/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionCompiler/array_BackSl_index_BackSl_test1.cs
C# | 4321 lines | 3565 code | 641 blank | 115 comment | 377 complexity | 473d095d9e7b75504fb7dc0c0b47302e 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 3167
- namespace Scenario3167{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "byteq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression byteq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_byteq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_byteq_ArrayIndex() {
- return checkEx_byteq_ArrayIndex(null, -1) &
- checkEx_byteq_ArrayIndex(null, 0) &
- checkEx_byteq_ArrayIndex(null, 1) &
-
- check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(0)) &
- check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(1)) &
- check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(5));
- }
-
- static byte?[] genArrbyteq_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_byteq_ArrayIndex(byte?[] val) {
- bool success = checkEx_byteq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_byteq_ArrayIndex(val, 0);
- }
- success &= checkEx_byteq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_byteq_ArrayIndex(byte?[] val, int index) {
- try {
- check_byteq_ArrayIndex(val, index);
- Console.WriteLine("byteq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_byteq_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 3168
- namespace Scenario3168{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ushortq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression ushortq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_ushortq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_ushortq_ArrayIndex() {
- return checkEx_ushortq_ArrayIndex(null, -1) &
- checkEx_ushortq_ArrayIndex(null, 0) &
- checkEx_ushortq_ArrayIndex(null, 1) &
-
- check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(0)) &
- check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(1)) &
- check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(5));
- }
-
- static ushort?[] genArrushortq_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_ushortq_ArrayIndex(ushort?[] val) {
- bool success = checkEx_ushortq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_ushortq_ArrayIndex(val, 0);
- }
- success &= checkEx_ushortq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_ushortq_ArrayIndex(ushort?[] val, int index) {
- try {
- check_ushortq_ArrayIndex(val, index);
- Console.WriteLine("ushortq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_ushortq_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 3169
- namespace Scenario3169{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "uintq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression uintq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_uintq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_uintq_ArrayIndex() {
- return checkEx_uintq_ArrayIndex(null, -1) &
- checkEx_uintq_ArrayIndex(null, 0) &
- checkEx_uintq_ArrayIndex(null, 1) &
-
- check_uintq_ArrayIndex(genArruintq_ArrayIndex(0)) &
- check_uintq_ArrayIndex(genArruintq_ArrayIndex(1)) &
- check_uintq_ArrayIndex(genArruintq_ArrayIndex(5));
- }
-
- static uint?[] genArruintq_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_uintq_ArrayIndex(uint?[] val) {
- bool success = checkEx_uintq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_uintq_ArrayIndex(val, 0);
- }
- success &= checkEx_uintq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_uintq_ArrayIndex(uint?[] val, int index) {
- try {
- check_uintq_ArrayIndex(val, index);
- Console.WriteLine("uintq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_uintq_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 3170
- namespace Scenario3170{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ulongq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression ulongq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_ulongq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_ulongq_ArrayIndex() {
- return checkEx_ulongq_ArrayIndex(null, -1) &
- checkEx_ulongq_ArrayIndex(null, 0) &
- checkEx_ulongq_ArrayIndex(null, 1) &
-
- check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(0)) &
- check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(1)) &
- check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(5));
- }
-
- static ulong?[] genArrulongq_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_ulongq_ArrayIndex(ulong?[] val) {
- bool success = checkEx_ulongq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_ulongq_ArrayIndex(val, 0);
- }
- success &= checkEx_ulongq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_ulongq_ArrayIndex(ulong?[] val, int index) {
- try {
- check_ulongq_ArrayIndex(val, index);
- Console.WriteLine("ulongq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_ulongq_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 3171
- namespace Scenario3171{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "sbyteq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression sbyteq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_sbyteq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_sbyteq_ArrayIndex() {
- return checkEx_sbyteq_ArrayIndex(null, -1) &
- checkEx_sbyteq_ArrayIndex(null, 0) &
- checkEx_sbyteq_ArrayIndex(null, 1) &
-
- check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(0)) &
- check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(1)) &
- check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(5));
- }
-
- static sbyte?[] genArrsbyteq_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_sbyteq_ArrayIndex(sbyte?[] val) {
- bool success = checkEx_sbyteq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_sbyteq_ArrayIndex(val, 0);
- }
- success &= checkEx_sbyteq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_sbyteq_ArrayIndex(sbyte?[] val, int index) {
- try {
- check_sbyteq_ArrayIndex(val, index);
- Console.WriteLine("sbyteq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_sbyteq_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 3172
- namespace Scenario3172{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "shortq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression shortq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_shortq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_shortq_ArrayIndex() {
- return checkEx_shortq_ArrayIndex(null, -1) &
- checkEx_shortq_ArrayIndex(null, 0) &
- checkEx_shortq_ArrayIndex(null, 1) &
-
- check_shortq_ArrayIndex(genArrshortq_ArrayIndex(0)) &
- check_shortq_ArrayIndex(genArrshortq_ArrayIndex(1)) &
- check_shortq_ArrayIndex(genArrshortq_ArrayIndex(5));
- }
-
- static short?[] genArrshortq_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_shortq_ArrayIndex(short?[] val) {
- bool success = checkEx_shortq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_shortq_ArrayIndex(val, 0);
- }
- success &= checkEx_shortq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_shortq_ArrayIndex(short?[] val, int index) {
- try {
- check_shortq_ArrayIndex(val, index);
- Console.WriteLine("shortq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_shortq_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 3173
- namespace Scenario3173{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "intq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression intq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_intq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_intq_ArrayIndex() {
- return checkEx_intq_ArrayIndex(null, -1) &
- checkEx_intq_ArrayIndex(null, 0) &
- checkEx_intq_ArrayIndex(null, 1) &
-
- check_intq_ArrayIndex(genArrintq_ArrayIndex(0)) &
- check_intq_ArrayIndex(genArrintq_ArrayIndex(1)) &
- check_intq_ArrayIndex(genArrintq_ArrayIndex(5));
- }
-
- static int?[] genArrintq_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_intq_ArrayIndex(int?[] val) {
- bool success = checkEx_intq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_intq_ArrayIndex(val, 0);
- }
- success &= checkEx_intq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_intq_ArrayIndex(int?[] val, int index) {
- try {
- check_intq_ArrayIndex(val, index);
- Console.WriteLine("intq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_intq_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 3174
- namespace Scenario3174{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "longq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression longq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_longq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_longq_ArrayIndex() {
- return checkEx_longq_ArrayIndex(null, -1) &
- checkEx_longq_ArrayIndex(null, 0) &
- checkEx_longq_ArrayIndex(null, 1) &
-
- check_longq_ArrayIndex(genArrlongq_ArrayIndex(0)) &
- check_longq_ArrayIndex(genArrlongq_ArrayIndex(1)) &
- check_longq_ArrayIndex(genArrlongq_ArrayIndex(5));
- }
-
- static long?[] genArrlongq_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_longq_ArrayIndex(long?[] val) {
- bool success = checkEx_longq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_longq_ArrayIndex(val, 0);
- }
- success &= checkEx_longq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_longq_ArrayIndex(long?[] val, int index) {
- try {
- check_longq_ArrayIndex(val, index);
- Console.WriteLine("longq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_longq_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 3175
- namespace Scenario3175{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "floatq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression floatq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_floatq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_floatq_ArrayIndex() {
- return checkEx_floatq_ArrayIndex(null, -1) &
- checkEx_floatq_ArrayIndex(null, 0) &
- checkEx_floatq_ArrayIndex(null, 1) &
-
- check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(0)) &
- check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(1)) &
- check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(5));
- }
-
- static float?[] genArrfloatq_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_floatq_ArrayIndex(float?[] val) {
- bool success = checkEx_floatq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_floatq_ArrayIndex(val, 0);
- }
- success &= checkEx_floatq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_floatq_ArrayIndex(float?[] val, int index) {
- try {
- check_floatq_ArrayIndex(val, index);
- Console.WriteLine("floatq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_floatq_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 3176
- namespace Scenario3176{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "doubleq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression doubleq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_doubleq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_doubleq_ArrayIndex() {
- return checkEx_doubleq_ArrayIndex(null, -1) &
- checkEx_doubleq_ArrayIndex(null, 0) &
- checkEx_doubleq_ArrayIndex(null, 1) &
-
- check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(0)) &
- check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(1)) &
- check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(5));
- }
-
- static double?[] genArrdoubleq_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_doubleq_ArrayIndex(double?[] val) {
- bool success = checkEx_doubleq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_doubleq_ArrayIndex(val, 0);
- }
- success &= checkEx_doubleq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_doubleq_ArrayIndex(double?[] val, int index) {
- try {
- check_doubleq_ArrayIndex(val, index);
- Console.WriteLine("doubleq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_doubleq_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 3177
- namespace Scenario3177{
-
- public class Test
- {
- [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "decimalq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
- public static Expression decimalq_ArrayIndex__() {
- if(Main() != 0 ) {
- throw new Exception();
- } else {
- return Expression.Constant(0);
- }
- }
- public static int Main()
- {
- Ext.StartCapture();
- bool success = false;
- try
- {
- success = check_decimalq_ArrayIndex();
- }
- finally
- {
- Ext.StopCapture();
- }
- return success ? 0 : 1;
- }
-
- static bool check_decimalq_ArrayIndex() {
- return checkEx_decimalq_ArrayIndex(null, -1) &
- checkEx_decimalq_ArrayIndex(null, 0) &
- checkEx_decimalq_ArrayIndex(null, 1) &
-
- check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(0)) &
- check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(1)) &
- check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(5));
- }
-
- static decimal?[] genArrdecimalq_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_decimalq_ArrayIndex(decimal?[] val) {
- bool success = checkEx_decimalq_ArrayIndex(val, -1);
- for (int i = 0; i < val.Length; i++) {
- success &= check_decimalq_ArrayIndex(val, 0);
- }
- success &= checkEx_decimalq_ArrayIndex(val, val.Length);
- return success;
- }
-
- static bool checkEx_decimalq_ArrayIndex(decimal?[] val, int index) {
- try {
- check_decimalq_ArrayIndex(val, index);
- Console.WriteLine("decimalq_ArrayIndex[" + index + "] failed");
- return false;
- }
- catch {
- return true;
- }
- }
-
- static bool check_decimalq_ArrayIndex(decimal?[] val, int index) {
- Expression<Func<decimal?>> e =
- Expression.Lambda<Func<decimal?>>(
- Expression.ArrayIndex(Expression.Constant(val, typeof(decimal?[])),
- Expression.Constant(index, typeof(int))),
- new System.Collections.Generic.List<ParameterExpression>());
- Func<decimal?> f = e.Compile();
- return object.Equals(f(), val[index]);
- }
- }
-
-
- public static class Ext {
- public static void StartCapture() {
- // …
Large files files are truncated, but you can click here to view the full file