Revision: 1527 Author: jasonpmorrison Date: 2006-07-19 21:16:47 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/rubyeclipse/?rev=1527&view=rev Log Message: ----------- - Find and match ArgumentNode - Find and match Symbol Node (HACK: JRuby positioning issue with symbols) Modified Paths: -------------- branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/MarkOccurrencesTest.java Modified: branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/MarkOccurrencesTest.java =================================================================== --- branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/MarkOccurrencesTest.java 2006-07-20 04:16:16 UTC (rev 1526) +++ branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/MarkOccurrencesTest.java 2006-07-20 04:16:47 UTC (rev 1527) @@ -14,7 +14,7 @@ * Tests related to matching occurrences. * * @author Jason Morrison - * + *` */ public class MarkOccurrencesTest extends TestCase { @@ -48,6 +48,15 @@ } /** + * Match args to locals + */ + public void testArgMatches() { + String source = "class Klass;def foo(my_arg);puts my_arg*2;end;end"; + int[][] offsets = {{20,26},{33,39}}; + assertOccurrencesEqual( source, 22, "my_arg", offsets ); + } + + /** * Match locals within Kernel::DefnNode */ public void testLocalVariablesInKernelDefnScope() { @@ -102,7 +111,18 @@ assertOccurrencesEqual(source, 0, "$foo", offsets); } -//todo: Method invocation tests get into territory where a more formal approach is needed (i.e. DDP) + /** + * Test referencing a symbol in various contexts. + * + */ + public void testSymbolMatches() { + String source = "a_var = :foo;class Klass;def foo;l = :foo;end;def bar;puts :foo;end;end;puts :foo.to_s"; +// String source = "$foo = 'bar';class Klass;def foo;$foo = 5;end;def bar;puts $foo;end;end;puts $foo"; + int[][] offsets = {{8,12},{37,41},{59,63},{77,81}}; + assertOccurrencesEqual(source, 9, ":foo", offsets); + } + +//TODO: Method invocation tests need to know the type of their receiver. // Sub-goals are becoming necessary, i.e. for determining arg-type to match selectors by more // than name, and determining receiver-type to match selectors applied to other same-typed receivers. @@ -136,7 +156,19 @@ public void testTypeMatches() { String source = "f = String.new;class Klass;def foo;c = String;end;end;class MyString < String;end"; int[][] offsets = {{4,10},{39,45},{71,77}}; - assertOccurrencesEqual( source, 5, "String", offsets ); + assertOccurrencesEqual( source, 4, "String", offsets ); } +// public void testConstNodeToClassDeclNode() { +// String source = "class Klass;def foo;5;end;end;k = Klass.new"; +// int[][] offsets = {{6,11},{34,39}}; +// assertOccurrencesEqual( source, 6, "Klass", offsets ); +// } + +// public void testBlockArguments() { +// String source = "[1,2,3].each { |number| puts number }"; +// int[][] offsets = {{16,22},{29,35}}; +// assertOccurrencesEqual(source, 16, "number", offsets); +// } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |