Package org.python.pydev.parser.jython.ast

Examples of org.python.pydev.parser.jython.ast.Assign


                "mutable_set = {1,2,3,4,5}\n" +
                "";

        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign assign = (Assign) m.body[0];
        Set set = (Set) assign.value;
        assertEquals(
                "Set[elts=[Num[n=1, type=Int, num=1], Num[n=2, type=Int, num=2], Num[n=3, type=Int, num=3], Num[n=4, type=Int, num=4], Num[n=5, type=Int, num=5]]]",
                set.toString());
    }
View Full Code Here


                "mutable_set = {x for x in xrange(10)}\n" +
                "";

        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign assign = (Assign) m.body[0];
        assertTrue(assign.value instanceof SetComp);
    }
View Full Code Here

                "d = {}\n" +
                "";

        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign assign = (Assign) m.body[0];
        assertTrue(assign.value instanceof Dict);
    }
View Full Code Here

                "d = {i: i*2 for i in range(3)}\n" +
                "";

        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign assign = (Assign) m.body[0];
        assertTrue(assign.value instanceof DictComp);
    }
View Full Code Here

                "");
        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length);
        Assign assign = (Assign) classDef.body[0];
        assertEquals(1, assign.targets.length);
        Name name = (Name) assign.targets[0];
        assertEquals("ATTRIBUTE", name.id);
    }
View Full Code Here

                "");
        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length);
        Assign assign = (Assign) classDef.body[0];
        assertEquals(2, assign.targets.length);
        Name name = (Name) assign.targets[0];
        assertEquals("ATTRIBUTE1", name.id);
        name = (Name) assign.targets[1];
        assertEquals("ATTRIBUTE2", name.id);
View Full Code Here

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);

        assertNull(funcDef.body[1]);
        Assign assign = (Assign) funcDef.body[0];
        assertEquals(1, assign.targets.length);
        Attribute attribute = (Attribute) assign.targets[0];
        NameTok attr = (NameTok) attribute.attr;
        assertEquals("ATTRIBUTE", attr.id.toString());
    }
View Full Code Here

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);

        for (int i = 0; i < 3; i++) {
            Assign assign = (Assign) funcDef.body[i];
            assertEquals(1, assign.targets.length);
            Attribute attribute = (Attribute) assign.targets[0];
            NameTok attr = (NameTok) attribute.attr;
            assertEquals("ATTRIBUTE" + i, attr.id.toString());
        }
View Full Code Here

                "");
        assertEquals(1, m.body.length);
        ClassDef classDef = ((ClassDef) m.body[0]);
        assertEquals("Bar", ((NameTok) classDef.name).id);
        assertEquals(1, classDef.body.length);
        Assign assign = (Assign) classDef.body[0];
        assertEquals(1, assign.targets.length);
        Name name = (Name) assign.targets[0];
        assertEquals("ATTRIBUTE", name.id);
    }
View Full Code Here

    public void testGlobalAttributes() {
        Module m = (Module) FastDefinitionsParser.parse("GLOBAL_ATTRIBUTE = 10\n" +
                "\n" +
                "");
        assertEquals(1, m.body.length);
        Assign assign = ((Assign) m.body[0]);
        assertEquals("GLOBAL_ATTRIBUTE", ((Name) assign.targets[0]).id);
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.ast.Assign

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.