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

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


                "from __future__ import with_statement\n" +
                "with foo:\n" +
                "    print 'bla'\n" +
                "";
        //we'll actually treat this as a try..finally with a body with try..except..else
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(2, mod.body.length);
        assertTrue(mod.body[1] instanceof With);
        With w = (With) mod.body[1];
        assertTrue(((WithItem) w.with_item[0]).optional_vars == null);
View Full Code Here


                "from __future__ import with_statement\n" +
                "with foo as x:\n" +
                "    print 'bla'\n" +
                "";
        //we'll actually treat this as a try..finally with a body with try..except..else
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(2, mod.body.length);
        assertTrue(mod.body[1] instanceof With);
        With w = (With) mod.body[1];
        assertTrue(((WithItem) w.with_item[0]).optional_vars != null);
View Full Code Here

                "with foo as x:\n"
                +
                "    print 'bla'\n" +
                "";
        //we'll actually treat this as a try..finally with a body with try..except..else
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(2, mod.body.length);
        assertTrue(mod.body[1] instanceof With);
        With w = (With) mod.body[1];
        assertTrue(((WithItem) w.with_item[0]).optional_vars != null);
View Full Code Here

                "from __future__ import (division, with_statement)\n" +
                "with foo as x:\n"
                +
                "    print 'bla'\n" +
                "";
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(2, mod.body.length);
        assertTrue(mod.body[1] instanceof With);
        With w = (With) mod.body[1];
        assertTrue(((WithItem) w.with_item[0]).optional_vars != null);
View Full Code Here

                "def fun():\n"
                +
                "   with open('somepath') as f:\n" +
                "       return f.read()\n" +
                "";
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(2, mod.body.length);

    }
View Full Code Here

                "finally:\n" +
                "    'finally'\n" +
                "\n" +
                "";
        //we'll actually treat this as a try..finally with a body with try..except..else
        Module mod = (Module) parseLegalDocStr(str);
        assertEquals(1, mod.body.length);
        TryFinally f = (TryFinally) mod.body[0];

        assertEquals(1, f.body.length);
        TryExcept exc = (TryExcept) f.body[0];
View Full Code Here

                "@classdec2\n" +
                "class A:\n" +
                "    pass\n" +
                "";
        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        ClassDef d = (ClassDef) m.body[0];
        assertEquals(2, d.decs.length);
        assertEquals("classdec", NodeUtils.getRepresentationString(d.decs[0].func));
        assertEquals("classdec2", NodeUtils.getRepresentationString(d.decs[1].func));
    }
View Full Code Here

                +
                "print(abstracts)\n" +
                "\n" +
                "";
        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign a0 = (Assign) m.body[0];
        Assign a1 = (Assign) m.body[1];
        assertTrue(a0.value instanceof Dict);
        SetComp setComp = (SetComp) a1.value;
View Full Code Here

    public void testSetCreation() {
        String s = "" +
                "namespace = {1, 2, 3, 4}\n" +
                "";
        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign a0 = (Assign) m.body[0];
        assertTrue(a0.value instanceof Set);
        assertEquals("Assign[targets=[Name[id=namespace, ctx=Store, reserved=false]], value="
                +
                "Set[elts=[Num[n=1, type=Int, num=1], Num[n=2, type=Int, num=2], "
View Full Code Here

                +
                "print(abstracts)\n" +
                "\n" +
                "";
        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        Assign a0 = (Assign) m.body[0];
        Assign a1 = (Assign) m.body[1];
        assertTrue(a0.value instanceof Dict);
        DictComp dictComp = (DictComp) a1.value;
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.