You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
12
external/corert/tests/src/Simple/Add1/Add1.cmd
vendored
Normal file
12
external/corert/tests/src/Simple/Add1/Add1.cmd
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
setlocal
|
||||
"%1\%2"
|
||||
set ErrorCode=%ERRORLEVEL%
|
||||
IF "%ErrorCode%"=="100" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
23
external/corert/tests/src/Simple/Add1/Add1.cs
vendored
Normal file
23
external/corert/tests/src/Simple/Add1/Add1.cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
//
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
public class BringUpTest
|
||||
{
|
||||
const int Pass = 100;
|
||||
const int Fail = -1;
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.NoInlining)]
|
||||
public static int Add1(int x) { return x+1; }
|
||||
|
||||
public static int Main()
|
||||
{
|
||||
int y = Add1(1);
|
||||
if (y == 2) return Pass;
|
||||
else return Fail;
|
||||
}
|
||||
}
|
||||
7
external/corert/tests/src/Simple/Add1/Add1.csproj
vendored
Normal file
7
external/corert/tests/src/Simple/Add1/Add1.csproj
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" />
|
||||
</Project>
|
||||
9
external/corert/tests/src/Simple/Add1/Add1.sh
vendored
Executable file
9
external/corert/tests/src/Simple/Add1/Add1.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
$1/$2
|
||||
if [ $? == 100 ]; then
|
||||
echo pass
|
||||
exit 0
|
||||
else
|
||||
echo fail
|
||||
exit 1
|
||||
fi
|
||||
12
external/corert/tests/src/Simple/BasicThreading/BasicThreading.cmd
vendored
Normal file
12
external/corert/tests/src/Simple/BasicThreading/BasicThreading.cmd
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
setlocal
|
||||
"%1\%2"
|
||||
set ErrorCode=%ERRORLEVEL%
|
||||
IF "%ErrorCode%"=="100" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
139
external/corert/tests/src/Simple/BasicThreading/BasicThreading.cs
vendored
Normal file
139
external/corert/tests/src/Simple/BasicThreading/BasicThreading.cs
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
class Program
|
||||
{
|
||||
static int Main()
|
||||
{
|
||||
SimpleReadWriteThreadStaticTest.Run(42, "SimpleReadWriteThreadStatic");
|
||||
ThreadStaticsTestWithTasks.Run();
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleReadWriteThreadStaticTest
|
||||
{
|
||||
public static void Run(int intValue, string stringValue)
|
||||
{
|
||||
NonGenericReadWriteThreadStaticsTest(intValue, "NonGeneric" + stringValue);
|
||||
GenericReadWriteThreadStaticsTest(intValue + 1, "Generic" + stringValue);
|
||||
}
|
||||
|
||||
class NonGenericType
|
||||
{
|
||||
[ThreadStatic]
|
||||
public static int IntValue;
|
||||
|
||||
[ThreadStatic]
|
||||
public static string StringValue;
|
||||
}
|
||||
|
||||
class GenericType<T, V>
|
||||
{
|
||||
[ThreadStatic]
|
||||
public static T ValueT;
|
||||
|
||||
[ThreadStatic]
|
||||
public static V ValueV;
|
||||
}
|
||||
|
||||
static void NonGenericReadWriteThreadStaticsTest(int intValue, string stringValue)
|
||||
{
|
||||
NonGenericType.IntValue = intValue;
|
||||
NonGenericType.StringValue = stringValue;
|
||||
|
||||
if (NonGenericType.IntValue != intValue)
|
||||
{
|
||||
throw new Exception("SimpleReadWriteThreadStaticsTest: wrong integer value: " + NonGenericType.IntValue.ToString());
|
||||
}
|
||||
|
||||
if (NonGenericType.StringValue != stringValue)
|
||||
{
|
||||
throw new Exception("SimpleReadWriteThreadStaticsTest: wrong string value: " + NonGenericType.StringValue);
|
||||
}
|
||||
}
|
||||
|
||||
static void GenericReadWriteThreadStaticsTest(int intValue, string stringValue)
|
||||
{
|
||||
GenericType<int, string>.ValueT = intValue;
|
||||
GenericType<int, string>.ValueV = stringValue;
|
||||
|
||||
if (GenericType<int, string>.ValueT != intValue)
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest1a: wrong integer value: " + GenericType<int, string>.ValueT.ToString());
|
||||
}
|
||||
|
||||
if (GenericType<int, string>.ValueV != stringValue)
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest1b: wrong string value: " + GenericType<int, string>.ValueV);
|
||||
}
|
||||
|
||||
intValue++;
|
||||
GenericType<int, int>.ValueT = intValue;
|
||||
GenericType<int, int>.ValueV = intValue + 1;
|
||||
|
||||
if (GenericType<int, int>.ValueT != intValue)
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest2a: wrong integer value: " + GenericType<int, string>.ValueT.ToString());
|
||||
}
|
||||
|
||||
if (GenericType<int, int>.ValueV != (intValue + 1))
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest2b: wrong integer value: " + GenericType<int, string>.ValueV.ToString());
|
||||
}
|
||||
|
||||
GenericType<string, string>.ValueT = stringValue + "a";
|
||||
GenericType<string, string>.ValueV = stringValue + "b";
|
||||
|
||||
if (GenericType<string, string>.ValueT != (stringValue + "a"))
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest3a: wrong string value: " + GenericType<string, string>.ValueT);
|
||||
}
|
||||
|
||||
if (GenericType<string, string>.ValueV != (stringValue + "b"))
|
||||
{
|
||||
throw new Exception("GenericReadWriteThreadStaticsTest3b: wrong string value: " + GenericType<string, string>.ValueV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ThreadStaticsTestWithTasks
|
||||
{
|
||||
static object lockObject = new object();
|
||||
const int TotalTaskCount = 32;
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
Task[] tasks = new Task[TotalTaskCount];
|
||||
for (int i = 0; i < tasks.Length; ++i)
|
||||
{
|
||||
tasks[i] = Task.Factory.StartNew((param) =>
|
||||
{
|
||||
int index = (int)param;
|
||||
int intTestValue = index * 10;
|
||||
string stringTestValue = "ThreadStaticsTestWithTasks" + index;
|
||||
|
||||
// Try to run the on every other task
|
||||
if ((index % 2) == 0)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
SimpleReadWriteThreadStaticTest.Run(intTestValue, stringTestValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SimpleReadWriteThreadStaticTest.Run(intTestValue, stringTestValue);
|
||||
}
|
||||
}, i);
|
||||
}
|
||||
for (int i = 0; i < tasks.Length; ++i)
|
||||
{
|
||||
tasks[i].Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
7
external/corert/tests/src/Simple/BasicThreading/BasicThreading.csproj
vendored
Normal file
7
external/corert/tests/src/Simple/BasicThreading/BasicThreading.csproj
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" />
|
||||
</Project>
|
||||
9
external/corert/tests/src/Simple/BasicThreading/BasicThreading.sh
vendored
Normal file
9
external/corert/tests/src/Simple/BasicThreading/BasicThreading.sh
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
$1/$2
|
||||
if [ $? == 100 ]; then
|
||||
echo pass
|
||||
exit 0
|
||||
else
|
||||
echo fail
|
||||
exit 1
|
||||
fi
|
||||
1
external/corert/tests/src/Simple/BasicThreading/no_cpp
vendored
Normal file
1
external/corert/tests/src/Simple/BasicThreading/no_cpp
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Skip this test for cpp codegen mode
|
||||
1
external/corert/tests/src/Simple/BasicThreading/no_unix
vendored
Normal file
1
external/corert/tests/src/Simple/BasicThreading/no_unix
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Doesn't work on OSX.
|
||||
6
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.cmd
vendored
Normal file
6
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.cmd
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@echo off
|
||||
|
||||
:: Intentionally empty since we're just testing we can compile the framework
|
||||
:: assemblies to their own library obj files
|
||||
|
||||
exit /b 0
|
||||
9
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.csproj
vendored
Normal file
9
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.csproj
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project ToolsVersion="14.0" DefaultTargets="BuildAllFrameworkLibraries" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<NativeIntermediateOutputPath>$(MSBuildProjectDirectory)\obj\$(Configuration)\native\</NativeIntermediateOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="..\..\..\..\src\BuildIntegration\BuildFrameworkNativeObjects.proj" />
|
||||
|
||||
</Project>
|
||||
6
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.sh
vendored
Executable file
6
external/corert/tests/src/Simple/BuildMultiModuleLibraries/BuildMultiModuleLibraries.sh
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Intentionally empty since we're just testing we can compile the framework
|
||||
# assemblies to their own library obj files
|
||||
|
||||
exit 0
|
||||
1
external/corert/tests/src/Simple/BuildMultiModuleLibraries/no_cpp
vendored
Normal file
1
external/corert/tests/src/Simple/BuildMultiModuleLibraries/no_cpp
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Skip this test for cpp codegen mode
|
||||
12
external/corert/tests/src/Simple/Delegates/Delegates.cmd
vendored
Normal file
12
external/corert/tests/src/Simple/Delegates/Delegates.cmd
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
setlocal
|
||||
"%1\%2"
|
||||
set ErrorCode=%ERRORLEVEL%
|
||||
IF "%ErrorCode%"=="100" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
422
external/corert/tests/src/Simple/Delegates/Delegates.cs
vendored
Normal file
422
external/corert/tests/src/Simple/Delegates/Delegates.cs
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
|
||||
public class BringUpTests
|
||||
{
|
||||
const int Pass = 100;
|
||||
const int Fail = -1;
|
||||
|
||||
public static int Main()
|
||||
{
|
||||
int result = Pass;
|
||||
|
||||
if (!TestValueTypeDelegates())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
if (!TestVirtualDelegates())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
if (!TestInterfaceDelegates())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
if (!TestStaticOpenClosedDelegates())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
if (!TestMulticastDelegates())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
if (!TestDynamicInvoke())
|
||||
{
|
||||
Console.WriteLine("Failed");
|
||||
result = Fail;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool TestValueTypeDelegates()
|
||||
{
|
||||
Console.Write("Testing delegates to value types...");
|
||||
|
||||
{
|
||||
TestValueType t = new TestValueType { X = 123 };
|
||||
Func<string, string> d = t.GiveX;
|
||||
string result = d("MyPrefix");
|
||||
if (result != "MyPrefix123")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
object t = new TestValueType { X = 456 };
|
||||
Func<string> d = t.ToString;
|
||||
string result = d();
|
||||
if (result != "456")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Func<int, TestValueType> d = TestValueType.MakeValueType;
|
||||
TestValueType result = d(789);
|
||||
if (result.X != 789)
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TestVirtualDelegates()
|
||||
{
|
||||
Console.Write("Testing delegates to virtual methods...");
|
||||
|
||||
{
|
||||
Mid t = new Mid();
|
||||
if (t.GetBaseDo()() != "Base")
|
||||
return false;
|
||||
|
||||
if (t.GetDerivedDo()() != "Mid")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Mid t = new Derived();
|
||||
if (t.GetBaseDo()() != "Base")
|
||||
return false;
|
||||
|
||||
if (t.GetDerivedDo()() != "Derived")
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TestInterfaceDelegates()
|
||||
{
|
||||
Console.Write("Testing delegates to interface methods...");
|
||||
|
||||
{
|
||||
IFoo t = new ClassWithIFoo("Class");
|
||||
Func<int, string> d = t.DoFoo;
|
||||
if (d(987) != "Class987")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
IFoo t = new StructWithIFoo("Struct");
|
||||
Func<int, string> d = t.DoFoo;
|
||||
if (d(654) != "Struct654")
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TestStaticOpenClosedDelegates()
|
||||
{
|
||||
Console.Write("Testing static open and closed delegates...");
|
||||
|
||||
{
|
||||
Func<string, string, string> d = ExtensionClass.Combine;
|
||||
if (d("Hello", "World") != "HelloWorld")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Func<string, string> d = "Hi".Combine;
|
||||
if (d("There") != "HiThere")
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TestMulticastDelegates()
|
||||
{
|
||||
Console.Write("Testing multicast delegates...");
|
||||
|
||||
{
|
||||
ClassThatMutates t = new ClassThatMutates();
|
||||
|
||||
Action d = t.AddOne;
|
||||
d();
|
||||
|
||||
if (t.State != 1)
|
||||
return false;
|
||||
t.State = 0;
|
||||
|
||||
d += t.AddTwo;
|
||||
d();
|
||||
|
||||
if (t.State != 3)
|
||||
return false;
|
||||
t.State = 0;
|
||||
|
||||
d += t.AddOne;
|
||||
d();
|
||||
|
||||
if (t.State != 4)
|
||||
return false;
|
||||
}
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TestDynamicInvoke()
|
||||
{
|
||||
Console.Write("Testing dynamic invoke...");
|
||||
|
||||
{
|
||||
TestValueType t = new TestValueType { X = 123 };
|
||||
Func<string, string> d = t.GiveX;
|
||||
string result = (string)d.DynamicInvoke(new object[] { "MyPrefix" });
|
||||
if (result != "MyPrefix123")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Func<int, TestValueType> d = TestValueType.MakeValueType;
|
||||
TestValueType result = (TestValueType)d.DynamicInvoke(new object[] { 789 });
|
||||
if (result.X != 789)
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
IFoo t = new ClassWithIFoo("Class");
|
||||
Func<int, string> d = t.DoFoo;
|
||||
if ((string)d.DynamicInvoke(new object[] { 987 }) != "Class987")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
IFoo t = new StructWithIFoo("Struct");
|
||||
Func<int, string> d = t.DoFoo;
|
||||
if ((string)d.DynamicInvoke(new object[] { 654 }) != "Struct654")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Func<string, string, string> d = ExtensionClass.Combine;
|
||||
if ((string)d.DynamicInvoke(new object[] { "Hello", "World" }) != "HelloWorld")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Func<string, string> d = "Hi".Combine;
|
||||
if ((string)d.DynamicInvoke(new object[] { "There" }) != "HiThere")
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Mutate<int> d = ClassWithByRefs.Mutate;
|
||||
object[] args = new object[] { 8 };
|
||||
d.DynamicInvoke(args);
|
||||
if ((int)args[0] != 50)
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
Mutate<string> d = ClassWithByRefs.Mutate;
|
||||
object[] args = new object[] { "Hello" };
|
||||
d.DynamicInvoke(args);
|
||||
if ((string)args[0] != "HelloMutated")
|
||||
return false;
|
||||
}
|
||||
|
||||
unsafe
|
||||
{
|
||||
GetAndReturnPointerDelegate d = ClassWithPointers.GetAndReturnPointer;
|
||||
if ((IntPtr)d.DynamicInvoke(new object[] { (IntPtr)8 }) != (IntPtr)50)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if false
|
||||
// This is hitting an EH bug around throw/rethrow from a catch block (pass is not set properly)
|
||||
unsafe
|
||||
{
|
||||
PassPointerByRefDelegate d = ClassWithPointers.PassPointerByRef;
|
||||
var args = new object[] { (IntPtr)8 };
|
||||
|
||||
bool caught = false;
|
||||
try
|
||||
{
|
||||
d.DynamicInvoke(args);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
caught = true;
|
||||
}
|
||||
|
||||
if (!caught)
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
Console.WriteLine("OK");
|
||||
return true;
|
||||
}
|
||||
|
||||
struct TestValueType
|
||||
{
|
||||
public int X;
|
||||
|
||||
public string GiveX(string prefix)
|
||||
{
|
||||
return prefix + X.ToString();
|
||||
}
|
||||
|
||||
public static TestValueType MakeValueType(int value)
|
||||
{
|
||||
return new TestValueType { X = value };
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return X.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
class Base
|
||||
{
|
||||
public virtual string Do()
|
||||
{
|
||||
return "Base";
|
||||
}
|
||||
}
|
||||
|
||||
class Mid : Base
|
||||
{
|
||||
public override string Do()
|
||||
{
|
||||
return "Mid";
|
||||
}
|
||||
|
||||
public Func<string> GetBaseDo()
|
||||
{
|
||||
return base.Do;
|
||||
}
|
||||
|
||||
public Func<string> GetDerivedDo()
|
||||
{
|
||||
return Do;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived : Mid
|
||||
{
|
||||
public override string Do()
|
||||
{
|
||||
return "Derived";
|
||||
}
|
||||
}
|
||||
|
||||
interface IFoo
|
||||
{
|
||||
string DoFoo(int x);
|
||||
}
|
||||
|
||||
class ClassWithIFoo : IFoo
|
||||
{
|
||||
string _prefix;
|
||||
|
||||
public ClassWithIFoo(string prefix)
|
||||
{
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
public string DoFoo(int x)
|
||||
{
|
||||
return _prefix + x.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
struct StructWithIFoo : IFoo
|
||||
{
|
||||
string _prefix;
|
||||
|
||||
public StructWithIFoo(string prefix)
|
||||
{
|
||||
_prefix = prefix;
|
||||
}
|
||||
|
||||
public string DoFoo(int x)
|
||||
{
|
||||
return _prefix + x.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
class ClassThatMutates
|
||||
{
|
||||
public int State;
|
||||
|
||||
public void AddOne()
|
||||
{
|
||||
State++;
|
||||
}
|
||||
|
||||
public void AddTwo()
|
||||
{
|
||||
State += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class ExtensionClass
|
||||
{
|
||||
public static string Combine(this string s1, string s2)
|
||||
{
|
||||
return s1 + s2;
|
||||
}
|
||||
}
|
||||
|
||||
unsafe delegate IntPtr GetAndReturnPointerDelegate(void* ptr);
|
||||
unsafe delegate void PassPointerByRefDelegate(ref void* ptr);
|
||||
|
||||
unsafe static class ClassWithPointers
|
||||
{
|
||||
public static IntPtr GetAndReturnPointer(void* ptr)
|
||||
{
|
||||
return (IntPtr)((byte*)ptr + 42);
|
||||
}
|
||||
|
||||
public static void PassPointerByRef(ref void* ptr)
|
||||
{
|
||||
ptr = (byte*)ptr + 42;
|
||||
}
|
||||
}
|
||||
|
||||
delegate void Mutate<T>(ref T x);
|
||||
|
||||
class ClassWithByRefs
|
||||
{
|
||||
public static void Mutate(ref int x)
|
||||
{
|
||||
x += 42;
|
||||
}
|
||||
|
||||
public static void Mutate(ref string x)
|
||||
{
|
||||
x += "Mutated";
|
||||
}
|
||||
}
|
||||
7
external/corert/tests/src/Simple/Delegates/Delegates.csproj
vendored
Normal file
7
external/corert/tests/src/Simple/Delegates/Delegates.csproj
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Compile Include="*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), SimpleTest.targets))\SimpleTest.targets" />
|
||||
</Project>
|
||||
9
external/corert/tests/src/Simple/Delegates/Delegates.sh
vendored
Executable file
9
external/corert/tests/src/Simple/Delegates/Delegates.sh
vendored
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
$1/$2
|
||||
if [ $? == 100 ]; then
|
||||
echo pass
|
||||
exit 0
|
||||
else
|
||||
echo fail
|
||||
exit 1
|
||||
fi
|
||||
1
external/corert/tests/src/Simple/Delegates/no_cpp
vendored
Normal file
1
external/corert/tests/src/Simple/Delegates/no_cpp
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Skip this test for cpp codegen mode
|
||||
12
external/corert/tests/src/Simple/Exceptions/Exceptions.cmd
vendored
Normal file
12
external/corert/tests/src/Simple/Exceptions/Exceptions.cmd
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
setlocal
|
||||
"%1\%2"
|
||||
set ErrorCode=%ERRORLEVEL%
|
||||
IF "%ErrorCode%"=="100" (
|
||||
echo %~n0: pass
|
||||
EXIT /b 0
|
||||
) ELSE (
|
||||
echo %~n0: fail
|
||||
EXIT /b 1
|
||||
)
|
||||
endlocal
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user