|
From: David C. <dc...@us...> - 2005-10-13 01:00:44
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3446/src/org/rubypeople/rdt/internal/core/builder Modified Files: TC_RdtCompiler.java Added Files: TC_IndexUpdater.java Removed Files: IndexUpdater_UT.java Log Message: Partial support for opening classes from Test::Unit failure. --- NEW FILE: TC_IndexUpdater.java --- package org.rubypeople.rdt.internal.core.builder; import java.io.InputStreamReader; import junit.framework.TestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.jruby.ast.ClassNode; import org.jruby.ast.Colon2Node; import org.jruby.ast.Node; import org.jruby.ast.TrueNode; import org.jruby.lexer.yacc.ISourcePosition; import org.rubypeople.eclipse.shams.resources.ShamFile; import org.rubypeople.rdt.internal.core.parser.RdtPosition; import org.rubypeople.rdt.internal.core.parser.RubyParser; import org.rubypeople.rdt.internal.core.symbols.ClassSymbol; import org.rubypeople.rdt.internal.core.symbols.SymbolIndex; public class TC_IndexUpdater extends TestCase { private static final RdtPosition POSITION_1 = new RdtPosition(1,2,3); private static final String TEST_CLASS_NAME = "TestClassName"; private IndexUpdater updater; private ShamFile file; private MockSymbolIndex symbolIndex; public void setUp() { file = new ShamFile("TestFile.rb"); symbolIndex = new MockSymbolIndex(); updater = new IndexUpdater(symbolIndex); } public void testIrrelevantNodes() { Node node = new TrueNode(POSITION_1); updater.update(file, node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAddNotCalled(); } public void testSimple() { Colon2Node nameNode = new Colon2Node(POSITION_1, null, TEST_CLASS_NAME); Node node = new ClassNode(POSITION_1, nameNode, null, null); updater.update(file, node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAdded(new ClassSymbol(TEST_CLASS_NAME), file, POSITION_1); } public void testWithTree() throws Exception { Node node = parseCode("if x\nclass Foo\nend\n end\n"); updater.update(file,node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAdded(new ClassSymbol("Foo"), file, new RdtPosition(1, 2, 10, 18)); } public void testTreeWithScopedClass() throws Exception { Node node = parseCode("if x\nclass Foo::Bar\nend\n end\n"); updater.update(file,node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(1, 2, 10, 23)); } public void testTreeWithDeeplyScopedClass() throws Exception { Node node = parseCode("if x\nclass X::Foo::Bar\nend\n end\n"); updater.update(file,node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAdded(new ClassSymbol("X::Foo::Bar"), file, new RdtPosition(1, 2, 10, 26)); } public void testTreeWithNesting() throws Exception { Node node = parseCode("if x\nmodule Foo\nclass Bar\nend\n end\nend\n"); updater.update(file,node); symbolIndex.assertFlushed(file.getFullPath()); symbolIndex.assertAdded(new ClassSymbol("Foo::Bar"), file, new RdtPosition(2, 3, 21, 29)); } private Node parseCode(String code) throws CoreException { file.setContents(code); InputStreamReader reader = new InputStreamReader(file.getContents()); return new RubyParser().parse(file, reader); } private static class MockSymbolIndex extends SymbolIndex { private IFile fileArg; private ClassSymbol symbolArg; private ISourcePosition positionArg; private IPath flushedPathArg; public void flush(IPath path) { flushedPathArg = path; } public void assertFlushed(IPath expectedPath) { assertEquals("Flushed path", expectedPath, flushedPathArg); } public void assertAddNotCalled() { assertNull("Unexpected call to assertAddNotCalled()", fileArg); } public void assertAdded(ClassSymbol expectedSymbol, IFile expectedFile, ISourcePosition expectedPosition) { assertEquals("Symbol", expectedSymbol, symbolArg); assertEquals("File", expectedFile, fileArg); assertEquals("Position", expectedPosition, positionArg); } public void add(ClassSymbol symbol, IFile file, ISourcePosition position) { symbolArg = symbol; fileArg = file; positionArg = position; } } } Index: TC_RdtCompiler.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RdtCompiler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TC_RdtCompiler.java 9 Oct 2005 22:13:01 -0000 1.3 --- TC_RdtCompiler.java 13 Oct 2005 01:00:30 -0000 1.4 *************** *** 47,52 **** parser.assertParsed(file, FILE_CONTENTS); file.assertContentStreamClosed(); ! // DSC ! // indexUpdater.assertUpdated(file, rootNode); } --- 47,51 ---- parser.assertParsed(file, FILE_CONTENTS); file.assertContentStreamClosed(); ! indexUpdater.assertUpdated(file, rootNode); } --- IndexUpdater_UT.java DELETED --- |