[svn] r6879: vs-plugin/trunk: ConsoleTest/Program.cs Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj ...

IT svnadmin at nemerle.org
Mon Nov 13 06:11:15 CET 2006


Log:
Unit test for partial classes.

Author: IT
Date: Mon Nov 13 06:11:10 2006
New Revision: 6879

Added:
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-3.n
Modified:
   vs-plugin/trunk/ConsoleTest/Program.cs
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n
   vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs

Modified: vs-plugin/trunk/ConsoleTest/Program.cs
==============================================================================
--- vs-plugin/trunk/ConsoleTest/Program.cs	(original)
+++ vs-plugin/trunk/ConsoleTest/Program.cs	Mon Nov 13 06:11:10 2006
@@ -12,7 +12,8 @@
 			Test1 test = new Test1();
 			test.Init();
 
-			test.Check_regions();
+			test.Check_partial_region();
+			test.Check_region_location();
 			test.QuickTip_TupleProp();
 			test.QuickTip_TupleMethod();
 			test.Complete_enum();

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Compiler.Utils.csproj	Mon Nov 13 06:11:10 2006
@@ -74,10 +74,10 @@
     <Compile Include="Nemerle.Completion2\CodeModel\GlyphType.n" />
     <Compile Include="Const.n" />
     <Content Include="Nemerle.Completion2\Tests\Content\Class1-2.n">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
     <Content Include="Nemerle.Completion2\Tests\Content\Class1.n">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </Content>
     <Compile Include="Utils.n" />
     <Compile Include="Nemerle.Completion2\Tests\Tests.Init.n" />
@@ -152,6 +152,11 @@
     <Compile Include="Nemerle.Completion2\CodeModel\Formatter.n" />
     <Compile Include="Nemerle.Completion2\TextManagement\ISource.n" />
   </ItemGroup>
+  <ItemGroup>
+    <Content Include="Nemerle.Completion2\Tests\Content\Class1-3.n">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </Content>
+  </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/CodeModel/Project.n	Mon Nov 13 06:11:10 2006
@@ -230,7 +230,7 @@
             afterUsingLine = line;
         }
 
-        def addRegion(loc)
+        def addRegion(loc, isExpanded)
         {
           when (!loc.IsEmpty())
           {
@@ -240,7 +240,7 @@
               else
                 loc,
               null,
-              true);
+              isExpanded);
 
             checkLine(loc.Line);
           }
@@ -304,7 +304,8 @@
 
                     funs.Iter(f => addRegion(
                       Utils.Combine(f.header.Location, f.body.Location).
-                      TrimStart(f.header.Location, false)));
+                        TrimStart(f.header.Location, true),
+                        false));
 
                   | _ => ()
                   }
@@ -318,7 +319,7 @@
 
             // Get the method region location.
             //
-            addRegion(method.Location.TrimStart(method.fun_header.Location, false));
+            addRegion(method.Location.TrimStart(method.fun_header.ret_type_loc, false), true);
 
           | builder is TypeBuilder =>
 

Added: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-3.n
==============================================================================
--- (empty file)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Content/Class1-3.n	Mon Nov 13 06:11:10 2006
@@ -0,0 +1,8 @@
+partial class TestPartial
+{
+}
+
+partial class TestPartial
+{
+}
+

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.Init.n	Mon Nov 13 06:11:10 2006
@@ -35,18 +35,23 @@
         _engine.Sources.AddOrUpdate(source, File.ReadAllText(source));
       }
 
-      addSource(FilePath2);
+      addSource(FilePath3);
       Assert.AreEqual(1, _engine.Sources.Count, "Expected Failure.");
 
-      addSource(FilePath1);
+      addSource(FilePath2);
       Assert.AreEqual(2, _engine.Sources.Count, "Expected Failure.");
 
+      addSource(FilePath1);
+      Assert.AreEqual(3, _engine.Sources.Count, "Expected Failure.");
+
       _project = _engine.Project;
       Assert.IsNotNull(_project, "_project is null");
     }
 
     FilePath1 = @"Nemerle.Completion2\Tests\Content\Class1.n";
     FilePath2 = @"Nemerle.Completion2\Tests\Content\Class1-2.n";
+    FilePath3 = @"Nemerle.Completion2\Tests\Content\Class1-3.n";
+
     mutable _project : Project;
     mutable _engine : Engine;
 

Modified: vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n
==============================================================================
--- vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	(original)
+++ vs-plugin/trunk/Nemerle.Compiler.Utils/Nemerle.Completion2/Tests/Tests.n	Mon Nov 13 06:11:10 2006
@@ -14,13 +14,25 @@
   public partial class Test1
   {
     [Test]
-    public Check_regions() : void
+    public Check_partial_region() : void
     {
-      def file = FilePath1;
+      mutable nRegions = 0;
+
+      _project.Check(
+        FilePath3,
+        TestSourceTextManager(FilePath3),
+        fun(_, _, _) { nRegions++ },
+        fun(_)       { false      });
 
+      Assert.AreEqual(2, nRegions);
+    }
+
+    [Test]
+    public Check_region_location() : void
+    {
       _project.Check(
-        file,
-        TestSourceTextManager(file),
+        FilePath1,
+        TestSourceTextManager(FilePath1),
         fun(loc, _, _)
         {
           when (loc.Line == loc.EndLine)

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleScanner.cs	Mon Nov 13 06:11:10 2006
@@ -40,6 +40,8 @@
 
 				if (projectInfo == null)
 				{
+					// TODO: We need to create hidden project for files which are not included
+					// in any project.
 					engine = new Engine(new ProjectManager(_languageService), new TraceWriter());
 					engine.Init();
 				}



More information about the svn mailing list