/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionCompiler/array_BackSl_index_BackSl_test0.cs
C# | 10651 lines | 9016 code | 1420 blank | 215 comment | 846 complexity | 58772e2b18712478e6f2280faba6af92 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 3124
- namespace Scenario3124{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "byte_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression byte_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_byte_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_byte_ArrayIndex()
- {
- return checkEx_byte_ArrayIndex(null, -1) &
- checkEx_byte_ArrayIndex(null, 0) &
- checkEx_byte_ArrayIndex(null, 1) &
-
- check_byte_ArrayIndex(genArrbyte_ArrayIndex(0)) &
- check_byte_ArrayIndex(genArrbyte_ArrayIndex(1)) &
- check_byte_ArrayIndex(genArrbyte_ArrayIndex(5));
- }
-
- static byte[] genArrbyte_ArrayIndex(int size)
- {
- byte[] vals = new byte[] { 0, 1, byte.MaxValue };
- byte[] result = new byte[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_byte_ArrayIndex(byte[] val)
- {
- bool success = checkEx_byte_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_byte_ArrayIndex(val, 0);
- }
- success &= checkEx_byte_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_byte_ArrayIndex(byte[] val, int index)
- {
- try
- {
- check_byte_ArrayIndex(val, index);
- Console.WriteLine("byte_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_byte_ArrayIndex(byte[] val, int index)
- {
- Expression<Func<byte>> e =
- Expression.Lambda<Func<byte>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(byte[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<byte> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3125
- namespace Scenario3125{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ushort_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression ushort_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_ushort_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_ushort_ArrayIndex()
- {
- return checkEx_ushort_ArrayIndex(null, -1) &
- checkEx_ushort_ArrayIndex(null, 0) &
- checkEx_ushort_ArrayIndex(null, 1) &
-
- check_ushort_ArrayIndex(genArrushort_ArrayIndex(0)) &
- check_ushort_ArrayIndex(genArrushort_ArrayIndex(1)) &
- check_ushort_ArrayIndex(genArrushort_ArrayIndex(5));
- }
-
- static ushort[] genArrushort_ArrayIndex(int size)
- {
- ushort[] vals = new ushort[] { 0, 1, ushort.MaxValue };
- ushort[] result = new ushort[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_ushort_ArrayIndex(ushort[] val)
- {
- bool success = checkEx_ushort_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_ushort_ArrayIndex(val, 0);
- }
- success &= checkEx_ushort_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_ushort_ArrayIndex(ushort[] val, int index)
- {
- try
- {
- check_ushort_ArrayIndex(val, index);
- Console.WriteLine("ushort_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_ushort_ArrayIndex(ushort[] val, int index)
- {
- Expression<Func<ushort>> e =
- Expression.Lambda<Func<ushort>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(ushort[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<ushort> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3126
- namespace Scenario3126{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "uint_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression uint_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_uint_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_uint_ArrayIndex()
- {
- return checkEx_uint_ArrayIndex(null, -1) &
- checkEx_uint_ArrayIndex(null, 0) &
- checkEx_uint_ArrayIndex(null, 1) &
-
- check_uint_ArrayIndex(genArruint_ArrayIndex(0)) &
- check_uint_ArrayIndex(genArruint_ArrayIndex(1)) &
- check_uint_ArrayIndex(genArruint_ArrayIndex(5));
- }
-
- static uint[] genArruint_ArrayIndex(int size)
- {
- uint[] vals = new uint[] { 0, 1, uint.MaxValue };
- uint[] result = new uint[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_uint_ArrayIndex(uint[] val)
- {
- bool success = checkEx_uint_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_uint_ArrayIndex(val, 0);
- }
- success &= checkEx_uint_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_uint_ArrayIndex(uint[] val, int index)
- {
- try
- {
- check_uint_ArrayIndex(val, index);
- Console.WriteLine("uint_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_uint_ArrayIndex(uint[] val, int index)
- {
- Expression<Func<uint>> e =
- Expression.Lambda<Func<uint>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(uint[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<uint> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3127
- namespace Scenario3127{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ulong_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression ulong_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_ulong_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_ulong_ArrayIndex()
- {
- return checkEx_ulong_ArrayIndex(null, -1) &
- checkEx_ulong_ArrayIndex(null, 0) &
- checkEx_ulong_ArrayIndex(null, 1) &
-
- check_ulong_ArrayIndex(genArrulong_ArrayIndex(0)) &
- check_ulong_ArrayIndex(genArrulong_ArrayIndex(1)) &
- check_ulong_ArrayIndex(genArrulong_ArrayIndex(5));
- }
-
- static ulong[] genArrulong_ArrayIndex(int size)
- {
- ulong[] vals = new ulong[] { 0, 1, ulong.MaxValue };
- ulong[] result = new ulong[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_ulong_ArrayIndex(ulong[] val)
- {
- bool success = checkEx_ulong_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_ulong_ArrayIndex(val, 0);
- }
- success &= checkEx_ulong_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_ulong_ArrayIndex(ulong[] val, int index)
- {
- try
- {
- check_ulong_ArrayIndex(val, index);
- Console.WriteLine("ulong_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_ulong_ArrayIndex(ulong[] val, int index)
- {
- Expression<Func<ulong>> e =
- Expression.Lambda<Func<ulong>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(ulong[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<ulong> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3128
- namespace Scenario3128{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "sbyte_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression sbyte_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_sbyte_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_sbyte_ArrayIndex()
- {
- return checkEx_sbyte_ArrayIndex(null, -1) &
- checkEx_sbyte_ArrayIndex(null, 0) &
- checkEx_sbyte_ArrayIndex(null, 1) &
-
- check_sbyte_ArrayIndex(genArrsbyte_ArrayIndex(0)) &
- check_sbyte_ArrayIndex(genArrsbyte_ArrayIndex(1)) &
- check_sbyte_ArrayIndex(genArrsbyte_ArrayIndex(5));
- }
-
- static sbyte[] genArrsbyte_ArrayIndex(int size)
- {
- sbyte[] vals = new sbyte[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue };
- sbyte[] result = new sbyte[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_sbyte_ArrayIndex(sbyte[] val)
- {
- bool success = checkEx_sbyte_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_sbyte_ArrayIndex(val, 0);
- }
- success &= checkEx_sbyte_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_sbyte_ArrayIndex(sbyte[] val, int index)
- {
- try
- {
- check_sbyte_ArrayIndex(val, index);
- Console.WriteLine("sbyte_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_sbyte_ArrayIndex(sbyte[] val, int index)
- {
- Expression<Func<sbyte>> e =
- Expression.Lambda<Func<sbyte>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(sbyte[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<sbyte> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3129
- namespace Scenario3129{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "short_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression short_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_short_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_short_ArrayIndex()
- {
- return checkEx_short_ArrayIndex(null, -1) &
- checkEx_short_ArrayIndex(null, 0) &
- checkEx_short_ArrayIndex(null, 1) &
-
- check_short_ArrayIndex(genArrshort_ArrayIndex(0)) &
- check_short_ArrayIndex(genArrshort_ArrayIndex(1)) &
- check_short_ArrayIndex(genArrshort_ArrayIndex(5));
- }
-
- static short[] genArrshort_ArrayIndex(int size)
- {
- short[] vals = new short[] { 0, 1, -1, short.MinValue, short.MaxValue };
- short[] result = new short[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_short_ArrayIndex(short[] val)
- {
- bool success = checkEx_short_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_short_ArrayIndex(val, 0);
- }
- success &= checkEx_short_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_short_ArrayIndex(short[] val, int index)
- {
- try
- {
- check_short_ArrayIndex(val, index);
- Console.WriteLine("short_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_short_ArrayIndex(short[] val, int index)
- {
- Expression<Func<short>> e =
- Expression.Lambda<Func<short>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(short[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<short> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3130
- namespace Scenario3130{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "int_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression int_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_int_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_int_ArrayIndex()
- {
- return checkEx_int_ArrayIndex(null, -1) &
- checkEx_int_ArrayIndex(null, 0) &
- checkEx_int_ArrayIndex(null, 1) &
-
- check_int_ArrayIndex(genArrint_ArrayIndex(0)) &
- check_int_ArrayIndex(genArrint_ArrayIndex(1)) &
- check_int_ArrayIndex(genArrint_ArrayIndex(5));
- }
-
- static int[] genArrint_ArrayIndex(int size)
- {
- int[] vals = new int[] { 0, 1, -1, int.MinValue, int.MaxValue };
- int[] result = new int[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_int_ArrayIndex(int[] val)
- {
- bool success = checkEx_int_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_int_ArrayIndex(val, 0);
- }
- success &= checkEx_int_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_int_ArrayIndex(int[] val, int index)
- {
- try
- {
- check_int_ArrayIndex(val, index);
- Console.WriteLine("int_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_int_ArrayIndex(int[] val, int index)
- {
- Expression<Func<int>> e =
- Expression.Lambda<Func<int>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(int[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<int> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3131
- namespace Scenario3131{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "long_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression long_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_long_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_long_ArrayIndex()
- {
- return checkEx_long_ArrayIndex(null, -1) &
- checkEx_long_ArrayIndex(null, 0) &
- checkEx_long_ArrayIndex(null, 1) &
-
- check_long_ArrayIndex(genArrlong_ArrayIndex(0)) &
- check_long_ArrayIndex(genArrlong_ArrayIndex(1)) &
- check_long_ArrayIndex(genArrlong_ArrayIndex(5));
- }
-
- static long[] genArrlong_ArrayIndex(int size)
- {
- long[] vals = new long[] { 0, 1, -1, long.MinValue, long.MaxValue };
- long[] result = new long[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_long_ArrayIndex(long[] val)
- {
- bool success = checkEx_long_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_long_ArrayIndex(val, 0);
- }
- success &= checkEx_long_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_long_ArrayIndex(long[] val, int index)
- {
- try
- {
- check_long_ArrayIndex(val, index);
- Console.WriteLine("long_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_long_ArrayIndex(long[] val, int index)
- {
- Expression<Func<long>> e =
- Expression.Lambda<Func<long>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(long[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<long> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3132
- namespace Scenario3132{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "float_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression float_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_float_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_float_ArrayIndex()
- {
- return checkEx_float_ArrayIndex(null, -1) &
- checkEx_float_ArrayIndex(null, 0) &
- checkEx_float_ArrayIndex(null, 1) &
-
- check_float_ArrayIndex(genArrfloat_ArrayIndex(0)) &
- check_float_ArrayIndex(genArrfloat_ArrayIndex(1)) &
- check_float_ArrayIndex(genArrfloat_ArrayIndex(5));
- }
-
- static float[] genArrfloat_ArrayIndex(int size)
- {
- float[] vals = new float[] { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN };
- float[] result = new float[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_float_ArrayIndex(float[] val)
- {
- bool success = checkEx_float_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_float_ArrayIndex(val, 0);
- }
- success &= checkEx_float_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_float_ArrayIndex(float[] val, int index)
- {
- try
- {
- check_float_ArrayIndex(val, index);
- Console.WriteLine("float_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_float_ArrayIndex(float[] val, int index)
- {
- Expression<Func<float>> e =
- Expression.Lambda<Func<float>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(float[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<float> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3133
- namespace Scenario3133{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "double_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression double_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_double_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_double_ArrayIndex()
- {
- return checkEx_double_ArrayIndex(null, -1) &
- checkEx_double_ArrayIndex(null, 0) &
- checkEx_double_ArrayIndex(null, 1) &
-
- check_double_ArrayIndex(genArrdouble_ArrayIndex(0)) &
- check_double_ArrayIndex(genArrdouble_ArrayIndex(1)) &
- check_double_ArrayIndex(genArrdouble_ArrayIndex(5));
- }
-
- static double[] genArrdouble_ArrayIndex(int size)
- {
- double[] vals = new double[] { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN };
- double[] result = new double[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_double_ArrayIndex(double[] val)
- {
- bool success = checkEx_double_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_double_ArrayIndex(val, 0);
- }
- success &= checkEx_double_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_double_ArrayIndex(double[] val, int index)
- {
- try
- {
- check_double_ArrayIndex(val, index);
- Console.WriteLine("double_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- {
- return true;
- }
- }
-
- static bool check_double_ArrayIndex(double[] val, int index)
- {
- Expression<Func<double>> e =
- Expression.Lambda<Func<double>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(double[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<double> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- 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 3134
- namespace Scenario3134{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "decimal_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression decimal_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_decimal_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_decimal_ArrayIndex()
- {
- return checkEx_decimal_ArrayIndex(null, -1) &
- checkEx_decimal_ArrayIndex(null, 0) &
- checkEx_decimal_ArrayIndex(null, 1) &
-
- check_decimal_ArrayIndex(genArrdecimal_ArrayIndex(0)) &
- check_decimal_ArrayIndex(genArrdecimal_ArrayIndex(1)) &
- check_decimal_ArrayIndex(genArrdecimal_ArrayIndex(5));
- }
-
- static decimal[] genArrdecimal_ArrayIndex(int size)
- {
- decimal[] vals = new decimal[] { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue };
- decimal[] result = new decimal[size];
- for (int i = 0; i < size; i++)
- {
- result[i] = vals[i % vals.Length];
- }
- return result;
- }
-
- static bool check_decimal_ArrayIndex(decimal[] val)
- {
- bool success = checkEx_decimal_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++)
- {
- success &= check_decimal_ArrayIndex(val, 0);
- }
- success &= checkEx_decimal_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_decimal_ArrayIndex(decimal[] val, int index)
- {
- try
- {
- check_decimal_ArrayIndex(val, index);
- Console.WriteLine("decimal_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch
- …
Large files files are truncated, but you can click here to view the full file