[Pydev-cvs] org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited So
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-08-21 20:56:20
|
Update of /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19176/tests_completions/org/python/pydev/editor/codecompletion/revisited Modified Files: SourceModuleProposalTest.java Log Message: Minor changes for console / possible race condition on linking with outline page. Index: SourceModuleProposalTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_completions/org/python/pydev/editor/codecompletion/revisited/SourceModuleProposalTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SourceModuleProposalTest.java 25 Feb 2008 11:21:34 -0000 1.3 --- SourceModuleProposalTest.java 21 Aug 2008 20:56:28 -0000 1.4 *************** *** 1,102 **** ! /* ! * Created on Apr 14, 2005 ! * ! * @author Fabio Zadrozny ! */ ! package org.python.pydev.editor.codecompletion.revisited; ! ! import junit.framework.TestCase; ! ! import org.eclipse.jface.text.BadLocationException; ! import org.eclipse.jface.text.Document; ! import org.eclipse.jface.text.IDocument; ! import org.eclipse.jface.text.IRegion; ! import org.python.pydev.core.IPythonNature; ! import org.python.pydev.editor.codecompletion.IPyCompletionProposal; ! import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; ! import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! ! /** ! * @author Fabio Zadrozny ! */ ! public class SourceModuleProposalTest extends TestCase { ! ! public static void main(String[] args) { ! try { ! SourceModuleProposalTest test = new SourceModuleProposalTest(); ! test.setUp(); ! test.testOffset(); ! test.tearDown(); ! junit.textui.TestRunner.run(SourceModuleProposalTest.class); ! } catch (Throwable e) { ! e.printStackTrace(); ! } ! } ! ! private IPythonNature nature; ! ! /* ! * @see TestCase#setUp() ! */ ! protected void setUp() throws Exception { ! super.setUp(); ! nature = CodeCompletionTestsBase.createStaticNature(); ! } ! ! /* ! * @see TestCase#tearDown() ! */ ! protected void tearDown() throws Exception { ! super.tearDown(); ! } ! ! public void testOffset() throws BadLocationException{ ! String docStr = ""+ ! "class A: \n" + ! " pass \n" + ! " \n" + ! "if __name__ == '__main__': \n" + ! " pass \n"; ! ! checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! checkProposal(docStr, 2, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! ! docStr = ""+ ! "class A: \n" + ! " pass \n" + ! " \n" + ! "class B: \n" + ! " pass \n" + ! " \n" + ! "if __name__ == '__main__': \n" + ! " pass \n"; ! ! checkProposal(docStr, 5, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! ! } ! ! /** ! * @param docStr ! * @param line ! * @param definition ! * @param addTo ! * @throws BadLocationException ! */ ! private void checkProposal(String docStr, int line, String tokDef, int addTo) throws BadLocationException { ! IDocument doc = new Document(docStr); ! SourceModule mod = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, 0); ! SourceModuleProposal s = new SourceModuleProposal("",0,0,0,null,"",null,"",mod, IPyCompletionProposal.PRIORITY_DEFAULT); ! s.doc = doc; ! if(tokDef != null) ! try { ! s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! } catch (Exception e) { ! throw new RuntimeException(e); ! } ! s.addTo = addTo; ! IRegion region = doc.getLineInformation(line); ! assertEquals(region.getOffset()+region.getLength(), s.getReplacementOffset()); ! } ! ! } --- 1,102 ---- ! ///* ! // * Created on Apr 14, 2005 ! // * ! // * @author Fabio Zadrozny ! // */ ! //package org.python.pydev.editor.codecompletion.revisited; ! // ! //import junit.framework.TestCase; ! // ! //import org.eclipse.jface.text.BadLocationException; ! //import org.eclipse.jface.text.Document; ! //import org.eclipse.jface.text.IDocument; ! //import org.eclipse.jface.text.IRegion; ! //import org.python.pydev.core.IPythonNature; ! //import org.python.pydev.editor.codecompletion.IPyCompletionProposal; ! //import org.python.pydev.editor.codecompletion.revisited.modules.AbstractModule; ! //import org.python.pydev.editor.codecompletion.revisited.modules.SourceModule; ! // ! ///** ! // * @author Fabio Zadrozny ! // */ ! //public class SourceModuleProposalTest extends TestCase { ! // ! // public static void main(String[] args) { ! // try { ! // SourceModuleProposalTest test = new SourceModuleProposalTest(); ! // test.setUp(); ! // test.testOffset(); ! // test.tearDown(); ! // junit.textui.TestRunner.run(SourceModuleProposalTest.class); ! // } catch (Throwable e) { ! // e.printStackTrace(); ! // } ! // } ! // ! // private IPythonNature nature; ! // ! // /* ! // * @see TestCase#setUp() ! // */ ! // protected void setUp() throws Exception { ! // super.setUp(); ! // nature = CodeCompletionTestsBase.createStaticNature(); ! // } ! // ! // /* ! // * @see TestCase#tearDown() ! // */ ! // protected void tearDown() throws Exception { ! // super.tearDown(); ! // } ! // ! // public void testOffset() throws BadLocationException{ ! // String docStr = ""+ ! // "class A: \n" + ! // " pass \n" + ! // " \n" + ! // "if __name__ == '__main__': \n" + ! // " pass \n"; ! // ! // checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! // checkProposal(docStr, 2, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! // ! // docStr = ""+ ! // "class A: \n" + ! // " pass \n" + ! // " \n" + ! // "class B: \n" + ! // " pass \n" + ! // " \n" + ! // "if __name__ == '__main__': \n" + ! // " pass \n"; ! // ! // checkProposal(docStr, 5, null, SourceModuleProposal.ADD_TO_LAST_LINE_BEFORE_MAIN); ! // checkProposal(docStr, 2, "A" , SourceModuleProposal.ADD_TO_LAST_CLASS_LINE); ! // ! // } ! // ! // /** ! // * @param docStr ! // * @param line ! // * @param definition ! // * @param addTo ! // * @throws BadLocationException ! // */ ! // private void checkProposal(String docStr, int line, String tokDef, int addTo) throws BadLocationException { ! // IDocument doc = new Document(docStr); ! // SourceModule mod = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, 0); ! // SourceModuleProposal s = new SourceModuleProposal("",0,0,0,null,"",null,"",mod, IPyCompletionProposal.PRIORITY_DEFAULT); ! // s.doc = doc; ! // if(tokDef != null) ! // try { ! // s.definition = mod.findGlobalTokDef(CompletionStateFactory.getEmptyCompletionState(tokDef, null, new CompletionCache()), null); ! // } catch (Exception e) { ! // throw new RuntimeException(e); ! // } ! // s.addTo = addTo; ! // IRegion region = doc.getLineInformation(line); ! // assertEquals(region.getOffset()+region.getLength(), s.getReplacementOffset()); ! // } ! // ! //} |