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

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


                "\n" +
                "\n" +
                "\n" +
                "");
        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];
View Full Code Here


    public void testDefinitionsParser4() {
        Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" +
                "    def m1(self):pass");
        assertEquals(1, m.body.length);
        ClassDef classDef = (ClassDef) m.body[0];
        assertEquals("Bar", ((NameTok) classDef.name).id);

        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        assertEquals("m1", ((NameTok) funcDef.name).id);
    }
View Full Code Here

        Module m = (Module) FastDefinitionsParser.parse("class Bar(object):\n" +
                "    def m1(self):pass\n"
                +
                "def m2(self):pass\n");
        assertEquals(2, m.body.length);
        ClassDef classDef = (ClassDef) m.body[0];

        assertEquals("Bar", ((NameTok) classDef.name).id);

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

                "    class Zoo(object):\n"
                +
                "        def m1(self):pass\n" +
                "def m2(self):pass\n");
        assertEquals(2, m.body.length);
        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);

        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);

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

        assertEquals("m2", ((NameTok) ((FunctionDef) m.body[1]).name).id);
View Full Code Here

                        "class Bar2(object):\n" +
                        "    class Zoo2(object):\n" +
                        "        class PPP2(self):pass\n");
        assertEquals(2, m.body.length);

        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);
        assertEquals("PPP", ((NameTok) ((ClassDef) classDefZoo.body[0]).name).id);

        //check the 2nd leaf
        classDefBar = (ClassDef) m.body[1];
View Full Code Here

                        "class Bar2(object):\n" +
                        "    class Zoo2(object):\n" +
                        "        pass\n");
        assertEquals(2, m.body.length);

        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);

        //check the 2nd leaf
        classDefBar = (ClassDef) m.body[1];
        assertEquals("Bar2", ((NameTok) classDefBar.name).id);
View Full Code Here

                        "    pass\n" +
                        "class Bar2(object):\n" +
                        "    pass\n");
        assertEquals(2, m.body.length);

        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
View Full Code Here

                "        def m2(self):pass\n" +
                "            def m3(self):pass\n"
                +
                "def mGlobal(self):pass\n");
        assertEquals(2, m.body.length);
        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
        assertEquals("mGlobal", ((NameTok) ((FunctionDef) m.body[1]).name).id);

        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);

        assertEquals(2, classDefZoo.body.length);
        assertEquals("m1", ((NameTok) ((FunctionDef) classDefZoo.body[0]).name).id);
View Full Code Here

                "        def m2(self):pass\n" +
                "            def m3(self):pass\n"
                +
                "def mGlobal(self):pass\n");
        assertEquals(2, m.body.length);
        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
        assertEquals("mGlobal", ((NameTok) ((FunctionDef) m.body[1]).name).id);

        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);

        assertEquals(2, classDefZoo.body.length);
        assertEquals("m1", ((NameTok) ((FunctionDef) classDefZoo.body[0]).name).id);
View Full Code Here

                +
                "            #def m3(self):pass\n" +
                "            'string'\n" +
                "def mGlobal(self):pass\n");
        assertEquals(2, m.body.length);
        ClassDef classDefBar = (ClassDef) m.body[0];
        assertEquals(1, classDefBar.beginColumn);
        assertEquals(1, classDefBar.beginLine);

        assertEquals("Bar", ((NameTok) classDefBar.name).id);
        FunctionDef defGlobal = (FunctionDef) m.body[1];
        assertEquals("mGlobal", ((NameTok) (defGlobal).name).id);
        assertEquals(1, defGlobal.beginColumn);
        assertEquals(7, defGlobal.beginLine);

        ClassDef classDefZoo = (ClassDef) classDefBar.body[0];
        assertEquals("Zoo", ((NameTok) classDefZoo.name).id);
        assertEquals(5, classDefZoo.beginColumn);
        assertEquals(2, classDefZoo.beginLine);

        assertEquals(2, classDefZoo.body.length);
View Full Code Here

TOP

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

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.