01: package org.concern.controller;
02:
03: import junit.framework.TestCase;
04:
05: import java.util.*;
06:
07: public class InterpreterTest extends TestCase {
08: protected Process process;
09:
10: public InterpreterTest(String name) {
11: super (name);
12: }
13:
14: public void testInterpreter() throws Exception {
15: Map evaluations = new HashMap();
16: evaluations.put("a", Boolean.TRUE);
17: evaluations.put("b", Boolean.TRUE);
18: evaluations.put("c", Boolean.TRUE);
19: evaluations.put("j", null);
20: evaluations.put("k", null);
21: evaluations.put("l", null);
22: evaluations.put("x", Boolean.FALSE);
23: evaluations.put("y", Boolean.FALSE);
24: evaluations.put("z", Boolean.FALSE);
25: Interpreter interpreter = new Interpreter(evaluations);
26: assertTrue(interpreter.eval("a || j || x"));
27: assertFalse(interpreter.eval("a && j && x"));
28: assertFalse(interpreter.eval("k"));
29: assertFalse(interpreter.eval("!l"));
30: assertFalse(interpreter.eval("k || !k"));
31: assertTrue(interpreter.eval("(k || !k) || (a && !x)"));
32: assertTrue(interpreter.eval("(k || !k) || !(!a || x)"));
33: }
34: }
|