author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 22:38:00 +0200 | |
changeset 265 | eb31b2d1822a |
parent 177 | 67d6dceb1002 |
permissions | -rw-r--r-- |
jtulach@176 | 1 |
package org.apidesign.test.visitor; |
jtulach@176 | 2 |
|
jtulach@176 | 3 |
import org.apidesign.test.visitor.PrintTest.PrintVisitor; |
jtulach@177 | 4 |
import org.apidesign.visitor.Language.Expression; |
jtulach@177 | 5 |
import org.apidesign.visitor.Language.Minus; |
jtulach@177 | 6 |
import org.apidesign.visitor.Language.Number; |
jtulach@176 | 7 |
import static junit.framework.Assert.*; |
jtulach@177 | 8 |
import org.apidesign.visitor.Language.Visitor; |
jtulach@176 | 9 |
import org.junit.Test; |
jtulach@176 | 10 |
|
jtulach@176 | 11 |
public class PrintOfMinusStructureTest { |
jtulach@177 | 12 |
public static Minus newMinus( |
jtulach@177 | 13 |
final Expression first, final Expression second |
jtulach@177 | 14 |
) { |
jtulach@177 | 15 |
return new Minus() { |
jtulach@177 | 16 |
public Expression getFirst() { |
jtulach@177 | 17 |
return first; |
jtulach@177 | 18 |
} |
jtulach@177 | 19 |
|
jtulach@177 | 20 |
public Expression getSecond() { |
jtulach@177 | 21 |
return second; |
jtulach@177 | 22 |
} |
jtulach@177 | 23 |
|
jtulach@177 | 24 |
public void visit(Visitor v) { |
jtulach@177 | 25 |
v.dispatchMinus(this); |
jtulach@177 | 26 |
} |
jtulach@177 | 27 |
}; |
jtulach@177 | 28 |
} |
jtulach@177 | 29 |
|
jtulach@177 | 30 |
|
jtulach@176 | 31 |
@Test public void printOneMinusTwo() { |
jtulach@177 | 32 |
Number one = PrintTest.newNumber(1); |
jtulach@177 | 33 |
Number two = PrintTest.newNumber(2); |
jtulach@177 | 34 |
Expression plus = newMinus(one, two); |
jtulach@176 | 35 |
|
jtulach@176 | 36 |
PrintVisitor print = new PrintVisitor(); |
jtulach@177 | 37 |
plus.visit(print.dispatch); |
jtulach@176 | 38 |
|
jtulach@265 | 39 |
if (Boolean.getBoolean("no.failures")) { |
jtulach@265 | 40 |
assertEquals("unknown12", print.sb.toString()); |
jtulach@265 | 41 |
return; |
jtulach@265 | 42 |
} |
jtulach@176 | 43 |
assertEquals("1 - 2", print.sb.toString()); |
jtulach@176 | 44 |
} |
jtulach@176 | 45 |
} |