Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>2017-10-04 16:10:54 +0300
committerJan Kotas <jkotas@microsoft.com>2017-10-04 16:10:54 +0300
commit8b0f94b3f6db2cfe4e1a4ad7749e1220c9d48970 (patch)
tree36f7134842cb65fea34feead7ed1d484e49c8639 /src/ILCompiler.TypeSystem
parenta7710b58da65eb02349a0a1f9f529cc6090eecfb (diff)
Update IsByRefLike tests (#4671)
Rewrite the test data to IL and add an extra test for good measure. Fixes #4665.
Diffstat (limited to 'src/ILCompiler.TypeSystem')
-rw-r--r--src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs12
-rw-r--r--src/ILCompiler.TypeSystem/tests/ILTestAssembly/ILTestAssembly.ilproj1
-rw-r--r--src/ILCompiler.TypeSystem/tests/ILTestAssembly/InstanceFieldLayout.il22
-rw-r--r--src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs18
4 files changed, 32 insertions, 21 deletions
diff --git a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs
index 83ca0c423..64367e233 100644
--- a/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs
+++ b/src/ILCompiler.TypeSystem/tests/CoreTestAssembly/InstanceFieldLayout.cs
@@ -157,16 +157,4 @@ namespace IsByRefLike
{
int X;
}
-
-#if false // https://github.com/dotnet/corert/issues/4665
- public ref class InvalidClass
- {
- ByReference<int> ByRef;
- }
-
- public struct InvalidStruct
- {
- ByRefLikeStruct ByRefLike;
- }
-#endif
}
diff --git a/src/ILCompiler.TypeSystem/tests/ILTestAssembly/ILTestAssembly.ilproj b/src/ILCompiler.TypeSystem/tests/ILTestAssembly/ILTestAssembly.ilproj
index 8ef1a79ab..5d65099c4 100644
--- a/src/ILCompiler.TypeSystem/tests/ILTestAssembly/ILTestAssembly.ilproj
+++ b/src/ILCompiler.TypeSystem/tests/ILTestAssembly/ILTestAssembly.ilproj
@@ -12,6 +12,7 @@
<Compile Include="Main.il" />
<Compile Include="ILDisassembler.il" />
+ <Compile Include="InstanceFieldLayout.il" />
<Compile Include="StaticFieldLayout.il" />
<Compile Include="VirtualFunctionOverride.il" />
</ItemGroup>
diff --git a/src/ILCompiler.TypeSystem/tests/ILTestAssembly/InstanceFieldLayout.il b/src/ILCompiler.TypeSystem/tests/ILTestAssembly/InstanceFieldLayout.il
new file mode 100644
index 000000000..2a07e9e57
--- /dev/null
+++ b/src/ILCompiler.TypeSystem/tests/ILTestAssembly/InstanceFieldLayout.il
@@ -0,0 +1,22 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+.class public sequential ansi sealed beforefieldinit IsByRefLike.InvalidStruct
+ extends [CoreTestAssembly]System.ValueType
+{
+ .field private valuetype [CoreTestAssembly]System.ByReference`1<object> ByRef
+}
+
+.class public auto ansi beforefieldinit IsByRefLike.InvalidClass1
+ extends [CoreTestAssembly]System.Object
+{
+ .field private valuetype [CoreTestAssembly]System.ByReference`1<object> ByRef
+}
+
+.class public auto ansi beforefieldinit IsByRefLike.InvalidClass2
+ extends [CoreTestAssembly]System.Object
+{
+ .custom instance void [CoreTestAssembly]System.Runtime.CompilerServices.IsByRefLikeAttribute::.ctor() = ( 01 00 00 00 )
+ .field private valuetype [CoreTestAssembly]System.ByReference`1<object> ByRef
+}
diff --git a/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs b/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs
index f8ba12b60..d5945c0ce 100644
--- a/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs
+++ b/src/ILCompiler.TypeSystem/tests/InstanceFieldLayoutTests.cs
@@ -2,11 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
using Internal.TypeSystem;
using Xunit;
@@ -17,6 +12,7 @@ namespace TypeSystemTests
{
TestTypeSystemContext _context;
ModuleDesc _testModule;
+ ModuleDesc _ilTestModule;
public InstanceFieldLayoutTests()
{
@@ -25,6 +21,7 @@ namespace TypeSystemTests
_context.SetSystemModule(systemModule);
_testModule = systemModule;
+ _ilTestModule = _context.CreateModuleForSimpleName("ILTestAssembly");
}
[Fact]
@@ -324,20 +321,23 @@ namespace TypeSystemTests
}
}
-#if false // https://github.com/dotnet/corert/issues/4665
[Fact]
public void TestInvalidByRefLikeTypes()
{
{
- DefType type = _testModule.GetType("IsByRefLike", "InvalidClass");
+ DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidClass1");
+ Assert.Throws<TypeSystemException.TypeLoadException>(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields));
+ }
+
+ {
+ DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidClass2");
Assert.Throws<TypeSystemException.TypeLoadException>(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields));
}
{
- DefType type = _testModule.GetType("IsByRefLike", "InvalidStruct");
+ DefType type = _ilTestModule.GetType("IsByRefLike", "InvalidStruct");
Assert.Throws<TypeSystemException.TypeLoadException>(() => type.ComputeInstanceLayout(InstanceLayoutKind.TypeAndFields));
}
}
-#endif
}
}