[Pydev-cvs] org.python.pydev.parser/tests/org/python/pydev/parser PyParserTest.java, 1.38, 1.39 PyP
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:38
|
Update of /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/tests/org/python/pydev/parser Modified Files: PyParserTest.java PyParserTestBase.java PyParser25Test.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: PyParser25Test.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParser25Test.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyParser25Test.java 14 Mar 2008 00:23:16 -0000 1.12 --- PyParser25Test.java 27 Sep 2008 19:58:43 -0000 1.13 *************** *** 24,28 **** PyParser25Test test = new PyParser25Test(); test.setUp(); ! test.testNewWithStmt4(); test.tearDown(); System.out.println("Finished"); --- 24,28 ---- PyParser25Test test = new PyParser25Test(); test.setUp(); ! test.testImportFails(); test.tearDown(); System.out.println("Finished"); *************** *** 111,114 **** --- 111,129 ---- } + public void testNewRelativeImport4(){ + setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); + String str = "from ...bar import foo\n"; + Module mod = (Module) parseLegalDocStr(str); + ImportFrom f = (ImportFrom) mod.body[0]; + assertEquals(3, f.level); + assertEquals("bar", ((NameTok)f.module).id); + } + + public void testImportFails(){ + setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); + String str = "from import foo\n"; + parseILegalDoc(new Document(str)); + } + public void testNewWithStmt(){ setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5); Index: PyParserTestBase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParserTestBase.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyParserTestBase.java 16 Jun 2007 17:12:54 -0000 1.18 --- PyParserTestBase.java 27 Sep 2008 19:58:43 -0000 1.19 *************** *** 52,109 **** } ! /** ! * @param s ! * @return ! */ ! protected static SimpleNode parseLegalDocStr(String s, Object ... additionalErrInfo) { ! Document doc = new Document(s); //by default always use the last version for parsing ! return parseLegalDoc(doc, additionalErrInfo, parser); ! } ! protected SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo) { ! return parseLegalDoc(doc, additionalErrInfo, parser); } ! protected ParseException parseILegalDoc(IDocument doc) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err == null){ ! fail("Expected a ParseException and the doc was successfully parsed."); } ! if(!(err instanceof ParseException)){ ! fail("Expected a ParseException and received:"+err.getClass()); ! } ! return (ParseException) err; } /** ! * @param additionalErrInfo can be used to add additional errors to the fail message if the doc is not parseable ! * @param parser the parser to be used to do the parsing. ! */ ! protected static SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo, PyParser parser) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err != null){ ! String s = ""; ! for (int i = 0; i < additionalErrInfo.length; i++) { ! s += additionalErrInfo[i]; ! } ! if (err instanceof ParseException) { ! ParseException parseErr = (ParseException) err; parseErr.printStackTrace(); ! ! Token token = parseErr.currentToken; ! if(token != null){ ! fail("Expected no error, received: "+parseErr.getMessage()+" "+s+" line:"+token.beginLine+ " col:"+token.beginColumn); ! } ! } ! ! fail("Expected no error, received: "+err+" "+s); ! } ! assertNotNull(objects.o1); ! return objects.o1; ! } public void testEmpty() { --- 52,109 ---- } ! /** ! * @param s ! * @return ! */ ! protected static SimpleNode parseLegalDocStr(String s, Object ... additionalErrInfo) { ! Document doc = new Document(s); //by default always use the last version for parsing ! return parseLegalDoc(doc, additionalErrInfo, parser); ! } ! protected SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo) { ! return parseLegalDoc(doc, additionalErrInfo, parser); } ! protected ParseException parseILegalDoc(IDocument doc) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err == null){ ! fail("Expected a ParseException and the doc was successfully parsed."); } ! if(!(err instanceof ParseException)){ ! fail("Expected a ParseException and received:"+err.getClass()); ! } ! return (ParseException) err; } /** ! * @param additionalErrInfo can be used to add additional errors to the fail message if the doc is not parseable ! * @param parser the parser to be used to do the parsing. ! */ ! protected static SimpleNode parseLegalDoc(IDocument doc, Object[] additionalErrInfo, PyParser parser) { ! parser.setDocument(doc, false, null); Tuple<SimpleNode, Throwable> objects = parser.reparseDocument(); ! Object err = objects.o2; ! if(err != null){ ! String s = ""; ! for (int i = 0; i < additionalErrInfo.length; i++) { ! s += additionalErrInfo[i]; ! } ! if (err instanceof ParseException) { ! ParseException parseErr = (ParseException) err; parseErr.printStackTrace(); ! ! Token token = parseErr.currentToken; ! if(token != null){ ! fail("Expected no error, received: "+parseErr.getMessage()+" "+s+" line:"+token.beginLine+ " col:"+token.beginColumn); ! } ! } ! ! fail("Expected no error, received: "+err+" "+s); ! } ! assertNotNull(objects.o1); ! return objects.o1; ! } public void testEmpty() { Index: PyParserTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/tests/org/python/pydev/parser/PyParserTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** PyParserTest.java 15 Jun 2008 22:59:22 -0000 1.38 --- PyParserTest.java 27 Sep 2008 19:58:43 -0000 1.39 *************** *** 49,54 **** @Override protected void setUp() throws Exception { ! super.setUp(); ! PyParser.USE_FAST_STREAM = true; } --- 49,54 ---- @Override protected void setUp() throws Exception { ! super.setUp(); ! PyParser.USE_FAST_STREAM = true; } *************** *** 141,177 **** public void testMultilineStr() { ! String s = "" + ! "a = '''\n" + ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n" + ! "really really big string\n" + ! "really really big string\n" + ! "'''"; ! parseLegalDocStr(s); } public void testErr() { ! String s = "" + ! "def m():\n" + ! " call(a,"; ! parseILegalDoc(new Document(s)); } --- 141,177 ---- public void testMultilineStr() { ! String s = "" + ! "a = '''\n" + ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n"+ ! "really really big string\n" + ! "really really big string\n" + ! "really really big string\n" + ! "'''"; ! parseLegalDocStr(s); } public void testErr() { ! String s = "" + ! "def m():\n" + ! " call(a,"; ! parseILegalDoc(new Document(s)); } *************** *** 214,224 **** public void testYield2() { setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_4); ! String s = "" + ! "class Generator:\n" + ! " def __iter__(self): \n" + ! " for a in range(10):\n" + ! " yield foo(a)\n" + ! ""; ! parseLegalDocStr(s); } --- 214,224 ---- public void testYield2() { setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_4); ! String s = "" + ! "class Generator:\n" + ! " def __iter__(self): \n" + ! " for a in range(10):\n" + ! " yield foo(a)\n" + ! ""; ! parseLegalDocStr(s); } *************** *** 338,350 **** // not removed completely because we may still want to debug it later... // public void testOnCsv() { ! // PyParser.USE_FAST_STREAM = false; ! // String loc = TestDependent.PYTHON_LIB+"csv.py"; ! // String s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); ! // ! // PyParser.USE_FAST_STREAM = true; ! // loc = TestDependent.PYTHON_LIB+"csv.py"; ! // s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); // } --- 338,350 ---- // not removed completely because we may still want to debug it later... // public void testOnCsv() { ! // PyParser.USE_FAST_STREAM = false; ! // String loc = TestDependent.PYTHON_LIB+"csv.py"; ! // String s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); ! // ! // PyParser.USE_FAST_STREAM = true; ! // loc = TestDependent.PYTHON_LIB+"csv.py"; ! // s = REF.getFileContents(new File(loc)); ! // parseLegalDocStr(s); // } *************** *** 380,386 **** public void testOnTestContextLib() { if(TestDependent.HAS_PYTHON_TESTS){ ! String loc = TestDependent.PYTHON_LIB+"test/test_contextlib.py"; ! String s = REF.getFileContents(new File(loc)); ! parseLegalDocStr(s,"(file: test_contextlib.py)"); } } --- 380,386 ---- public void testOnTestContextLib() { if(TestDependent.HAS_PYTHON_TESTS){ ! String loc = TestDependent.PYTHON_LIB+"test/test_contextlib.py"; ! String s = REF.getFileContents(new File(loc)); ! parseLegalDocStr(s,"(file: test_contextlib.py)"); } } *************** *** 544,554 **** */ public void testParser10() { ! String s = "" + ! "l = [ \"encode\", \"decode\" ] \n"+ ! "\n"; ! SimpleNode node = parseLegalDocStr(s); ! List<ASTEntry> strs = SequencialASTIteratorVisitor.create(node).getAsList(new Class[]{Str.class}); ! assertEquals(7, strs.get(0).node.beginColumn); ! assertEquals(17, strs.get(1).node.beginColumn); } --- 544,554 ---- */ public void testParser10() { ! String s = "" + ! "l = [ \"encode\", \"decode\" ] \n"+ ! "\n"; ! SimpleNode node = parseLegalDocStr(s); ! List<ASTEntry> strs = SequencialASTIteratorVisitor.create(node).getAsList(new Class[]{Str.class}); ! assertEquals(7, strs.get(0).node.beginColumn); ! assertEquals(17, strs.get(1).node.beginColumn); } |