Package eu.admire.dispel.parser.types

Examples of eu.admire.dispel.parser.types.Variable


            runDISPEL("package test1 { Integer x = 1; register x; } " +
            "package test2 { String y = \"Hello World\"; register y; } ");
        assertNull(mError);
        RegisteredObject x = builder.getRegistered().get("test1.x");
        assertTrue(x.getObject() instanceof Variable);
        Variable var = (Variable)x.getObject();
        assertTrue(var.getType() instanceof PrimitiveType);
        assertEquals(1l, var.getValue());
        RegisteredObject y = builder.getRegistered().get("test2.y");
        assertTrue(y.getObject() instanceof Variable);
        var = (Variable)y.getObject();
        assertTrue(var.getType() instanceof PrimitiveType);
        assertEquals("Hello World", var.getValue());
    }
View Full Code Here


    {
        DISPELGraphBuilder builder =
            runDISPEL("Connection c; " +
                    "|- [ <s= { 1, 2, 3} > ] -| => c; ");
        assertNull(mError);
        Variable c = builder.getDispelExecutionState().getVariables().get("c");
        Connection connection = (Connection)c.getValue();
        LiteralValuesNode literal =
            (LiteralValuesNode)connection.getSource();
        List<Object> values = literal.getValues();
        assertEquals(ListMarker.BEGIN, values.get(0));
        assertTrue(values.get(1) instanceof Map);
View Full Code Here

   
    public void testMod() throws Exception
    {
        DISPELGraphBuilder builder = runDISPEL("Integer x = 10 % 3;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("x");
        assertEquals(1l, var.getValue());
    }
View Full Code Here

                    "     PE(<> => <Connection output>) MyPE = createPE(i); " +
                    "     MyPE p = new MyPE; " +
                    "     p.output => b.input[i]; " +
                    "}");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("b");
        assertTrue(var.getValue() instanceof RequestNode);
        RequestNode node = (RequestNode)var.getValue();
        for (int i=0; i<4; i++)
        {
            RequestNode a = node.getInput("input", i).getSource();
            RequestNode source = a.getInput("input", 0).getSource();
            assertTrue(source instanceof LiteralValuesNode);
View Full Code Here

        DISPELGraphBuilder builder =
            runDISPEL(
                    "Integer[] i = {1, 2, 3, 4};\n" +
                "String[] s = new String[] {\"a\", \"b\", \"c\"};");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("i");
        for (int i=0; i<4; i++)
        {
            assertEquals(
                    Long.valueOf(i+1),
                    var.getValue(Collections.singletonList(i)));
        }
        var = builder.getDispelExecutionState().getVariables().get("s");
        assertEquals("a", var.getValue(Collections.singletonList(0)));
        assertEquals("b", var.getValue(Collections.singletonList(1)));
        assertEquals("c", var.getValue(Collections.singletonList(2)));
    }
View Full Code Here

            runDISPEL(
                    "Integer f(Integer[] i) { return i[0] + i[1]; };\n" +
                    "Integer r = f(new Integer[] {1, 2, 3});\n" +
                    "f(new Integer[] {1, 2, 3});");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("r");
        assertEquals(3l, var.getValue());
    }
View Full Code Here

            runDISPEL(
                    "Type Location is <Integer x, y, z; String label>;\n" +
                    "Location loc = <label = \"here\", z = 3, y = 5, x = -2>;\n" +
                    "String there = loc.label;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("loc");
        assertTrue(var.getValue() instanceof Map);
        Map<String, Object> tuple = (Map<String, Object>)var.getValue();
        assertEquals("here", tuple.get("label"));
        assertEquals(3l, tuple.get("z"));
        assertEquals(5l, tuple.get("y"));
        assertEquals(-2l, tuple.get("x"));
        var = builder.getDispelExecutionState().getVariables().get("there");
        assertEquals("here", var.getValue());
    }
View Full Code Here

        DISPELGraphBuilder builder = runDISPEL("use a.A; " +
                "A a1 = new A; A a2 = new A; " +
                "a1.output => a2.input; a1.output => a2.input; " +
                "submit a1;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("a1");
        assertNotNull(var);
        assertTrue(var.getValue() instanceof ProcessingElementNode);
        ProcessingElementNode a1 = (ProcessingElementNode)var.getValue();
        Connection out = a1.getOutput("output", 0);
        assertEquals(1, out.getTargets().size());
        System.out.println(a1);
    }
View Full Code Here

            "} " +
            "PE(<Connection in1; Connection in2> => <>) MyPE = f(); " +
            "MyPE m = new MyPE;" +
            "|- 1 -| => m.in1; |- 2 -| => m.in2;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("m");
        assertTrue(var.getValue() instanceof CompositeProcessingElement);
        Connection in1 = ((CompositeProcessingElement)var.getValue()).getInput("in1", 0);
        assertTrue(in1.getSource() instanceof LiteralValuesNode);
        assertEquals("a.A", in1.getTargets().get(0).getRequestNode().getName());
        Connection in2 = ((CompositeProcessingElement)var.getValue()).getInput("in2", 0);
        assertTrue(in2.getSource() instanceof LiteralValuesNode);
        assertEquals("b.B", in2.getTargets().get(0).getRequestNode().getName());
    }
View Full Code Here

        assertTrue(object.getObject() instanceof Variable);
        reg = new DispelObject("i", ((Variable)object.getObject()).getValue());
        mRegistry.register(reg.name, reg);
        builder = runDISPEL("use s; use i; String a = s; Integer b = i;");
        assertNull(mError);
        Variable var = builder.getDispelExecutionState().getVariables().get("s");
        assertNotNull(var);
        assertTrue(var.getValue() instanceof String);
        assertEquals("abcde", var.getValue());
        var = builder.getDispelExecutionState().getVariables().get("i");
        assertNotNull(var);
        assertTrue(var.getValue() instanceof Long);
        assertEquals(123l, var.getValue());
        var = builder.getDispelExecutionState().getVariables().get("b");
        assertNotNull(var);
        assertTrue(var.getValue() instanceof Long);
        assertEquals(123l, var.getValue());
    }
View Full Code Here

TOP

Related Classes of eu.admire.dispel.parser.types.Variable

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.