[Pydev-cvs] org.python.pydev/tests/org/python/pydev/editor/codecompletion/revisited ASTManagerTest.j
Brought to you by:
fabioz
|
From: Fabio Z. <fa...@us...> - 2005-02-16 16:49:02
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9724/tests/org/python/pydev/editor/codecompletion/revisited Modified Files: ASTManagerTest.java PythonPathHelperTest.java Log Message: Code completion improvement Index: ASTManagerTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/codecompletion/revisited/ASTManagerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ASTManagerTest.java 2 Feb 2005 15:56:18 -0000 1.1 --- ASTManagerTest.java 16 Feb 2005 16:48:49 -0000 1.2 *************** *** 9,12 **** --- 9,13 ---- import org.eclipse.jface.text.Document; + import org.python.pydev.editor.codecompletion.revisited.modules.CompiledModule; import org.python.pydev.plugin.PythonNature; *************** *** 19,26 **** private CompletionState state; - public static void main(String[] args) { - junit.textui.TestRunner.run(ASTManagerTest.class); - } /* --- 20,32 ---- private CompletionState state; + private ASTManager manager; + private PythonNature nature; + private String token; + private int line; + private int col; + private String sDoc; + private Document doc; + private IToken[] comps = null; /* *************** *** 29,32 **** --- 35,41 ---- protected void setUp() throws Exception { super.setUp(); + CompiledModule.COMPILED_MODULES_ENABLED = false; + manager = new ASTManager(); + nature = new PythonNature(); } *************** *** 36,61 **** protected void tearDown() throws Exception { super.tearDown(); } public void testCompletion(){ ! ASTManager manager = new ASTManager(); ! PythonNature nature = new PythonNature(); ! String token = "C"; ! int line = 6; ! int col = 11; ! ! String sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; ! ! Document doc = new Document(sDoc); ! IToken[] comps = null; state = new CompletionState(line,col, token, nature); comps = manager.getCompletionsForToken(doc, state); --- 45,66 ---- protected void tearDown() throws Exception { super.tearDown(); + CompiledModule.COMPILED_MODULES_ENABLED = true; } public void testCompletion(){ ! token = "C"; ! line = 6; ! col = 11; ! sDoc = ""+ ! "class C: \n" + ! " \n" + ! " def makeit(self):\n" + ! " pass \n" + ! " \n" + ! "class D(C.: \n" + ! " \n" + ! " def a(self): \n" + ! " pass \n"; ! doc = new Document(sDoc); state = new CompletionState(line,col, token, nature); comps = manager.getCompletionsForToken(doc, state); *************** *** 178,181 **** --- 183,220 ---- } + + public void testLocals(){ + token = ""; + line = 2; + col = 10; + sDoc = ""+ + "def met(par1, par2): \n" + + " print \n"; + doc = new Document(sDoc); + state = new CompletionState(line,col, token, nature); + comps = manager.getCompletionsForToken(doc, state); + assertEquals(3, comps.length ); + assertIsIn("par1", comps); + assertIsIn("par2", comps); + assertIsIn("met", comps); + + + token = ""; + line = 3; + col = 13; + sDoc = ""+ + "class C: \n" + + " def met(self, par1, par2): \n" + + " print \n"; + doc = new Document(sDoc); + state = new CompletionState(line,col, token, nature); + comps = manager.getCompletionsForToken(doc, state); + assertEquals(4, comps.length ); + assertIsIn("par1", comps); + assertIsIn("par2", comps); + assertIsIn("self", comps); + assertIsIn("C", comps); + } + /** * @param string *************** *** 192,194 **** --- 231,237 ---- } + public static void main(String[] args) { + CompiledModule.COMPILED_MODULES_ENABLED = false; + junit.textui.TestRunner.run(ASTManagerTest.class); + } } Index: PythonPathHelperTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/codecompletion/revisited/PythonPathHelperTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PythonPathHelperTest.java 14 Feb 2005 11:51:23 -0000 1.4 --- PythonPathHelperTest.java 16 Feb 2005 16:48:49 -0000 1.5 *************** *** 38,41 **** --- 38,42 ---- public void setUp() throws Exception { super.setUp(); + CompiledModule.COMPILED_MODULES_ENABLED = false; manager = new ASTManager(); nature = new PythonNature(); *************** *** 47,50 **** --- 48,52 ---- */ public void tearDown() throws Exception { + CompiledModule.COMPILED_MODULES_ENABLED = true; super.tearDown(); } *************** *** 205,212 **** } public static void main(String[] args) { //IMPORTANT: I don't want to test the compiled modules, only the source modules. - CompiledModule.COMPILED_MODULES_ENABLED = false; junit.textui.TestRunner.run(PythonPathHelperTest.class); --- 207,234 ---- } + + public void testRelativeImport(){ + token = "Derived"; + line = 3; + col = 8; + + sDoc = ""+ + "from testlib.unittest.relative.testrelative import Derived \n"+ + " \n"+ + "Derived. \n"; + + IToken[] comps = null; + Document doc = new Document(sDoc); + CompletionState state = new CompletionState(line,col, token, nature); + comps = manager.getCompletionsForToken(doc, state); + assertEquals(2, comps.length); + ASTManagerTest.assertIsIn("test1", comps); + ASTManagerTest.assertIsIn("test2", comps); + + + } public static void main(String[] args) { //IMPORTANT: I don't want to test the compiled modules, only the source modules. junit.textui.TestRunner.run(PythonPathHelperTest.class); *************** *** 214,218 **** // PythonPathHelperTest test = new PythonPathHelperTest(); // test.setUp(); ! // test.testImportAs2(); // test.tearDown(); // } catch (Exception e) { --- 236,240 ---- // PythonPathHelperTest test = new PythonPathHelperTest(); // test.setUp(); ! // test.testRelativeImport(); // test.tearDown(); // } catch (Exception e) { |