/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionCompiler/constant_BackSl_test0.cs
C# | 17067 lines | 13916 code | 2661 blank | 490 comment | 1717 complexity | 22396c4bece7d3cee26efab926f9d6e0 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
Large files files are truncated, but you can click here to view the full file
- #if !CLR2
- using System.Linq.Expressions;
- #else
- using Microsoft.Scripting.Ast;
- using Microsoft.Scripting.Utils;
- #endif
-
- using System.Reflection;
- using System;
- namespace ExpressionCompiler {
-
-
- //-------- Scenario 1706
- namespace Scenario1706{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check0__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check0__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check0();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check0() {
- foreach (byte val in new byte[] { 0, 1, byte.MaxValue }) {
- if (!check0(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check0(byte val) {
- Expression<Func<byte>> e =
- Expression.Lambda<Func<byte>>(
- Expression.Constant(val, typeof(byte)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<byte> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1707
- namespace Scenario1707{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check1__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check1__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check1();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check1() {
- foreach (ushort val in new ushort[] { 0, 1, ushort.MaxValue }) {
- if (!check1(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check1(ushort val) {
- Expression<Func<ushort>> e =
- Expression.Lambda<Func<ushort>>(
- Expression.Constant(val, typeof(ushort)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<ushort> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1708
- namespace Scenario1708{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check2__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check2__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check2();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check2() {
- foreach (uint val in new uint[] { 0, 1, uint.MaxValue }) {
- if (!check2(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check2(uint val) {
- Expression<Func<uint>> e =
- Expression.Lambda<Func<uint>>(
- Expression.Constant(val, typeof(uint)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<uint> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1709
- namespace Scenario1709{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check3__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check3__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check3();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check3() {
- foreach (ulong val in new ulong[] { 0, 1, ulong.MaxValue }) {
- if (!check3(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check3(ulong val) {
- Expression<Func<ulong>> e =
- Expression.Lambda<Func<ulong>>(
- Expression.Constant(val, typeof(ulong)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<ulong> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1710
- namespace Scenario1710{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check4__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check4__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check4();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check4() {
- foreach (sbyte val in new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue }) {
- if (!check4(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check4(sbyte val) {
- Expression<Func<sbyte>> e =
- Expression.Lambda<Func<sbyte>>(
- Expression.Constant(val, typeof(sbyte)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<sbyte> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1711
- namespace Scenario1711{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check5__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check5__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check5();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check5() {
- foreach (short val in new short[] { 0, 1, -1, short.MinValue, short.MaxValue }) {
- if (!check5(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check5(short val) {
- Expression<Func<short>> e =
- Expression.Lambda<Func<short>>(
- Expression.Constant(val, typeof(short)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<short> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1712
- namespace Scenario1712{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check6__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check6__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check6();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check6() {
- foreach (int val in new int[] { 0, 1, -1, int.MinValue, int.MaxValue }) {
- if (!check6(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check6(int val) {
- Expression<Func<int>> e =
- Expression.Lambda<Func<int>>(
- Expression.Constant(val, typeof(int)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<int> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1713
- namespace Scenario1713{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check7__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check7__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check7();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check7() {
- foreach (long val in new long[] { 0, 1, -1, long.MinValue, long.MaxValue }) {
- if (!check7(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check7(long val) {
- Expression<Func<long>> e =
- Expression.Lambda<Func<long>>(
- Expression.Constant(val, typeof(long)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<long> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1714
- namespace Scenario1714{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check8__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check8__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check8();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check8() {
- foreach (float val in new float[] { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN }) {
- if (!check8(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check8(float val) {
- Expression<Func<float>> e =
- Expression.Lambda<Func<float>>(
- Expression.Constant(val, typeof(float)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<float> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1715
- namespace Scenario1715{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check9__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check9__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check9();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check9() {
- foreach (double val in new double[] { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN }) {
- if (!check9(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check9(double val) {
- Expression<Func<double>> e =
- Expression.Lambda<Func<double>>(
- Expression.Constant(val, typeof(double)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<double> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1716
- namespace Scenario1716{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check10__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check10__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check10();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check10() {
- foreach (decimal val in new decimal[] { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue }) {
- if (!check10(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check10(decimal val) {
- Expression<Func<decimal>> e =
- Expression.Lambda<Func<decimal>>(
- Expression.Constant(val, typeof(decimal)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<decimal> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1717
- namespace Scenario1717{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check11__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check11__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check11();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check11() {
- foreach (char val in new char[] { '\0', '\b', 'A', '\uffff' }) {
- if (!check11(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check11(char val) {
- Expression<Func<char>> e =
- Expression.Lambda<Func<char>>(
- Expression.Constant(val, typeof(char)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<char> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1718
- namespace Scenario1718{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check12__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check12__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check12();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check12() {
- foreach (bool val in new bool[] { true, false }) {
- if (!check12(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check12(bool val) {
- Expression<Func<bool>> e =
- Expression.Lambda<Func<bool>>(
- Expression.Constant(val, typeof(bool)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<bool> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
- }
-
- //-------- Scenario 1719
- namespace Scenario1719{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check13__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check13__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check13();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check13() {
- foreach (S val in new S[] { default(S), new S() }) {
- if (!check13(val)) {
- return false;
- }
- }
- return true;
- }
-
- static bool check13(S val) {
- Expression<Func<S>> e =
- Expression.Lambda<Func<S>>(
- Expression.Constant(val, typeof(S)),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<S> f = e.Compile();
- return object.Equals(f(), val);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[] { "test.dll" });
- }
-
- public static void StopCapture() {
- // MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
- // m.Invoke(null, new object[0]);
- }
-
- public static bool IsIntegralOrEnum(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Byte:
- case TypeCode.SByte:
- case TypeCode.Int16:
- case TypeCode.Int32:
- case TypeCode.Int64:
- case TypeCode.UInt16:
- case TypeCode.UInt32:
- case TypeCode.UInt64:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsFloating(Type type) {
- switch (Type.GetTypeCode(GetNonNullableType(type))) {
- case TypeCode.Single:
- case TypeCode.Double:
- return true;
- default:
- return false;
- }
- }
-
- public static Type GetNonNullableType(Type type) {
- return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
- type.GetGenericArguments()[0] :
- type;
- }
- }
-
-
-
-
- public interface I {
- void M();
- }
-
- public class C : IEquatable<C>, I {
- void I.M() {
- }
-
- public override bool Equals(object o) {
- return o is C && Equals((C) o);
- }
-
- public bool Equals(C c) {
- return c != null;
- }
-
- public override int GetHashCode() {
- return 0;
- }
- }
-
- public class D : C, IEquatable<D> {
- public int Val;
- public D() {
- }
- public D(int val) {
- Val = val;
- }
-
- public override bool Equals(object o) {
- return o is D && Equals((D) o);
- }
-
- public bool Equals(D d) {
- return d != null && d.Val == Val;
- }
-
- public override int GetHashCode() {
- return Val;
- }
- }
-
- public enum E {
- A=1, B=2
- }
-
- public enum El : long {
- A, B, C
- }
-
- public struct S : IEquatable<S> {
- public override bool Equals(object o) {
- return (o is S) && Equals((S) o);
- }
- public bool Equals(S other) {
- return true;
- }
- public override int GetHashCode() {
- return 0;
- }
- }
-
- public struct Sp : IEquatable<Sp> {
- public Sp(int i, double d) {
- I = i;
- D = d;
- }
-
- public int I;
- public double D;
-
- public override bool Equals(object o) {
- return (o is Sp) && Equals((Sp) o);
- }
- public bool Equals(Sp other) {
- return other.I == I && other.D == D;
- }
- public override int GetHashCode() {
- return I.GetHashCode() ^ D.GetHashCode();
- }
- }
-
- public struct Ss : IEquatable<Ss> {
- public Ss(S s) {
- Val = s;
- }
-
- public S Val;
-
- public override bool Equals(object o) {
- return (o is Ss) && Equals((Ss) o);
- }
- public bool Equals(Ss other) {
- return other.Val.Equals(Val);
- }
- public override int GetHashCode() {
- return Val.GetHashCode();
- }
- }
-
- public struct Sc : IEquatable<Sc> {
- public Sc(string s) {
- S = s;
- }
-
- public string S;
-
- public override bool Equals(object o) {
- return (o is Sc) && Equals((Sc) o);
- }
- public bool Equals(Sc other) {
- return other.S == S;
- }
- public override int GetHashCode() {
- return S.GetHashCode();
- }
- }
-
- public struct Scs : IEquatable<Scs> {
- public Scs(string s, S val) {
- S = s;
- Val = val;
- }
-
- public string S;
- public S Val;
-
- public override bool Equals(object o) {
- return (o is Scs) && Equals((Scs) o);
- }
- public bool Equals(Scs other) {
- return other.S == S && other.Val.Equals(Val);
- }
- public override int GetHashCode() {
- return S.GetHashCode() ^ Val.GetHashCode();
- }
- }
-
-
- }
-
- //-------- Scenario 1720
- namespace Scenario1720{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "check14__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression check14__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check14();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check14() {
- foreach (Sp val in new Sp[] { default(Sp), new Sp(), new Sp(5,5.0) }) {
- if (!check14(val)) {
- …
Large files files are truncated, but you can click here to view the full file