|
From: <jas...@us...> - 2006-07-06 20:11:52
|
Revision: 1506 Author: jasonpmorrison Date: 2006-07-06 13:11:46 -0700 (Thu, 06 Jul 2006) ViewCVS: http://svn.sourceforge.net/rubyeclipse/?rev=1506&view=rev Log Message: ----------- Added tests for & implemented more occurence marking Modified Paths: -------------- branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/ReferenceMatchTest.java Modified: branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/ReferenceMatchTest.java =================================================================== --- branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/ReferenceMatchTest.java 2006-07-02 13:12:17 UTC (rev 1505) +++ branches/type_inferrence/trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/ti/ReferenceMatchTest.java 2006-07-06 20:11:46 UTC (rev 1506) @@ -84,5 +84,52 @@ int[][] offsets = {{20,26},{46,52},{60,66}}; assertReferencesEquals( source, 23, "my_var", offsets ); } + + /** + * Test referencing a global variable in various contexts. + * + */ + public void testGlobalVariableMatches() { + String source = "$foo = 'bar';class Klass;def foo;$foo = 5;end;def bar;puts $foo;end;end;puts $foo"; + int[][] offsets = {{0,4},{33,37},{59,63},{77,81}}; + assertReferencesEquals(source, 0, "$foo", offsets); + } +//todo: Method invocation tests get into territory where a more formal approach is needed (i.e. DDP) +// 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. + +// public void testMethodInvocationMatchInsideMethod() { +// String source = "class Klass;def foo;my_var = 5;y = my_var.to_s;puts y.to_s;end;end"; +// int[][] offsets = {{42,46},{54,58}}; +// assertReferencesEquals( source, 42, "to_s", offsets ); +// } +// +// public void testMethodInvocationMatchInKernelScope() { +// String source = "my_var = 5;y = my_var.to_s;puts y.to_s"; +// int[][] offsets = {{22,26},{34,38}}; +// assertReferencesEquals(source, 22, "to_s", offsets); +// } +// +// public void testStaticMethodInvocationMatchInKernelScope() { +// String source = "puts 5;puts 6;puts 7;"; +// int[][] offsets = {{0,4},{7,11},{14,18}}; +// assertReferencesEquals( source, 0, "puts", offsets ); +// } +// +// public void testMethodInvocationMatchAgainstMultipleInstancesOfSameType() { +// String source = "xvar = 5;yvar = 6;puts xvar.to_s;puts yvar.to_s"; +// int[][] offsets = {{28,32},{43,47}}; +// assertReferencesEquals(source, 28, "to_s", offsets); +// } + + /** + * Test matching against ConstNodes; specifically class references + */ + 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}}; + assertReferencesEquals( source, 5, "String", offsets ); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |