You've already forked linux-packaging-mono
Imported Upstream version 3.12.0
Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
@ -150,6 +150,16 @@ public class ConditionalParsing
|
||||
}
|
||||
}
|
||||
|
||||
void Test_18 (bool b, Action a)
|
||||
{
|
||||
var e = b ? () => { } : a;
|
||||
}
|
||||
|
||||
void Test_19 (int[,] table)
|
||||
{
|
||||
var x = 1 > 0 ? table[5, 1] : 0;
|
||||
}
|
||||
|
||||
static void Helper<T> (T arg)
|
||||
{
|
||||
}
|
||||
|
42
mcs/tests/gtest-623-lib.il
Normal file
42
mcs/tests/gtest-623-lib.il
Normal file
@ -0,0 +1,42 @@
|
||||
.assembly extern mscorlib
|
||||
{
|
||||
}
|
||||
|
||||
.assembly 'gtest-623-lib'
|
||||
{
|
||||
}
|
||||
|
||||
.module 'gtest-623-lib.dll'
|
||||
|
||||
.class public sequential ansi sealed beforefieldinit S
|
||||
extends [mscorlib]System.ValueType
|
||||
implements I {
|
||||
|
||||
.field public int32 Field
|
||||
|
||||
.method public hidebysig specialname rtspecialname
|
||||
instance default void '.ctor' () cil managed
|
||||
{
|
||||
ldarg.0
|
||||
ldc.i4.3
|
||||
stfld int32 S::Field
|
||||
ret
|
||||
}
|
||||
|
||||
.method public final virtual hidebysig newslot
|
||||
instance default int32 GetValue () cil managed
|
||||
{
|
||||
ldarg.0
|
||||
ldfld int32 S::Field
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
||||
.class interface public auto ansi abstract I
|
||||
{
|
||||
|
||||
.method public virtual hidebysig newslot abstract
|
||||
instance default int32 GetValue () cil managed
|
||||
{
|
||||
}
|
||||
}
|
24
mcs/tests/gtest-623.cs
Normal file
24
mcs/tests/gtest-623.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Compiler options: -r:gtest-623-lib.dll
|
||||
|
||||
using System;
|
||||
|
||||
public class C
|
||||
{
|
||||
static bool Test<T> () where T : struct, I
|
||||
{
|
||||
var t = new T ();
|
||||
if (t.GetValue () != 3)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int Main ()
|
||||
{
|
||||
if (!Test<S> ())
|
||||
return 1;
|
||||
|
||||
Console.WriteLine ("ok");
|
||||
return 0;
|
||||
}
|
||||
}
|
36
mcs/tests/gtest-624.cs
Normal file
36
mcs/tests/gtest-624.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
|
||||
class Model
|
||||
{
|
||||
public int Value;
|
||||
}
|
||||
|
||||
class C1<T1>
|
||||
{
|
||||
public void Add (Func<T1, int> t)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C2<TModel>
|
||||
{
|
||||
public abstract void ApplyImpl<U> (C1<U> c1) where U : TModel;
|
||||
}
|
||||
|
||||
class C3 : C2<Model>
|
||||
{
|
||||
public override void ApplyImpl<Foo> (C1<Foo> c1)
|
||||
{
|
||||
c1.Add (t => t.Value);
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main ()
|
||||
{
|
||||
var v1 = new C1<Model> ();
|
||||
var c3 = new C3 ();
|
||||
c3.ApplyImpl (v1);
|
||||
}
|
||||
}
|
21
mcs/tests/gtest-625.cs
Normal file
21
mcs/tests/gtest-625.cs
Normal file
@ -0,0 +1,21 @@
|
||||
struct S
|
||||
{
|
||||
public static bool operator true (S? S)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool operator false (S? S)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class P
|
||||
{
|
||||
static void Main ()
|
||||
{
|
||||
if (new S? ()) {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
// Compiler options: -langversion:experimental
|
||||
using System;
|
||||
|
||||
struct S
|
||||
|
17
mcs/tests/gtest-autoproperty-10.cs
Normal file
17
mcs/tests/gtest-autoproperty-10.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// Compiler options: -langversion:experimental
|
||||
struct S
|
||||
{
|
||||
public decimal P { get; } = -3;
|
||||
}
|
||||
|
||||
class X
|
||||
{
|
||||
public static int Main ()
|
||||
{
|
||||
var s = new S ();
|
||||
if (s.P != -3)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -210,6 +210,14 @@ struct MyTypeImplicitOnly
|
||||
}
|
||||
}
|
||||
|
||||
struct StructWithUserConstructor
|
||||
{
|
||||
public StructWithUserConstructor ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class MemberAccessData
|
||||
{
|
||||
public bool BoolValue;
|
||||
@ -2190,6 +2198,17 @@ class Tester
|
||||
Assert<MyEnum> (0, e.Compile ().Invoke ());
|
||||
}
|
||||
|
||||
void NewTest_8 ()
|
||||
{
|
||||
Expression<Func<DateTime>> e = () => new DateTime ();
|
||||
AssertNodeType (e, ExpressionType.New);
|
||||
Assert (null, ((NewExpression)e.Body).Constructor, "default ctor");
|
||||
|
||||
Expression<Func<StructWithUserConstructor>> e2 = () => new StructWithUserConstructor ();
|
||||
AssertNodeType (e2, ExpressionType.New);
|
||||
Assert ("Void .ctor()", ((NewExpression)e2.Body).Constructor.ToString (), "user ctor");
|
||||
}
|
||||
|
||||
void NotTest ()
|
||||
{
|
||||
Expression<Func<bool, bool>> e = (bool a) => !a;
|
||||
|
26
mcs/tests/gtest-lambda-36.cs
Normal file
26
mcs/tests/gtest-lambda-36.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
|
||||
class D<T>
|
||||
{
|
||||
public void S<U, V> (Func<U> ftu, Func<T, U, V> ftuv)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Test
|
||||
{
|
||||
static D<V> Factory<V> (V v)
|
||||
{
|
||||
return new D<V> ();
|
||||
}
|
||||
|
||||
static void Main ()
|
||||
{
|
||||
var danon = Factory (new { q = 5 });
|
||||
|
||||
danon.S (
|
||||
() => "x",
|
||||
(l, str) => new { str }
|
||||
);
|
||||
}
|
||||
}
|
18
mcs/tests/gtest-named-06.cs
Normal file
18
mcs/tests/gtest-named-06.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// parser test
|
||||
|
||||
class X
|
||||
{
|
||||
public static int T1 (int seconds)
|
||||
{
|
||||
return T1_Foo (value: seconds * 1000);
|
||||
}
|
||||
|
||||
public static int T1_Foo (int value = 0)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
}
|
||||
}
|
14
mcs/tests/gtest-optional-34.cs
Normal file
14
mcs/tests/gtest-optional-34.cs
Normal file
@ -0,0 +1,14 @@
|
||||
public struct S
|
||||
{
|
||||
public S (double left = 0, double top = 0)
|
||||
: this ()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class X
|
||||
{
|
||||
public static void Main ()
|
||||
{
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
// Compiler options: -unsafe
|
||||
//
|
||||
// Tests the valid value types for volatile fields.
|
||||
//
|
||||
@ -11,6 +12,9 @@ enum XX {
|
||||
A
|
||||
}
|
||||
|
||||
struct S {
|
||||
}
|
||||
|
||||
class X {
|
||||
volatile byte a;
|
||||
volatile sbyte b;
|
||||
@ -26,6 +30,9 @@ class X {
|
||||
volatile XX dd;
|
||||
volatile IntPtr ip;
|
||||
volatile UIntPtr uip;
|
||||
unsafe volatile ushort* uc;
|
||||
unsafe volatile XX* udd;
|
||||
unsafe volatile S* us;
|
||||
|
||||
public static void Main () {}
|
||||
}
|
||||
|
@ -1,79 +0,0 @@
|
||||
// Compiler options: -unsafe
|
||||
|
||||
using System;
|
||||
|
||||
class BoolArrayWithByteValues
|
||||
{
|
||||
|
||||
static int Foo (ref bool b)
|
||||
{
|
||||
bool b2 = true;
|
||||
bool r;
|
||||
r = b == true;
|
||||
if (!r)
|
||||
return 10;
|
||||
|
||||
r = b == b2;
|
||||
if (!r)
|
||||
return 11;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsafe bool Ptr ()
|
||||
{
|
||||
bool rv;
|
||||
|
||||
var arr = new byte [256];
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
arr [i] = (byte) i;
|
||||
fixed (byte* bptr = arr) {
|
||||
rv = true;
|
||||
for (int i = 0; i < arr.Length; i++) {
|
||||
bool* boptr = (bool*)(bptr + i);
|
||||
if (arr[i] > 0 && !*boptr)
|
||||
rv = false;
|
||||
System.Console.WriteLine ("#{0} = {1}", i, *boptr);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int Main()
|
||||
{
|
||||
var a = new bool[1];
|
||||
Buffer.SetByte (a, 0, 5);
|
||||
|
||||
var b = true;
|
||||
bool r;
|
||||
r = a [0];
|
||||
if (!r)
|
||||
return 1;
|
||||
|
||||
r = a [0] == true;
|
||||
if (!r)
|
||||
return 2;
|
||||
|
||||
r = a [0] == b;
|
||||
if (!r)
|
||||
return 3;
|
||||
|
||||
r = a [0] != false;
|
||||
if (!r)
|
||||
return 4;
|
||||
|
||||
r = a [0] != b;
|
||||
if (r)
|
||||
return 5;
|
||||
|
||||
var res = Foo (ref a [0]);
|
||||
if (res != 0)
|
||||
return res;
|
||||
|
||||
if (!Ptr ())
|
||||
return 6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -6,17 +6,36 @@ struct S
|
||||
|
||||
class C
|
||||
{
|
||||
public static int ConversionCalled;
|
||||
|
||||
public static implicit operator S (C c)
|
||||
{
|
||||
++ConversionCalled;
|
||||
return new S ();
|
||||
}
|
||||
}
|
||||
|
||||
class Program
|
||||
{
|
||||
static void Main ()
|
||||
static C field;
|
||||
|
||||
static int Main ()
|
||||
{
|
||||
C c = new C ();
|
||||
var x = c ?? new S ();
|
||||
|
||||
if (C.ConversionCalled != 1)
|
||||
return 1;
|
||||
|
||||
c = null;
|
||||
x = c ?? new S ();
|
||||
if (C.ConversionCalled != 1)
|
||||
return 2;
|
||||
|
||||
x = field ?? new S ();
|
||||
if (C.ConversionCalled != 1)
|
||||
return 3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
76
mcs/tests/test-906.cs
Normal file
76
mcs/tests/test-906.cs
Normal file
@ -0,0 +1,76 @@
|
||||
// Compiler options: -langversion:experimental
|
||||
using System;
|
||||
|
||||
struct S1
|
||||
{
|
||||
public readonly int Value;
|
||||
|
||||
public S1 ()
|
||||
{
|
||||
Value = 17;
|
||||
}
|
||||
}
|
||||
|
||||
struct S2
|
||||
{
|
||||
public readonly int Value = 23;
|
||||
}
|
||||
|
||||
struct S3
|
||||
{
|
||||
public readonly int Value = 11;
|
||||
|
||||
public S3 ()
|
||||
{
|
||||
Value = 5;
|
||||
}
|
||||
}
|
||||
|
||||
struct S4
|
||||
{
|
||||
public readonly int Value = 11;
|
||||
|
||||
public S4 (int v)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
struct S5
|
||||
{
|
||||
public readonly int Value = 7;
|
||||
|
||||
public S5 (int v)
|
||||
: this ()
|
||||
{
|
||||
this.Value += v;
|
||||
}
|
||||
}
|
||||
|
||||
class C
|
||||
{
|
||||
static int Main ()
|
||||
{
|
||||
var s = new S1 ();
|
||||
if (s.Value != 17)
|
||||
return 1;
|
||||
|
||||
var s2 = new S2 ();
|
||||
if (s2.Value != 23)
|
||||
return 2;
|
||||
|
||||
var s3 = new S3 ();
|
||||
if (s3.Value != 5)
|
||||
return 3;
|
||||
|
||||
var s4 = new S4 (5);
|
||||
if (s4.Value != 11)
|
||||
return 4;
|
||||
|
||||
var s5 = new S5 (2);
|
||||
if (s5.Value != 9)
|
||||
return 5;
|
||||
|
||||
Console.WriteLine ("ok");
|
||||
return 0;
|
||||
}
|
||||
}
|
22
mcs/tests/test-907.cs
Normal file
22
mcs/tests/test-907.cs
Normal file
@ -0,0 +1,22 @@
|
||||
public enum Foo { One, Two };
|
||||
|
||||
class MainClass
|
||||
{
|
||||
public static int Main ()
|
||||
{
|
||||
const Foo foo = Foo.Two;
|
||||
int obj;
|
||||
|
||||
switch (foo) {
|
||||
case Foo.One:
|
||||
case Foo.Two:
|
||||
obj = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
if (obj != 2)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
10
mcs/tests/test-910.cs
Normal file
10
mcs/tests/test-910.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System.Security;
|
||||
using System.Security.Permissions;
|
||||
|
||||
[HostProtection]
|
||||
class X
|
||||
{
|
||||
public static void Main ()
|
||||
{
|
||||
}
|
||||
}
|
30
mcs/tests/test-anon-172.cs
Normal file
30
mcs/tests/test-anon-172.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Reflection.Emit;
|
||||
using System.Reflection;
|
||||
|
||||
class MainClass
|
||||
{
|
||||
public static int Main ()
|
||||
{
|
||||
var dynMethod = new DynamicMethod ("Metoda", MethodAttributes.Public | MethodAttributes.Static, CallingConventions.Standard,
|
||||
null, Type.EmptyTypes, typeof (MainClass), true);
|
||||
var generator = dynMethod.GetILGenerator ();
|
||||
|
||||
generator.Emit (OpCodes.Ldc_I4_7);
|
||||
GenerateCodeCall (generator, (int a) => {
|
||||
Console.WriteLine (a);
|
||||
});
|
||||
|
||||
generator.Emit (OpCodes.Ret);
|
||||
|
||||
var deleg = (Action)dynMethod.CreateDelegate (typeof (Action));
|
||||
deleg ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void GenerateCodeCall<T1> (ILGenerator generator, Action<T1> a)
|
||||
{
|
||||
generator.Emit (OpCodes.Call, a.Method);
|
||||
}
|
||||
}
|
||||
|
42
mcs/tests/test-async-76.cs
Normal file
42
mcs/tests/test-async-76.cs
Normal file
@ -0,0 +1,42 @@
|
||||
// Compiler options: -r:../class/lib/net_4_5/Mono.Cecil.dll
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Mono.Cecil;
|
||||
|
||||
namespace N
|
||||
{
|
||||
class C
|
||||
{
|
||||
}
|
||||
|
||||
interface I<T>
|
||||
{
|
||||
void Foo (T t);
|
||||
}
|
||||
|
||||
class X : I<C>
|
||||
{
|
||||
async void I<C>.Foo (C c)
|
||||
{
|
||||
await Task.Delay (1);
|
||||
}
|
||||
|
||||
public static void Main ()
|
||||
{
|
||||
var assembly = AssemblyDefinition.ReadAssembly (typeof (X).Assembly.Location);
|
||||
foreach (var t in assembly.MainModule.Types) {
|
||||
PrintType (t, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void PrintType (TypeDefinition td, int indent)
|
||||
{
|
||||
if (td.IsNested && !string.IsNullOrEmpty (td.Namespace))
|
||||
throw new ApplicationException ("BROKEN NESTED TYPE:");
|
||||
Console.WriteLine ("{2} Namespace: {0} Name: {1}", td.Namespace, td.Name, new string (' ', indent * 4));
|
||||
foreach (var tn in td.NestedTypes)
|
||||
PrintType (tn, indent + 1);
|
||||
}
|
||||
}
|
||||
}
|
65
mcs/tests/test-decl-expr-01.cs
Normal file
65
mcs/tests/test-decl-expr-01.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
|
||||
class DeclarationExpression
|
||||
{
|
||||
public static int Main ()
|
||||
{
|
||||
Out (out int o);
|
||||
if (o != 3)
|
||||
return 1;
|
||||
|
||||
if (Out (out int o1)) {
|
||||
if (o1 != 3)
|
||||
return 2;
|
||||
}
|
||||
|
||||
Out (out int o2 = 2);
|
||||
if (o2 != 3)
|
||||
return 3;
|
||||
|
||||
Out (out var o3);
|
||||
if (o3 != 3)
|
||||
return 4;
|
||||
|
||||
Ref (ref int r = 2);
|
||||
if (r != 7)
|
||||
return 5;
|
||||
|
||||
Ref (ref ((var r2 = 3)));
|
||||
if (r2 != 8)
|
||||
return 6;
|
||||
|
||||
// Out2 (str: "b", v: out var o5);
|
||||
// if (o5 != 9)
|
||||
// return 7;
|
||||
|
||||
Out3 (out var o6 = 9m);
|
||||
if (o6.GetType () != typeof (decimal))
|
||||
return 8;
|
||||
|
||||
Console.WriteLine ("ok");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool Out (out int value)
|
||||
{
|
||||
value = 3;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Out2 (out int v, string str)
|
||||
{
|
||||
v = 9;
|
||||
return true;
|
||||
}
|
||||
|
||||
static void Out3<T> (out T t)
|
||||
{
|
||||
t = default (T);
|
||||
}
|
||||
|
||||
static void Ref (ref int arg)
|
||||
{
|
||||
arg += 5;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user