samples/visitor/03-visitunknown/src-test2.0/org/apidesign/test/visitor/InvalidCountNumbersTest.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 22:38:00 +0200
changeset 265 eb31b2d1822a
parent 167 ab8c04922abe
permissions -rw-r--r--
All tests are passing now in the "no.failures" mode
jtulach@167
     1
package org.apidesign.test.visitor;
jtulach@167
     2
jtulach@167
     3
import static junit.framework.Assert.*;
jtulach@167
     4
import org.apidesign.visitor.Language.Expression;
jtulach@167
     5
import org.apidesign.visitor.Language.Minus;
jtulach@167
     6
import org.apidesign.visitor.Language.Number;
jtulach@167
     7
import org.apidesign.visitor.Language.Plus;
jtulach@167
     8
import org.junit.Test;
jtulach@167
     9
jtulach@167
    10
public class InvalidCountNumbersTest {
jtulach@167
    11
    @Test public void printOneMinusTwo() {
jtulach@167
    12
        // BEGIN: visitor.visitunknown.traversal
jtulach@167
    13
        Number one = new Number(1);
jtulach@167
    14
        Number three = new Number(3);
jtulach@167
    15
        Number four = new Number(4);
jtulach@167
    16
        Expression minus = new Plus(one, new Minus(three, four));
jtulach@167
    17
        
jtulach@265
    18
        int cnt = CountNumbersTest.countNumbers(minus);
jtulach@265
    19
        if (Boolean.getBoolean("no.failures")) {
jtulach@265
    20
            // Should have three numbers, but visitor does not
jtulach@265
    21
            // know how to go through minus
jtulach@265
    22
            assertEquals(
jtulach@265
    23
                "Wrong result as there is no traversal through minus", 1, cnt
jtulach@265
    24
            );
jtulach@265
    25
            return;
jtulach@265
    26
        }
jtulach@167
    27
        assertEquals(
jtulach@167
    28
            "Should have three numbers, but visitor does not " +
jtulach@265
    29
            "know how to go through minus", 3, cnt
jtulach@167
    30
        );
jtulach@167
    31
        // END: visitor.visitunknown.traversal
jtulach@167
    32
    }
jtulach@167
    33
}