Deduplicate JIT/Methodical/Boxing/xlang tests (#62753)
authorTomáš Rylek <trylek@microsoft.com>
Tue, 14 Dec 2021 21:40:58 +0000 (22:40 +0100)
committerGitHub <noreply@github.com>
Tue, 14 Dec 2021 21:40:58 +0000 (22:40 +0100)
This group comprises a C# & IL main module and a C# & IL library
and tries all four pairings between them. The C# version of the
main module used to be shared but that's problematic with test
merging as distinguishing the two tests with an identical
namespace, class name and entry point would be hard. As this is
the only occurrence of this pattern in the runtime test source
tree, I'm proposing to duplicate the C# main module source and
adjust it for the two scenarios (targeting C# vs. IL version
of the dependent library).

Thanks

Tomas

src/tests/JIT/Methodical/Boxing/xlang/sin_cs.cs [moved from src/tests/JIT/Methodical/Boxing/xlang/sin.cs with 98% similarity]
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_cs_d.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_cs_do.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_cs_r.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_cs_ro.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_il_d.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_il_do.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_il_r.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_cs_il_ro.csproj
src/tests/JIT/Methodical/Boxing/xlang/sin_il.cs [new file with mode: 0644]

@@ -1,7 +1,7 @@
 // Licensed to the .NET Foundation under one or more agreements.
 // The .NET Foundation licenses this file to you under the MIT license.
 
-namespace SinCalc
+namespace SinCalc_against_sinlib_cs
 {
     using System;
     using SinCalcLib;
index 30f38a1..6e8810c 100644 (file)
@@ -9,7 +9,7 @@
     <Optimize>False</Optimize>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_cs.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_cs.csproj" />
index ed1e0bc..2589543 100644 (file)
@@ -9,7 +9,7 @@
     <Optimize>True</Optimize>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_cs.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_cs.csproj" />
index 0387b3b..9117e65 100644 (file)
@@ -8,7 +8,7 @@
     <Optimize>False</Optimize>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_cs.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_cs.csproj" />
index 65d86b2..a4d45ed 100644 (file)
@@ -9,7 +9,7 @@
     <Optimize>True</Optimize>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_cs.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_cs.csproj" />
index f8a97e9..ba920d3 100644 (file)
@@ -10,7 +10,7 @@
     <NoWarn>$(NoWarn),8002</NoWarn>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_il.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_il.ilproj" />
index bd19037..205a697 100644 (file)
@@ -10,7 +10,7 @@
     <NoWarn>$(NoWarn),8002</NoWarn>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_il.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_il.ilproj" />
index ae6de69..0f558db 100644 (file)
@@ -10,7 +10,7 @@
     <NoWarn>$(NoWarn),8002</NoWarn>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_il.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_il.ilproj" />
index 2f787e9..e2b11c1 100644 (file)
@@ -10,7 +10,7 @@
     <NoWarn>$(NoWarn),8002</NoWarn>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="sin.cs" />
+    <Compile Include="sin_il.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="sinlib_il.ilproj" />
diff --git a/src/tests/JIT/Methodical/Boxing/xlang/sin_il.cs b/src/tests/JIT/Methodical/Boxing/xlang/sin_il.cs
new file mode 100644 (file)
index 0000000..e6d09d2
--- /dev/null
@@ -0,0 +1,64 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace SinCalc_against_sinlib_il
+{
+    using System;
+    using SinCalcLib;
+
+    class SinCalc
+    {
+        static int Main()
+        {
+            object i;
+            object Angle;
+            object Result1, Result2;
+            object[] testresults = new object[10];
+            testresults[0] = 0.000000000d;
+            testresults[1] = 0.309016994d;
+            testresults[2] = 0.587785252d;
+            testresults[3] = 0.809016994d;
+            testresults[4] = 0.951056516d;
+            testresults[5] = 1.000000000d;
+            testresults[6] = 0.951056516d;
+            testresults[7] = 0.809016994d;
+            testresults[8] = 0.587785252d;
+            testresults[9] = 0.309016994d;
+
+            object mistake = 1e-9d;
+            for (i = 0; (int)i < 10; i = (int)i + 1)
+            {
+                Angle = ((PiVal)SinCalcLib.PI).Value * ((int)i / 10.0);
+                Console.Write("Classlib Sin(");
+                Console.Write(Angle);
+                Console.Write(")=");
+                Console.WriteLine(Result1 = Math.Sin((double)Angle));
+                Console.Write("This Version(");
+                Console.Write(Angle);
+                Console.Write(")=");
+                Console.WriteLine(Result2 = (double)SinCalcLib.mySin(Angle));
+                Console.Write("Error is:");
+                Console.WriteLine((double)Result1 - (double)Result2);
+                Console.WriteLine();
+                if (Math.Abs((double)Result1 - (double)Result2) > (double)mistake) // reasonable considering double
+                {
+                    Console.WriteLine("ERROR, Versions too far apart!");
+                    return 1;
+                }
+                if (Math.Abs((double)testresults[(int)i] - (double)Result1) > (double)mistake) // reasonable considering double
+                {
+                    Console.WriteLine("ERROR, Classlib version isnt right!");
+                    return 1;
+                }
+                if (Math.Abs((double)testresults[(int)i] - (double)Result2) > (double)mistake) // reasonable considering double
+                {
+                    Console.WriteLine("ERROR, our version isnt right!");
+                    return 1;
+                }
+
+            }
+            Console.WriteLine("Yippie, all correct");
+            return 100;
+        }
+    }
+}