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

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


        }
        Module m = (Module) FastDefinitionsParser.parse(buf.toString());
    }

    public void testEmpty() {
        Module m = (Module) FastDefinitionsParser.parse("# This file was created automatically by SWIG 1.3.29.\n" +
                ""
                +
                "" //empty
        );
        assertEquals(0, m.body.length);
View Full Code Here


                String s = "" +
                        "class Class1:         \n" +
                        "    def met1(self, a):\n" +
                        "        pass";
                SimpleNode node = parseLegalDocStr(s);
                Module m = (Module) node;
                ClassDef d = (ClassDef) m.body[0];
                FunctionDef f = (FunctionDef) d.body[0];
                assertEquals("self", ((Name) f.args.args[0]).id);
                assertEquals("a", ((Name) f.args.args[1]).id);
                return true;
View Full Code Here

            public Boolean call(Integer arg) {
                String s = "" +
                        "pass\n" +
                        "pass";
                Module m = (Module) parseLegalDocStr(s);
                assertEquals(2, m.body.length);
                Pass p1 = (Pass) m.body[0];
                Pass p2 = (Pass) m.body[1];
                //must intern specials in the same pass.
                assertSame(((SpecialStr) p1.specialsBefore.get(0)).str, ((SpecialStr) p2.specialsBefore.get(0)).str);
View Full Code Here

            public Boolean call(Integer arg) {
                String s = "" +
                        "def m():\n" +
                        "    call(a,";
                Tuple<SimpleNode, Throwable> tup = parseILegalDocSuccessfully(s);
                Module m = (Module) tup.o1;
                assertEquals(1, m.body.length);
                FunctionDef f = (FunctionDef) m.body[0];
                assertEquals("m", NodeUtils.getRepresentationString(f));
                return true;
            }
View Full Code Here

            public Boolean call(Integer arg) {
                String s = "class C: \n" +
                        "    pass\n" +
                        "#end\n" +
                        "";
                Module ast = (Module) parseLegalDocStr(s);
                ClassDef d = (ClassDef) ast.body[0];
                assertEquals(1, d.specialsAfter.size());
                commentType c = (commentType) d.specialsAfter.get(0);
                assertEquals("#end", c.id);
                return true;
View Full Code Here

            public Boolean call(Integer arg) {
                String s = "#end\n" +
                        "\n" +
                        "";
                Module ast = (Module) parseLegalDocStr(s);
                assertEquals(1, ast.specialsBefore.size());
                commentType c = (commentType) ast.specialsBefore.get(0);
                assertEquals("#end", c.id);
                return true;
            }
View Full Code Here

    public void testEmpty() throws Throwable {
        checkWithAllGrammars(new ICallback<Boolean, Integer>() {

            public Boolean call(Integer arg) {
                String s = "";
                Module ast = (Module) parseLegalDocStr(s);
                assertNotNull(ast);
                return true;
            }
        });
    }
View Full Code Here

        }

    }

    public void testFullRep() throws Exception {
        Module node = (Module) parseLegalDocStr("a.b.c.d");
        exprType attr = ((Expr) node.body[0]).value;
        assertEquals("a.b.c.d", NodeUtils.getFullRepresentationString(attr));
        exprType attr1 = NodeUtils.makeAttribute("a.b.c.d");
        assertEquals("a.b.c.d", NodeUtils.getFullRepresentationString(attr1));
        assertEquals(attr1.toString(), attr.toString());
View Full Code Here

        assertEquals(1, classes.size());
        assertEquals(endLine, classes.get(0).endLine);
    }

    public void testFindStmtForNode() throws Exception {
        Module ast = (Module) parseLegalDocStr("a=10;b=20;c=30");
        Assign assign = (Assign) ast.body[1];
        Name b = (Name) assign.targets[0];
        assertSame(assign, NodeUtils.findStmtForNode(ast, b));

        ast = (Module) parseLegalDocStr("a=10\nb=20\nc=30");
View Full Code Here

            public int getGrammarVersion() throws MisconfigurationException {
                return IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_2_7;
            }
        };
        Module node = (Module) parseLegalDocStr(s);
        FunctionDef funcDef = (FunctionDef) node.body[0];
        String result = PrettyPrinterV2.printArguments(p, funcDef.args);
        assertEquals("*args", result);
    }
View Full Code Here

TOP

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

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.