Package javax.script

Examples of javax.script.ScriptEngine


        testThrowsAssertion(engine, "assertFalse(1 == 1)", "assertFalse should fail on a true boolean expression");
    }

    @Test
    public void testAssertFalse_python() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "a = False\n" + "assertFalse(a)", "assertFalse of a false variable should succeed");
        testWorks(engine, "assertFalse(1 == 2)", "assertFalse on a false boolean expression should succeed");
        testThrowsAssertion(engine, "a = True\n" + "assertFalse(a)", "assertFalse should fail on a true variable");
        testThrowsAssertion(engine, "assertFalse(1 == 1)", "assertFalse should fail on a true boolean expression");
    }
View Full Code Here


        testThrowsAssertion(engine, "assertFalse(1 == 1)", "assertFalse should fail on a true boolean expression");
    }

    @Test
    public void testAssertNull_javascript() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "var foo = null; assertNull(foo);", "assertNull should succeed on a null variable");
        testWorks(engine, "assertNull(null)", "assertNull should succeed on a null literal");
        testThrowsAssertion(engine, "assertNull(1)", "assertNull should fail on a number");
        testThrowsAssertion(engine, "var foo = '1'; assertNull(foo)", "assertNull should fail on a non-null variable");
    }
View Full Code Here

        testThrowsAssertion(engine, "var foo = '1'; assertNull(foo)", "assertNull should fail on a non-null variable");
    }

    @Test
    public void testAssertNull_python() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "foo = None\n" + "assertNull(foo)", "assertNull should succeed on a null variable");
        testWorks(engine, "assertNull(None)", "assertNull should succeed on a null literal");
        testThrowsAssertion(engine, "assertNull(1)", "assertNull should fail on a number");
        testThrowsAssertion(engine, "foo = '1'\n" + "assertNull(foo)", "assertNull should fail on a non-null variable");
    }
View Full Code Here

        testThrowsAssertion(engine, "foo = '1'\n" + "assertNull(foo)", "assertNull should fail on a non-null variable");
    }

    @Test
    public void testAssertNotNull_javascript() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertNotNull(1)", "assertNotNull should succeed on a number");
        testWorks(engine, "var foo = '1'; assertNotNull(foo)", "assertNotNull should succeed on a non-null variable");
        testThrowsAssertion(engine, "assertNotNull(foo)", "assertNotNull should fail on an undefined variable");
        testThrowsAssertion(engine, "var foo = null; assertNotNull(foo);",
            "assertNotNull should fail on a null variable");
View Full Code Here

        testThrowsAssertion(engine, "assertNotNull(null)", "assertNotNull should fail on a null literal");
    }

    @Test
    public void testAssertNotNull_python() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertNotNull(1)", "assertNotNull should succeed on a number");
        testWorks(engine, "foo = '1'\n" + "assertNotNull(foo)", "assertNotNull should succeed on a non-null variable");
        testThrowsAssertion(engine, "assertNotNull(foo)", "assertNotNull should fail on an undefined variable");
        testThrowsAssertion(engine, "foo = None\n" + "assertNotNull(foo);",
            "assertNotNull should fail on a null variable");
View Full Code Here

        testThrowsAssertion(engine, "assertNotNull(None)", "assertNotNull should fail on a null literal");
    }

    @Test
    public void testAssertEquals_Numbers_javascript() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertEquals(1, 1)", "1 == 1");
        testWorks(engine, "assertEquals(1.0, 1)", "1.0 == 1");
        testWorks(engine, "assertEquals(1.0, 1.0)", "1.0 == 1.0");
        testThrowsAssertion(engine, "assertEquals(1, 2)", "1 == 2");
    }
View Full Code Here

        testThrowsAssertion(engine, "assertEquals(1, 2)", "1 == 2");
    }

    @Test
    public void testAssertEquals_Numbers_python() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertEquals(1, 1)", "1 == 1");
        //Python distinguishes between ints and floats, so this
        //won't work (even though "1.0 == 1" returns true in pure python)
        //testWorks(engine, "assertEquals(1.0, 1)", "1.0 == 1");
        testWorks(engine, "assertEquals(1.0, 1.0)", "1.0 == 1.0");
View Full Code Here

        testThrowsAssertion(engine, "assertEquals(1, 2)", "1 == 2");
    }

    @Test
    public void testAssertEquals_Arrays_javascript() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertEquals(['a', 'b'], ['a', 'b'])", "native array comparison");
        testThrowsAssertion(engine, "assertEquals(['a', 'b'], ['c', 'd'])", "native array comparison with difference");
    }
View Full Code Here

        testThrowsAssertion(engine, "assertEquals(['a', 'b'], ['c', 'd'])", "native array comparison with difference");
    }

    @Test
    public void testAssertEquals_Arrays_python() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "assertEquals(['a', 'b'], ['a', 'b'])", "native array comparison");
        testThrowsAssertion(engine, "assertEquals(['a', 'b'], ['c', 'd'])", "native array comparison with difference");
    }
View Full Code Here

        testThrowsAssertion(engine, "assertEquals(['a', 'b'], ['c', 'd'])", "native array comparison with difference");
    }

    @Test
    public void testAssertEquals_Collections_javascript() {
        ScriptEngine engine = getScriptEngine();
        testWorks(engine, "a = new java.util.ArrayList; " + "b = new java.util.ArrayList; " + "a.add('a'); "
            + "b.add('a'); " + "assertEquals(a, b)", "ArrayList comparison");
        testThrowsAssertion(engine, "a = new java.util.ArrayList; " + "b = new java.util.ArrayList; " + "a.add('a'); "
            + "b.add('b'); " + "assertEquals(a, b)", "ArrayList comparison with difference");
    }
View Full Code Here

TOP

Related Classes of javax.script.ScriptEngine

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.