InterpreterTest.java :  » Workflow-Engines » osbl-1_0 » org » concern » controller » Java Open Source

Java Open Source » Workflow Engines » osbl 1_0 
osbl 1_0 » org » concern » controller » InterpreterTest.java
package org.concern.controller;

import junit.framework.TestCase;

import java.util.*;

public class InterpreterTest extends TestCase
{
    protected Process process;

    public InterpreterTest(String name) {
        super(name);
    }

    public void testInterpreter()
        throws Exception
    {
        Map evaluations = new HashMap();
        evaluations.put("a", Boolean.TRUE);
        evaluations.put("b", Boolean.TRUE);
        evaluations.put("c", Boolean.TRUE);
        evaluations.put("j", null);
        evaluations.put("k", null);
        evaluations.put("l", null);
        evaluations.put("x", Boolean.FALSE);
        evaluations.put("y", Boolean.FALSE);
        evaluations.put("z", Boolean.FALSE);
        Interpreter interpreter = new Interpreter(evaluations);
        assertTrue(interpreter.eval("a || j || x"));
        assertFalse(interpreter.eval("a && j && x"));
        assertFalse(interpreter.eval("k"));
        assertFalse(interpreter.eval("!l"));
        assertFalse(interpreter.eval("k || !k"));
        assertTrue(interpreter.eval("(k || !k) || (a && !x)"));
        assertTrue(interpreter.eval("(k || !k) || !(!a || x)"));
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.