[svn]
r7424: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests:
FindDefinition....
phantom
svnadmin at nemerle.org
Wed Feb 14 14:31:07 CET 2007
Log:
FindDefinition included into test suite.
Author: phantom
Date: Wed Feb 14 14:31:04 2007
New Revision: 7424
Added:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectOne.n
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectTwo.n
Modified:
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Heavy.Tests.nproj
vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectOne.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectOne.n Wed Feb 14 14:31:04 2007
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace Heavy.Tests
+{
+ [TestFixture]
+ public class FindDefinitionTestProjectOne : CommonTest
+ {
+ [SetUp]
+ public SetUp() : void
+ {
+ base.Initialize(@"..\..\..\Refactoring\TestProjectOne\TestProjectOne.nproj", "definition", "usage");
+ Runner.Test = TestRunner.FindDefinition(Runner);
+ Assert.IsTrue(base.EngineFunctional());
+ }
+
+ // a good spot to use macros, yeah? ;)
+ [Test] public Test001() : void { base.Run(1); }
+ [Test] public Test002() : void { base.Run(2); }
+ [Test] public Test003() : void { base.Run(3); }
+ [Test] public Test004() : void { base.Run(4); }
+ [Test] public Test005() : void { base.Run(5); }
+ [Test] public Test006() : void { base.Run(6); }
+ [Test] public Test007() : void { base.Run(7); }
+ [Test] public Test008() : void { base.Run(8); }
+ [Test] public Test009() : void { base.Run(9); }
+ [Test] public Test010() : void { base.Run(10); }
+ [Test] public Test011() : void { base.Run(11); }
+ [Test] public Test012() : void { base.Run(12); }
+ [Test] public Test013() : void { base.Run(13); }
+ [Test] public Test014() : void { base.Run(14); }
+ [Test] public Test015() : void { base.Run(15); }
+ [Test] public Test016() : void { base.Run(16); }
+ [Test] public Test017() : void { base.Run(17); }
+ [Test] public Test018() : void { base.Run(18); }
+ [Test] public Test019() : void { base.Run(19); }
+ [Test] public Test020() : void { base.Run(20); }
+ [Test] public Test021() : void { base.Run(21); }
+ [Test] public Test022() : void { base.Run(22); }
+ [Test] public Test023() : void { base.Run(23); }
+ [Test] public Test024() : void { base.Run(24); }
+ [Test] public Test025() : void { base.Run(25); }
+ [Test] public Test026() : void { base.Run(26); }
+ [Test] public Test027() : void { base.Run(27); }
+ [Test] public Test028() : void { base.Run(28); }
+ [Test] public Test029() : void { base.Run(29); }
+ [Test] public Test030() : void { base.Run(30); }
+ [Test] public Test031() : void { base.Run(31); }
+ [Test] public Test032() : void { base.Run(32); }
+ [Test] public Test033() : void { base.Run(33); }
+ [Test] public Test034() : void { base.Run(34); }
+ [Test] public Test035() : void { base.Run(35); }
+ [Test] public Test036() : void { base.Run(36); }
+ [Test] public Test037() : void { base.Run(37); }
+ [Test] public Test038() : void { base.Run(38); }
+ [Test] public Test039() : void { base.Run(39); }
+ [Test] public Test040() : void { base.Run(40); }
+ [Test] public Test041() : void { base.Run(41); }
+ [Test] public Test042() : void { base.Run(42); }
+ [Test] public Test043() : void { base.Run(43); }
+ [Test] public Test044() : void { base.Run(44); }
+ [Test] public Test045() : void { base.Run(45); }
+ [Test] public Test046() : void { base.Run(46); }
+ [Test] public Test047() : void { base.Run(47); }
+ [Test] public Test048() : void { base.Run(48); }
+ [Test] public Test049() : void { base.Run(49); }
+ [Test] public Test050() : void { base.Run(50); }
+ [Test] public Test051() : void { base.Run(51); }
+ [Test] public Test052() : void { base.Run(52); }
+ [Test] public Test053() : void { base.Run(53); }
+ [Test] public Test054() : void { base.Run(54); }
+ [Test] public Test055() : void { base.Run(55); }
+ [Test] public Test056() : void { base.Run(56); }
+ [Test] public Test057() : void { base.Run(57); }
+ [Test] public Test058() : void { base.Run(58); }
+ [Test] public Test059() : void { base.Run(59); }
+ [Test] public Test060() : void { base.Run(60); }
+ [Test] public Test061() : void { base.Run(61); }
+ [Test] public Test062() : void { base.Run(62); }
+ [Test] public Test063() : void { base.Run(63); }
+ [Test] public Test064() : void { base.Run(64); }
+ [Test] public Test065() : void { base.Run(65); }
+ [Test] public Test066() : void { base.Run(66); }
+ [Test] public Test067() : void { base.Run(67); }
+ [Test] public Test068() : void { base.Run(68); }
+ [Test] public Test069() : void { base.Run(69); }
+ [Test] public Test070() : void { base.Run(70); }
+ [Test] public Test071() : void { base.Run(71); }
+ [Test] public Test072() : void { base.Run(72); }
+ [Test] public Test073() : void { base.Run(73); }
+ [Test] public Test074() : void { base.Run(74); }
+ [Test] public Test075() : void { base.Run(75); }
+ [Test] public Test076() : void { base.Run(76); }
+ [Test] public Test077() : void { base.Run(77); }
+ [Test] public Test078() : void { base.Run(78); }
+ [Test] public Test079() : void { base.Run(79); }
+ [Test] public Test080() : void { base.Run(80); }
+ [Test] public Test081() : void { base.Run(81); }
+ [Test] public Test082() : void { base.Run(82); }
+ [Test] public Test083() : void { base.Run(83); }
+ [Test] public Test084() : void { base.Run(84); }
+ [Test] public Test085() : void { base.Run(85); }
+ [Test] public Test086() : void { base.Run(86); }
+ [Test] public Test087() : void { base.Run(87); }
+ [Test] public Test088() : void { base.Run(88); }
+ [Test] public Test089() : void { base.Run(89); }
+ [Test] public Test090() : void { base.Run(91); }
+ [Test] public Test091() : void { base.Run(99); }
+ [Test] public Test092() : void { base.Run(92); }
+ [Test] public Test093() : void { base.Run(93); }
+ [Test] public Test094() : void { base.Run(94); }
+ [Test] public Test095() : void { base.Run(95); }
+ [Test] public Test096() : void { base.Run(96); }
+ [Test] public Test097() : void { base.Run(97); }
+ [Test] public Test098() : void { base.Run(98); }
+ [Test] public Test099() : void { base.Run(99); }
+ [Test] public Test100() : void { base.Run(100); }
+
+ }
+}
\ No newline at end of file
Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectTwo.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/FindDefinition.TestProjectTwo.n Wed Feb 14 14:31:04 2007
@@ -0,0 +1,123 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace Heavy.Tests
+{
+ [TestFixture]
+ public class FindDefinitionTestProjectTwo : CommonTest
+ {
+ [SetUp]
+ public SetUp() : void
+ {
+ base.Initialize(@"..\..\..\Refactoring\TestProjectTwo\TestProjectTwo.nproj", "definition", "usage");
+ Runner.Test = TestRunner.FindDefinition(Runner);
+ Assert.IsTrue(base.EngineFunctional());
+ }
+
+ // a good spot to use macros, yeah? ;)
+ [Test] public Test001() : void { base.Run(1); }
+ [Test] public Test002() : void { base.Run(2); }
+ [Test] public Test003() : void { base.Run(3); }
+ [Test] public Test004() : void { base.Run(4); }
+ [Test] public Test005() : void { base.Run(5); }
+ [Test] public Test006() : void { base.Run(6); }
+ [Test] public Test007() : void { base.Run(7); }
+ [Test] public Test008() : void { base.Run(8); }
+ [Test] public Test009() : void { base.Run(9); }
+ [Test] public Test010() : void { base.Run(10); }
+ [Test] public Test011() : void { base.Run(11); }
+ [Test] public Test012() : void { base.Run(12); }
+ [Test] public Test013() : void { base.Run(13); }
+ [Test] public Test014() : void { base.Run(14); }
+ [Test] public Test015() : void { base.Run(15); }
+ [Test] public Test016() : void { base.Run(16); }
+ [Test] public Test017() : void { base.Run(17); }
+ [Test] public Test018() : void { base.Run(18); }
+ [Test] public Test019() : void { base.Run(19); }
+ [Test] public Test020() : void { base.Run(20); }
+ [Test] public Test021() : void { base.Run(21); }
+ [Test] public Test022() : void { base.Run(22); }
+ [Test] public Test023() : void { base.Run(23); }
+ [Test] public Test024() : void { base.Run(24); }
+ [Test] public Test025() : void { base.Run(25); }
+ [Test] public Test026() : void { base.Run(26); }
+ [Test] public Test027() : void { base.Run(27); }
+ [Test] public Test028() : void { base.Run(28); }
+ [Test] public Test029() : void { base.Run(29); }
+ [Test] public Test030() : void { base.Run(30); }
+ [Test] public Test031() : void { base.Run(31); }
+ [Test] public Test032() : void { base.Run(32); }
+ [Test] public Test033() : void { base.Run(33); }
+ [Test] public Test034() : void { base.Run(34); }
+ [Test] public Test035() : void { base.Run(35); }
+ [Test] public Test036() : void { base.Run(36); }
+ [Test] public Test037() : void { base.Run(37); }
+ [Test] public Test038() : void { base.Run(38); }
+ [Test] public Test039() : void { base.Run(39); }
+ [Test] public Test040() : void { base.Run(40); }
+ [Test] public Test041() : void { base.Run(41); }
+ [Test] public Test042() : void { base.Run(42); }
+ [Test] public Test043() : void { base.Run(43); }
+ [Test] public Test044() : void { base.Run(44); }
+ [Test] public Test045() : void { base.Run(45); }
+ [Test] public Test046() : void { base.Run(46); }
+ [Test] public Test047() : void { base.Run(47); }
+ [Test] public Test048() : void { base.Run(48); }
+ [Test] public Test049() : void { base.Run(49); }
+ [Test] public Test050() : void { base.Run(50); }
+ [Test] public Test051() : void { base.Run(51); }
+ [Test] public Test052() : void { base.Run(52); }
+ [Test] public Test053() : void { base.Run(53); }
+ [Test] public Test054() : void { base.Run(54); }
+ [Test] public Test055() : void { base.Run(55); }
+ [Test] public Test056() : void { base.Run(56); }
+ [Test] public Test057() : void { base.Run(57); }
+ [Test] public Test058() : void { base.Run(58); }
+ [Test] public Test059() : void { base.Run(59); }
+ [Test] public Test060() : void { base.Run(60); }
+ [Test] public Test061() : void { base.Run(61); }
+ [Test] public Test062() : void { base.Run(62); }
+ [Test] public Test063() : void { base.Run(63); }
+ [Test] public Test064() : void { base.Run(64); }
+ [Test] public Test065() : void { base.Run(65); }
+ [Test] public Test066() : void { base.Run(66); }
+ [Test] public Test067() : void { base.Run(67); }
+ [Test] public Test068() : void { base.Run(68); }
+ [Test] public Test069() : void { base.Run(69); }
+ [Test] public Test070() : void { base.Run(70); }
+ [Test] public Test071() : void { base.Run(71); }
+ [Test] public Test072() : void { base.Run(72); }
+ [Test] public Test073() : void { base.Run(73); }
+ [Test] public Test074() : void { base.Run(74); }
+ [Test] public Test075() : void { base.Run(75); }
+ [Test] public Test076() : void { base.Run(76); }
+ [Test] public Test077() : void { base.Run(77); }
+ [Test] public Test078() : void { base.Run(78); }
+ [Test] public Test079() : void { base.Run(79); }
+ [Test] public Test080() : void { base.Run(80); }
+ [Test] public Test081() : void { base.Run(81); }
+ [Test] public Test082() : void { base.Run(82); }
+ [Test] public Test083() : void { base.Run(83); }
+ [Test] public Test084() : void { base.Run(84); }
+ [Test] public Test085() : void { base.Run(85); }
+ [Test] public Test086() : void { base.Run(86); }
+ [Test] public Test087() : void { base.Run(87); }
+ [Test] public Test088() : void { base.Run(88); }
+ [Test] public Test089() : void { base.Run(89); }
+ [Test] public Test090() : void { base.Run(91); }
+ [Test] public Test091() : void { base.Run(99); }
+ [Test] public Test092() : void { base.Run(92); }
+ [Test] public Test093() : void { base.Run(93); }
+ [Test] public Test094() : void { base.Run(94); }
+ [Test] public Test095() : void { base.Run(95); }
+ [Test] public Test096() : void { base.Run(96); }
+ [Test] public Test097() : void { base.Run(97); }
+ [Test] public Test098() : void { base.Run(98); }
+ [Test] public Test099() : void { base.Run(99); }
+ [Test] public Test100() : void { base.Run(100); }
+
+ }
+}
\ No newline at end of file
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Heavy.Tests.nproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Heavy.Tests.nproj (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Heavy.Tests.nproj Wed Feb 14 14:31:04 2007
@@ -69,6 +69,12 @@
<Compile Include="CommonTest.n">
<SubType>Code</SubType>
</Compile>
+ <Compile Include="FindDefinition.TestProjectOne.n">
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="FindDefinition.TestProjectTwo.n">
+ <SubType>Code</SubType>
+ </Compile>
<Compile Include="FindUsages.TestProjectOne.n">
<SubType>Code</SubType>
</Compile>
Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n (original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Heavy.Tests/Runner.n Wed Feb 14 14:31:04 2007
@@ -29,9 +29,9 @@
public static RunTheTest() : void
{
- def suite = FindUsagesTestProjectTwo();
+ def suite = FindDefinitionTestProjectTwo();
suite.SetUp();
- suite.Test031();
+ suite.Test030();
}
public static Explode(this s : string, delimiter : string) : list[string]
@@ -274,57 +274,15 @@
public FindDefinition(line: string, testCase : int, declaration : Location, starter : string) : bool
{
- if (skipTestCases.Contains(testCase))
- true
- else
- {
- def name = starter.Substring(starter.IndexOf('}') + 1).Trim();
- def position = line.IndexOf(name);
- def location = Location(declaration.File, declaration.Line, position, declaration.Line, position + name.Length);
- WriteLine($"\nSearching for usages of '$name' (test case: $testCase, location: $location)... ");
- // TODO: find multiple declarations (partial classes)
- def shouldFindRing = MakeUsage(line, declaration, name, starter) ::
- ScanSources(checkPhrase, testCase).Map((line, _, location, _) => MakeUsage(line, location, name, checkPhrase));
- Write($"\n Should find $(shouldFindRing.Length) usages... ");
- def foundMultiple =
- shouldFindRing.Map(goto =>
- {
- def location = goto.Location;
- def shift = if (name.Length > 1) 1 else 0;
- TheEngine.Project.GetUsages(location.File, location.Line, location.Column + shift).ToList()
- });
- Assert.IsFalse(foundMultiple.IsEmpty);
- def found = foundMultiple.FoldLeft(foundMultiple.Head, (ring, ring') =>
- {
- def warning = "Find Usages should produce the same results, disregarding on which usage a user places a cursor";
- def coincide =
- try
- {
- FoldLeft2(ring, ring', true, (a, b, coincideToTheLeft) =>
- if (coincideToTheLeft) a.Location.CompareLines(b.Location) == 0 else false)
+ Find(false, line, testCase, declaration, starter)
}
- catch
- {
- | _ => false
- };
- when (stopAfterFirstFailedTest)
- Assert.IsTrue(coincide, warning);
- ring
- });
- Write($"found $(found.Length) usages, checking for correspondance... ");
- def success = FoundUsagesAreRight(testCase, shouldFindRing, found); // put breakpoint here to see what usages are actually found
- def message = if (success) "ok" else "incorrect!.. saving changes...";
- WriteLine(message);
- unless (success)
+
+ public FindUsages(line: string, testCase : int, declaration : Location, starter : string) : bool
{
- Assert.IsFalse(stopAfterFirstFailedTest);
- // TODO: save here instead of saving each time error happens
- }
- success
- }
+ Find(true, line, testCase, declaration, starter)
}
- public FindUsages(line: string, testCase : int, declaration : Location, starter : string) : bool
+ public Find(alsoUsages: bool, line: string, testCase : int, declaration : Location, starter : string) : bool
{
//when (skipTestCases.Contains(testCase)) // TODO: report about compiler bug here (no errors, just internal compiler error)
//Nemerle.Imperative.Return;
@@ -337,15 +295,19 @@
def location = Location(declaration.File, declaration.Line, position, declaration.Line, position + name.Length);
WriteLine($"\nSearching for usages of '$name' (test case: $testCase, location: $location)... ");
// TODO: find multiple declarations (partial classes)
- def shouldFindRing = MakeUsage(line, declaration, name, starter) ::
+ mutable shouldFindRing = MakeUsage(line, declaration, name, starter) ::
ScanSources(checkPhrase, testCase).Map((line, _, location, _) => MakeUsage(line, location, name, checkPhrase));
- Write($"\n Should find $(shouldFindRing.Length) usages... ");
+ unless (alsoUsages)
+ shouldFindRing = shouldFindRing.Filter(usage => usage.UsageType == UsageType.Definition);
+ def findings = if (alsoUsages) "definitions and usages" else "definitions";
+ Write($"\n Should find $(shouldFindRing.Length) $findings... ");
def foundMultiple =
shouldFindRing.Map(goto =>
{
def location = goto.Location;
def shift = if (name.Length > 1) 1 else 0;
- TheEngine.Project.GetUsages(location.File, location.Line, location.Column + shift).ToList()
+ def find = if (alsoUsages) TheEngine.Project.GetUsages else TheEngine.Project.GetDefinition;
+ find(location.File, location.Line, location.Column + shift).ToList()
});
Assert.IsFalse(foundMultiple.IsEmpty);
def found = foundMultiple.FoldLeft(foundMultiple.Head, (ring, ring') =>
More information about the svn
mailing list