[Pydev-cvs] org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion PythonComple
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2007-07-09 01:19:03
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv923/tests_completions/org/python/pydev/editor/codecompletion Modified Files: PythonCompletionWithoutBuiltinsTest.java Log Message: Adaptation and instance checking considered in code-completion. Index: PythonCompletionWithoutBuiltinsTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/PythonCompletionWithoutBuiltinsTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PythonCompletionWithoutBuiltinsTest.java 8 Jul 2007 21:14:54 -0000 1.5 --- PythonCompletionWithoutBuiltinsTest.java 9 Jul 2007 01:19:03 -0000 1.6 *************** *** 15,18 **** --- 15,19 ---- import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.python.pydev.core.ICallback; + import org.python.pydev.core.ILocalScope; import org.python.pydev.core.IModule; import org.python.pydev.core.TestDependent; *************** *** 39,43 **** PythonCompletionWithoutBuiltinsTest test = new PythonCompletionWithoutBuiltinsTest(); test.setUp(); ! test.testAssertDeterminesClass4(); test.tearDown(); System.out.println("Finished"); --- 40,44 ---- PythonCompletionWithoutBuiltinsTest test = new PythonCompletionWithoutBuiltinsTest(); test.setUp(); ! test.testAssertDeterminesClass6(); test.tearDown(); System.out.println("Finished"); *************** *** 94,98 **** --- 95,128 ---- requestCompl("from testlib.unittest.testcase.TestCase import assertBM", new String[]{"assertBMPsNotEqual","assertBMPsEqual"}); } + + /** + * This test checks the code-completion for adaptation and factory methods, provided that the + * class expected is passed as one of the parameters. + * + * This is done in AssignAnalysis + */ + public void testProtocolsAdaptation() throws CoreException, BadLocationException{ + String s = + "import protocols\n" + + "class InterfM1(protocols.Interface):\n" + + " def m1(self):\n" + + " pass\n" + + " \n" + + "class Bar(object):\n" + + " protocols.advise(instancesProvide=[InterfM1])\n" + + "if __name__ == '__main__':\n" + + " a = protocols.adapt(Bar(), InterfM1)\n" + + " a."; + + requestCompl(s, s.length(), -1, new String[]{"m1()"}); + } + /** + * Check if some assert for an instance is enough to get the type of some variable. This should + * be configurable so that the user can do something as assert IsInterfaceDeclared(obj, Class) or + * AssertImplements(obj, Class), with the assert or not, providing some way for the user to configure that. + * + * This is done in ILocalScope#getPossibleClassesForActivationToken + */ public void testAssertDeterminesClass() throws CoreException, BadLocationException{ String s = *************** *** 151,154 **** --- 181,213 ---- } + public void testAssertDeterminesClass5() throws CoreException, BadLocationException{ + String s = + "class InterfM1:\n" + + " def m1(self):\n" + + " pass\n" + + "\n" + + "" + + "def m1(a):\n" + + " assert InterfM1.implementedBy(a)\n" + + " a."; + + requestCompl(s, s.length(), -1, new String[]{"m1()"}); + + } + public void testAssertDeterminesClass6() throws CoreException, BadLocationException{ + String s = + "class InterfM1:\n" + + " def m1(self):\n" + + " pass\n" + + "\n" + + "" + + "def m1(a):\n" + + " assert InterfM1.implementedBy()\n" + //should give no error + " a."; + + requestCompl(s, s.length(), -1, new String[]{}); + + } + public void testMultilineImportCompletion() throws CoreException, BadLocationException{ String s = "from testlib import (\n"; |