From: Charles Stoner Date: Mon, 23 Sep 2019 16:24:45 +0000 (-0700) Subject: Additional enum tests for System.Linq.Expressions.Interpreter.CallInstruction (dotnet... X-Git-Tag: submit/tizen/20210909.063632~11031^2~424 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2edea43ded18e1bb349e90a4232eaea7fa6ba6f2;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Additional enum tests for System.Linq.Expressions.Interpreter.CallInstruction (dotnet/corefx#41218) Commit migrated from https://github.com/dotnet/corefx/commit/f9919e1ce5ca407f55d078af003af642c1b44d92 --- diff --git a/src/libraries/System.Linq.Expressions/tests/Call/CallTests.cs b/src/libraries/System.Linq.Expressions/tests/Call/CallTests.cs index b67b1d8..bae12c9 100644 --- a/src/libraries/System.Linq.Expressions/tests/Call/CallTests.cs +++ b/src/libraries/System.Linq.Expressions/tests/Call/CallTests.cs @@ -665,37 +665,62 @@ namespace System.Linq.Expressions.Tests } } - [Fact] - public static void EnumReturnType0() + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void EnumReturnType0(bool useInterpreter) { Expression> expr = () => new[] { ToDayOfWeek0() }; - - Assert.Equal(DayOfWeek.Monday, expr.Compile(false)()[0]); - Assert.Equal(DayOfWeek.Monday, expr.Compile(true)()[0]); + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0]); } - [Fact] - public static void EnumReturnType1() + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void EnumReturnType1(bool useInterpreter) { Expression> expr = () => new[] { ToDayOfWeek1(1) }; - - Assert.Equal(DayOfWeek.Monday, expr.Compile(false)()[0]); - Assert.Equal(DayOfWeek.Monday, expr.Compile(true)()[0]); + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0]); } - [Fact] - public static void EnumReturnType2() + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void EnumReturnType2(bool useInterpreter) { Expression> expr = () => new[] { ToDayOfWeek2(0, 1) }; - - Assert.Equal(DayOfWeek.Monday, expr.Compile(false)()[0]); - Assert.Equal(DayOfWeek.Monday, expr.Compile(true)()[0]); + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0]); } private static DayOfWeek ToDayOfWeek0() => DayOfWeek.Monday; private static DayOfWeek ToDayOfWeek1(int i) => (DayOfWeek)i; private static DayOfWeek ToDayOfWeek2(int i, int j) => (DayOfWeek)(i + j); + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void NullableEnumReturnType0(bool useInterpreter) + { + Expression> expr = () => new[] { ToDayOfWeekOpt0() }; + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0].Value); + } + + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void NullableEnumReturnType1(bool useInterpreter) + { + Expression> expr = () => new[] { ToDayOfWeekOpt1(1) }; + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0].Value); + } + + [Theory] + [ClassData(typeof(CompilationTypes))] + public static void NullableEnumReturnType2(bool useInterpreter) + { + Expression> expr = () => new[] { ToDayOfWeekOpt2(0, 1) }; + Assert.Equal(DayOfWeek.Monday, expr.Compile(useInterpreter)()[0].Value); + } + + private static DayOfWeek? ToDayOfWeekOpt0() => DayOfWeek.Monday; + private static DayOfWeek? ToDayOfWeekOpt1(int i) => (DayOfWeek)i; + private static DayOfWeek? ToDayOfWeekOpt2(int i, int j) => (DayOfWeek)(i + j); + public class GenericClass { public static void NonGenericMethod() { }