PageRenderTime 77ms CodeModel.GetById 26ms app.highlight 39ms RepoModel.GetById 1ms app.codeStats 1ms

/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

Large files files are truncated, but you can click here to view the full file

   1#if !CLR2
   2using System.Linq.Expressions;
   3#else
   4using Microsoft.Scripting.Ast;
   5using Microsoft.Scripting.Utils;
   6#endif
   7
   8using System.Reflection;
   9using System;
  10namespace ExpressionCompiler { 
  11	
  12			
  13			//-------- Scenario 3167
  14			namespace Scenario3167{
  15				
  16				public class Test
  17				{
  18			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "byteq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  19			    public static Expression byteq_ArrayIndex__() {
  20			       if(Main() != 0 ) {
  21			           throw new Exception();
  22			       } else { 
  23			           return Expression.Constant(0);
  24			       }
  25			    }
  26				public     static int Main()
  27				    {
  28				        Ext.StartCapture();
  29				        bool success = false;
  30				        try
  31				        {
  32				            success = check_byteq_ArrayIndex();
  33				        }
  34				        finally
  35				        {
  36				            Ext.StopCapture();
  37				        }
  38				        return success ? 0 : 1;
  39				    }
  40				
  41				    static bool check_byteq_ArrayIndex() {
  42				        return checkEx_byteq_ArrayIndex(null, -1) &
  43				            checkEx_byteq_ArrayIndex(null, 0) &
  44				            checkEx_byteq_ArrayIndex(null, 1) &
  45				
  46				            check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(0)) &
  47				            check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(1)) &
  48				            check_byteq_ArrayIndex(genArrbyteq_ArrayIndex(5));
  49				    }
  50				
  51				    static byte?[] genArrbyteq_ArrayIndex(int size) {
  52				        byte?[] vals = new byte?[] { 0, 1, byte.MaxValue };
  53				        byte?[] result = new byte?[size];
  54				        for (int i = 0; i < size; i++) {
  55				            result[i] = vals[i % vals.Length];
  56				        }
  57				        return result;
  58				    }
  59				
  60				    static bool check_byteq_ArrayIndex(byte?[] val) {
  61				        bool success = checkEx_byteq_ArrayIndex(val, -1);
  62				        for (int i = 0; i < val.Length; i++) {
  63				            success &= check_byteq_ArrayIndex(val, 0);
  64				        }
  65				        success &= checkEx_byteq_ArrayIndex(val, val.Length);
  66				        return success;
  67				    }
  68				
  69				    static bool checkEx_byteq_ArrayIndex(byte?[] val, int index) {
  70				        try {
  71				            check_byteq_ArrayIndex(val, index);
  72				            Console.WriteLine("byteq_ArrayIndex[" + index + "] failed");
  73				            return false;
  74				        }
  75				        catch {
  76				            return true;
  77				        }
  78				    }
  79				
  80				    static bool check_byteq_ArrayIndex(byte?[] val, int index) {
  81				        Expression<Func<byte?>> e =
  82				            Expression.Lambda<Func<byte?>>(
  83				                Expression.ArrayIndex(Expression.Constant(val, typeof(byte?[])),
  84				                    Expression.Constant(index, typeof(int))),
  85				                new System.Collections.Generic.List<ParameterExpression>());
  86				        Func<byte?> f = e.Compile();
  87				        return object.Equals(f(), val[index]);
  88				    }
  89				}
  90			
  91			
  92			public  static class Ext {
  93			    public static void StartCapture() {
  94			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
  95			//        m.Invoke(null, new object[] { "test.dll" });
  96			    }
  97			
  98			    public static void StopCapture() {
  99			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 100			//        m.Invoke(null, new object[0]);
 101			    }
 102			
 103			    public static bool IsIntegralOrEnum(Type type) {
 104			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 105			            case TypeCode.Byte:
 106			            case TypeCode.SByte:
 107			            case TypeCode.Int16:
 108			            case TypeCode.Int32:
 109			            case TypeCode.Int64:
 110			            case TypeCode.UInt16:
 111			            case TypeCode.UInt32:
 112			            case TypeCode.UInt64:
 113			                return true;
 114			            default:
 115			                return false;
 116			        }
 117			    }
 118			
 119			    public static bool IsFloating(Type type) {
 120			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 121			            case TypeCode.Single:
 122			            case TypeCode.Double:
 123			                return true;
 124			            default:
 125			                return false;
 126			        }
 127			    }
 128			
 129			    public static Type GetNonNullableType(Type type) {
 130			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 131			                type.GetGenericArguments()[0] :
 132			                type;
 133			    }
 134			}
 135			
 136		
 137	}
 138			
 139			//-------- Scenario 3168
 140			namespace Scenario3168{
 141				
 142				public class Test
 143				{
 144			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ushortq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 145			    public static Expression ushortq_ArrayIndex__() {
 146			       if(Main() != 0 ) {
 147			           throw new Exception();
 148			       } else { 
 149			           return Expression.Constant(0);
 150			       }
 151			    }
 152				public     static int Main()
 153				    {
 154				        Ext.StartCapture();
 155				        bool success = false;
 156				        try
 157				        {
 158				            success = check_ushortq_ArrayIndex();
 159				        }
 160				        finally
 161				        {
 162				            Ext.StopCapture();
 163				        }
 164				        return success ? 0 : 1;
 165				    }
 166				
 167				    static bool check_ushortq_ArrayIndex() {
 168				        return checkEx_ushortq_ArrayIndex(null, -1) &
 169				            checkEx_ushortq_ArrayIndex(null, 0) &
 170				            checkEx_ushortq_ArrayIndex(null, 1) &
 171				
 172				            check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(0)) &
 173				            check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(1)) &
 174				            check_ushortq_ArrayIndex(genArrushortq_ArrayIndex(5));
 175				    }
 176				
 177				    static ushort?[] genArrushortq_ArrayIndex(int size) {
 178				        ushort?[] vals = new ushort?[] { 0, 1, ushort.MaxValue };
 179				        ushort?[] result = new ushort?[size];
 180				        for (int i = 0; i < size; i++) {
 181				            result[i] = vals[i % vals.Length];
 182				        }
 183				        return result;
 184				    }
 185				
 186				    static bool check_ushortq_ArrayIndex(ushort?[] val) {
 187				        bool success = checkEx_ushortq_ArrayIndex(val, -1);
 188				        for (int i = 0; i < val.Length; i++) {
 189				            success &= check_ushortq_ArrayIndex(val, 0);
 190				        }
 191				        success &= checkEx_ushortq_ArrayIndex(val, val.Length);
 192				        return success;
 193				    }
 194				
 195				    static bool checkEx_ushortq_ArrayIndex(ushort?[] val, int index) {
 196				        try {
 197				            check_ushortq_ArrayIndex(val, index);
 198				            Console.WriteLine("ushortq_ArrayIndex[" + index + "] failed");
 199				            return false;
 200				        }
 201				        catch {
 202				            return true;
 203				        }
 204				    }
 205				
 206				    static bool check_ushortq_ArrayIndex(ushort?[] val, int index) {
 207				        Expression<Func<ushort?>> e =
 208				            Expression.Lambda<Func<ushort?>>(
 209				                Expression.ArrayIndex(Expression.Constant(val, typeof(ushort?[])),
 210				                    Expression.Constant(index, typeof(int))),
 211				                new System.Collections.Generic.List<ParameterExpression>());
 212				        Func<ushort?> f = e.Compile();
 213				        return object.Equals(f(), val[index]);
 214				    }
 215				}
 216			
 217			
 218			public  static class Ext {
 219			    public static void StartCapture() {
 220			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 221			//        m.Invoke(null, new object[] { "test.dll" });
 222			    }
 223			
 224			    public static void StopCapture() {
 225			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 226			//        m.Invoke(null, new object[0]);
 227			    }
 228			
 229			    public static bool IsIntegralOrEnum(Type type) {
 230			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 231			            case TypeCode.Byte:
 232			            case TypeCode.SByte:
 233			            case TypeCode.Int16:
 234			            case TypeCode.Int32:
 235			            case TypeCode.Int64:
 236			            case TypeCode.UInt16:
 237			            case TypeCode.UInt32:
 238			            case TypeCode.UInt64:
 239			                return true;
 240			            default:
 241			                return false;
 242			        }
 243			    }
 244			
 245			    public static bool IsFloating(Type type) {
 246			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 247			            case TypeCode.Single:
 248			            case TypeCode.Double:
 249			                return true;
 250			            default:
 251			                return false;
 252			        }
 253			    }
 254			
 255			    public static Type GetNonNullableType(Type type) {
 256			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 257			                type.GetGenericArguments()[0] :
 258			                type;
 259			    }
 260			}
 261			
 262		
 263	}
 264			
 265			//-------- Scenario 3169
 266			namespace Scenario3169{
 267				
 268				public class Test
 269				{
 270			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "uintq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 271			    public static Expression uintq_ArrayIndex__() {
 272			       if(Main() != 0 ) {
 273			           throw new Exception();
 274			       } else { 
 275			           return Expression.Constant(0);
 276			       }
 277			    }
 278				public     static int Main()
 279				    {
 280				        Ext.StartCapture();
 281				        bool success = false;
 282				        try
 283				        {
 284				            success = check_uintq_ArrayIndex();
 285				        }
 286				        finally
 287				        {
 288				            Ext.StopCapture();
 289				        }
 290				        return success ? 0 : 1;
 291				    }
 292				
 293				    static bool check_uintq_ArrayIndex() {
 294				        return checkEx_uintq_ArrayIndex(null, -1) &
 295				            checkEx_uintq_ArrayIndex(null, 0) &
 296				            checkEx_uintq_ArrayIndex(null, 1) &
 297				
 298				            check_uintq_ArrayIndex(genArruintq_ArrayIndex(0)) &
 299				            check_uintq_ArrayIndex(genArruintq_ArrayIndex(1)) &
 300				            check_uintq_ArrayIndex(genArruintq_ArrayIndex(5));
 301				    }
 302				
 303				    static uint?[] genArruintq_ArrayIndex(int size) {
 304				        uint?[] vals = new uint?[] { 0, 1, uint.MaxValue };
 305				        uint?[] result = new uint?[size];
 306				        for (int i = 0; i < size; i++) {
 307				            result[i] = vals[i % vals.Length];
 308				        }
 309				        return result;
 310				    }
 311				
 312				    static bool check_uintq_ArrayIndex(uint?[] val) {
 313				        bool success = checkEx_uintq_ArrayIndex(val, -1);
 314				        for (int i = 0; i < val.Length; i++) {
 315				            success &= check_uintq_ArrayIndex(val, 0);
 316				        }
 317				        success &= checkEx_uintq_ArrayIndex(val, val.Length);
 318				        return success;
 319				    }
 320				
 321				    static bool checkEx_uintq_ArrayIndex(uint?[] val, int index) {
 322				        try {
 323				            check_uintq_ArrayIndex(val, index);
 324				            Console.WriteLine("uintq_ArrayIndex[" + index + "] failed");
 325				            return false;
 326				        }
 327				        catch {
 328				            return true;
 329				        }
 330				    }
 331				
 332				    static bool check_uintq_ArrayIndex(uint?[] val, int index) {
 333				        Expression<Func<uint?>> e =
 334				            Expression.Lambda<Func<uint?>>(
 335				                Expression.ArrayIndex(Expression.Constant(val, typeof(uint?[])),
 336				                    Expression.Constant(index, typeof(int))),
 337				                new System.Collections.Generic.List<ParameterExpression>());
 338				        Func<uint?> f = e.Compile();
 339				        return object.Equals(f(), val[index]);
 340				    }
 341				}
 342			
 343			
 344			public  static class Ext {
 345			    public static void StartCapture() {
 346			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 347			//        m.Invoke(null, new object[] { "test.dll" });
 348			    }
 349			
 350			    public static void StopCapture() {
 351			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 352			//        m.Invoke(null, new object[0]);
 353			    }
 354			
 355			    public static bool IsIntegralOrEnum(Type type) {
 356			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 357			            case TypeCode.Byte:
 358			            case TypeCode.SByte:
 359			            case TypeCode.Int16:
 360			            case TypeCode.Int32:
 361			            case TypeCode.Int64:
 362			            case TypeCode.UInt16:
 363			            case TypeCode.UInt32:
 364			            case TypeCode.UInt64:
 365			                return true;
 366			            default:
 367			                return false;
 368			        }
 369			    }
 370			
 371			    public static bool IsFloating(Type type) {
 372			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 373			            case TypeCode.Single:
 374			            case TypeCode.Double:
 375			                return true;
 376			            default:
 377			                return false;
 378			        }
 379			    }
 380			
 381			    public static Type GetNonNullableType(Type type) {
 382			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 383			                type.GetGenericArguments()[0] :
 384			                type;
 385			    }
 386			}
 387			
 388		
 389	}
 390			
 391			//-------- Scenario 3170
 392			namespace Scenario3170{
 393				
 394				public class Test
 395				{
 396			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "ulongq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 397			    public static Expression ulongq_ArrayIndex__() {
 398			       if(Main() != 0 ) {
 399			           throw new Exception();
 400			       } else { 
 401			           return Expression.Constant(0);
 402			       }
 403			    }
 404				public     static int Main()
 405				    {
 406				        Ext.StartCapture();
 407				        bool success = false;
 408				        try
 409				        {
 410				            success = check_ulongq_ArrayIndex();
 411				        }
 412				        finally
 413				        {
 414				            Ext.StopCapture();
 415				        }
 416				        return success ? 0 : 1;
 417				    }
 418				
 419				    static bool check_ulongq_ArrayIndex() {
 420				        return checkEx_ulongq_ArrayIndex(null, -1) &
 421				            checkEx_ulongq_ArrayIndex(null, 0) &
 422				            checkEx_ulongq_ArrayIndex(null, 1) &
 423				
 424				            check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(0)) &
 425				            check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(1)) &
 426				            check_ulongq_ArrayIndex(genArrulongq_ArrayIndex(5));
 427				    }
 428				
 429				    static ulong?[] genArrulongq_ArrayIndex(int size) {
 430				        ulong?[] vals = new ulong?[] { 0, 1, ulong.MaxValue };
 431				        ulong?[] result = new ulong?[size];
 432				        for (int i = 0; i < size; i++) {
 433				            result[i] = vals[i % vals.Length];
 434				        }
 435				        return result;
 436				    }
 437				
 438				    static bool check_ulongq_ArrayIndex(ulong?[] val) {
 439				        bool success = checkEx_ulongq_ArrayIndex(val, -1);
 440				        for (int i = 0; i < val.Length; i++) {
 441				            success &= check_ulongq_ArrayIndex(val, 0);
 442				        }
 443				        success &= checkEx_ulongq_ArrayIndex(val, val.Length);
 444				        return success;
 445				    }
 446				
 447				    static bool checkEx_ulongq_ArrayIndex(ulong?[] val, int index) {
 448				        try {
 449				            check_ulongq_ArrayIndex(val, index);
 450				            Console.WriteLine("ulongq_ArrayIndex[" + index + "] failed");
 451				            return false;
 452				        }
 453				        catch {
 454				            return true;
 455				        }
 456				    }
 457				
 458				    static bool check_ulongq_ArrayIndex(ulong?[] val, int index) {
 459				        Expression<Func<ulong?>> e =
 460				            Expression.Lambda<Func<ulong?>>(
 461				                Expression.ArrayIndex(Expression.Constant(val, typeof(ulong?[])),
 462				                    Expression.Constant(index, typeof(int))),
 463				                new System.Collections.Generic.List<ParameterExpression>());
 464				        Func<ulong?> f = e.Compile();
 465				        return object.Equals(f(), val[index]);
 466				    }
 467				}
 468			
 469			
 470			public  static class Ext {
 471			    public static void StartCapture() {
 472			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 473			//        m.Invoke(null, new object[] { "test.dll" });
 474			    }
 475			
 476			    public static void StopCapture() {
 477			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 478			//        m.Invoke(null, new object[0]);
 479			    }
 480			
 481			    public static bool IsIntegralOrEnum(Type type) {
 482			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 483			            case TypeCode.Byte:
 484			            case TypeCode.SByte:
 485			            case TypeCode.Int16:
 486			            case TypeCode.Int32:
 487			            case TypeCode.Int64:
 488			            case TypeCode.UInt16:
 489			            case TypeCode.UInt32:
 490			            case TypeCode.UInt64:
 491			                return true;
 492			            default:
 493			                return false;
 494			        }
 495			    }
 496			
 497			    public static bool IsFloating(Type type) {
 498			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 499			            case TypeCode.Single:
 500			            case TypeCode.Double:
 501			                return true;
 502			            default:
 503			                return false;
 504			        }
 505			    }
 506			
 507			    public static Type GetNonNullableType(Type type) {
 508			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 509			                type.GetGenericArguments()[0] :
 510			                type;
 511			    }
 512			}
 513			
 514		
 515	}
 516			
 517			//-------- Scenario 3171
 518			namespace Scenario3171{
 519				
 520				public class Test
 521				{
 522			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "sbyteq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 523			    public static Expression sbyteq_ArrayIndex__() {
 524			       if(Main() != 0 ) {
 525			           throw new Exception();
 526			       } else { 
 527			           return Expression.Constant(0);
 528			       }
 529			    }
 530				public     static int Main()
 531				    {
 532				        Ext.StartCapture();
 533				        bool success = false;
 534				        try
 535				        {
 536				            success = check_sbyteq_ArrayIndex();
 537				        }
 538				        finally
 539				        {
 540				            Ext.StopCapture();
 541				        }
 542				        return success ? 0 : 1;
 543				    }
 544				
 545				    static bool check_sbyteq_ArrayIndex() {
 546				        return checkEx_sbyteq_ArrayIndex(null, -1) &
 547				            checkEx_sbyteq_ArrayIndex(null, 0) &
 548				            checkEx_sbyteq_ArrayIndex(null, 1) &
 549				
 550				            check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(0)) &
 551				            check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(1)) &
 552				            check_sbyteq_ArrayIndex(genArrsbyteq_ArrayIndex(5));
 553				    }
 554				
 555				    static sbyte?[] genArrsbyteq_ArrayIndex(int size) {
 556				        sbyte?[] vals = new sbyte?[] { 0, 1, -1, sbyte.MinValue, sbyte.MaxValue };
 557				        sbyte?[] result = new sbyte?[size];
 558				        for (int i = 0; i < size; i++) {
 559				            result[i] = vals[i % vals.Length];
 560				        }
 561				        return result;
 562				    }
 563				
 564				    static bool check_sbyteq_ArrayIndex(sbyte?[] val) {
 565				        bool success = checkEx_sbyteq_ArrayIndex(val, -1);
 566				        for (int i = 0; i < val.Length; i++) {
 567				            success &= check_sbyteq_ArrayIndex(val, 0);
 568				        }
 569				        success &= checkEx_sbyteq_ArrayIndex(val, val.Length);
 570				        return success;
 571				    }
 572				
 573				    static bool checkEx_sbyteq_ArrayIndex(sbyte?[] val, int index) {
 574				        try {
 575				            check_sbyteq_ArrayIndex(val, index);
 576				            Console.WriteLine("sbyteq_ArrayIndex[" + index + "] failed");
 577				            return false;
 578				        }
 579				        catch {
 580				            return true;
 581				        }
 582				    }
 583				
 584				    static bool check_sbyteq_ArrayIndex(sbyte?[] val, int index) {
 585				        Expression<Func<sbyte?>> e =
 586				            Expression.Lambda<Func<sbyte?>>(
 587				                Expression.ArrayIndex(Expression.Constant(val, typeof(sbyte?[])),
 588				                    Expression.Constant(index, typeof(int))),
 589				                new System.Collections.Generic.List<ParameterExpression>());
 590				        Func<sbyte?> f = e.Compile();
 591				        return object.Equals(f(), val[index]);
 592				    }
 593				}
 594			
 595			
 596			public  static class Ext {
 597			    public static void StartCapture() {
 598			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 599			//        m.Invoke(null, new object[] { "test.dll" });
 600			    }
 601			
 602			    public static void StopCapture() {
 603			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 604			//        m.Invoke(null, new object[0]);
 605			    }
 606			
 607			    public static bool IsIntegralOrEnum(Type type) {
 608			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 609			            case TypeCode.Byte:
 610			            case TypeCode.SByte:
 611			            case TypeCode.Int16:
 612			            case TypeCode.Int32:
 613			            case TypeCode.Int64:
 614			            case TypeCode.UInt16:
 615			            case TypeCode.UInt32:
 616			            case TypeCode.UInt64:
 617			                return true;
 618			            default:
 619			                return false;
 620			        }
 621			    }
 622			
 623			    public static bool IsFloating(Type type) {
 624			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 625			            case TypeCode.Single:
 626			            case TypeCode.Double:
 627			                return true;
 628			            default:
 629			                return false;
 630			        }
 631			    }
 632			
 633			    public static Type GetNonNullableType(Type type) {
 634			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 635			                type.GetGenericArguments()[0] :
 636			                type;
 637			    }
 638			}
 639			
 640		
 641	}
 642			
 643			//-------- Scenario 3172
 644			namespace Scenario3172{
 645				
 646				public class Test
 647				{
 648			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "shortq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 649			    public static Expression shortq_ArrayIndex__() {
 650			       if(Main() != 0 ) {
 651			           throw new Exception();
 652			       } else { 
 653			           return Expression.Constant(0);
 654			       }
 655			    }
 656				public     static int Main()
 657				    {
 658				        Ext.StartCapture();
 659				        bool success = false;
 660				        try
 661				        {
 662				            success = check_shortq_ArrayIndex();
 663				        }
 664				        finally
 665				        {
 666				            Ext.StopCapture();
 667				        }
 668				        return success ? 0 : 1;
 669				    }
 670				
 671				    static bool check_shortq_ArrayIndex() {
 672				        return checkEx_shortq_ArrayIndex(null, -1) &
 673				            checkEx_shortq_ArrayIndex(null, 0) &
 674				            checkEx_shortq_ArrayIndex(null, 1) &
 675				
 676				            check_shortq_ArrayIndex(genArrshortq_ArrayIndex(0)) &
 677				            check_shortq_ArrayIndex(genArrshortq_ArrayIndex(1)) &
 678				            check_shortq_ArrayIndex(genArrshortq_ArrayIndex(5));
 679				    }
 680				
 681				    static short?[] genArrshortq_ArrayIndex(int size) {
 682				        short?[] vals = new short?[] { 0, 1, -1, short.MinValue, short.MaxValue };
 683				        short?[] result = new short?[size];
 684				        for (int i = 0; i < size; i++) {
 685				            result[i] = vals[i % vals.Length];
 686				        }
 687				        return result;
 688				    }
 689				
 690				    static bool check_shortq_ArrayIndex(short?[] val) {
 691				        bool success = checkEx_shortq_ArrayIndex(val, -1);
 692				        for (int i = 0; i < val.Length; i++) {
 693				            success &= check_shortq_ArrayIndex(val, 0);
 694				        }
 695				        success &= checkEx_shortq_ArrayIndex(val, val.Length);
 696				        return success;
 697				    }
 698				
 699				    static bool checkEx_shortq_ArrayIndex(short?[] val, int index) {
 700				        try {
 701				            check_shortq_ArrayIndex(val, index);
 702				            Console.WriteLine("shortq_ArrayIndex[" + index + "] failed");
 703				            return false;
 704				        }
 705				        catch {
 706				            return true;
 707				        }
 708				    }
 709				
 710				    static bool check_shortq_ArrayIndex(short?[] val, int index) {
 711				        Expression<Func<short?>> e =
 712				            Expression.Lambda<Func<short?>>(
 713				                Expression.ArrayIndex(Expression.Constant(val, typeof(short?[])),
 714				                    Expression.Constant(index, typeof(int))),
 715				                new System.Collections.Generic.List<ParameterExpression>());
 716				        Func<short?> f = e.Compile();
 717				        return object.Equals(f(), val[index]);
 718				    }
 719				}
 720			
 721			
 722			public  static class Ext {
 723			    public static void StartCapture() {
 724			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 725			//        m.Invoke(null, new object[] { "test.dll" });
 726			    }
 727			
 728			    public static void StopCapture() {
 729			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 730			//        m.Invoke(null, new object[0]);
 731			    }
 732			
 733			    public static bool IsIntegralOrEnum(Type type) {
 734			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 735			            case TypeCode.Byte:
 736			            case TypeCode.SByte:
 737			            case TypeCode.Int16:
 738			            case TypeCode.Int32:
 739			            case TypeCode.Int64:
 740			            case TypeCode.UInt16:
 741			            case TypeCode.UInt32:
 742			            case TypeCode.UInt64:
 743			                return true;
 744			            default:
 745			                return false;
 746			        }
 747			    }
 748			
 749			    public static bool IsFloating(Type type) {
 750			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 751			            case TypeCode.Single:
 752			            case TypeCode.Double:
 753			                return true;
 754			            default:
 755			                return false;
 756			        }
 757			    }
 758			
 759			    public static Type GetNonNullableType(Type type) {
 760			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 761			                type.GetGenericArguments()[0] :
 762			                type;
 763			    }
 764			}
 765			
 766		
 767	}
 768			
 769			//-------- Scenario 3173
 770			namespace Scenario3173{
 771				
 772				public class Test
 773				{
 774			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "intq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 775			    public static Expression intq_ArrayIndex__() {
 776			       if(Main() != 0 ) {
 777			           throw new Exception();
 778			       } else { 
 779			           return Expression.Constant(0);
 780			       }
 781			    }
 782				public     static int Main()
 783				    {
 784				        Ext.StartCapture();
 785				        bool success = false;
 786				        try
 787				        {
 788				            success = check_intq_ArrayIndex();
 789				        }
 790				        finally
 791				        {
 792				            Ext.StopCapture();
 793				        }
 794				        return success ? 0 : 1;
 795				    }
 796				
 797				    static bool check_intq_ArrayIndex() {
 798				        return checkEx_intq_ArrayIndex(null, -1) &
 799				            checkEx_intq_ArrayIndex(null, 0) &
 800				            checkEx_intq_ArrayIndex(null, 1) &
 801				
 802				            check_intq_ArrayIndex(genArrintq_ArrayIndex(0)) &
 803				            check_intq_ArrayIndex(genArrintq_ArrayIndex(1)) &
 804				            check_intq_ArrayIndex(genArrintq_ArrayIndex(5));
 805				    }
 806				
 807				    static int?[] genArrintq_ArrayIndex(int size) {
 808				        int?[] vals = new int?[] { 0, 1, -1, int.MinValue, int.MaxValue };
 809				        int?[] result = new int?[size];
 810				        for (int i = 0; i < size; i++) {
 811				            result[i] = vals[i % vals.Length];
 812				        }
 813				        return result;
 814				    }
 815				
 816				    static bool check_intq_ArrayIndex(int?[] val) {
 817				        bool success = checkEx_intq_ArrayIndex(val, -1);
 818				        for (int i = 0; i < val.Length; i++) {
 819				            success &= check_intq_ArrayIndex(val, 0);
 820				        }
 821				        success &= checkEx_intq_ArrayIndex(val, val.Length);
 822				        return success;
 823				    }
 824				
 825				    static bool checkEx_intq_ArrayIndex(int?[] val, int index) {
 826				        try {
 827				            check_intq_ArrayIndex(val, index);
 828				            Console.WriteLine("intq_ArrayIndex[" + index + "] failed");
 829				            return false;
 830				        }
 831				        catch {
 832				            return true;
 833				        }
 834				    }
 835				
 836				    static bool check_intq_ArrayIndex(int?[] val, int index) {
 837				        Expression<Func<int?>> e =
 838				            Expression.Lambda<Func<int?>>(
 839				                Expression.ArrayIndex(Expression.Constant(val, typeof(int?[])),
 840				                    Expression.Constant(index, typeof(int))),
 841				                new System.Collections.Generic.List<ParameterExpression>());
 842				        Func<int?> f = e.Compile();
 843				        return object.Equals(f(), val[index]);
 844				    }
 845				}
 846			
 847			
 848			public  static class Ext {
 849			    public static void StartCapture() {
 850			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 851			//        m.Invoke(null, new object[] { "test.dll" });
 852			    }
 853			
 854			    public static void StopCapture() {
 855			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 856			//        m.Invoke(null, new object[0]);
 857			    }
 858			
 859			    public static bool IsIntegralOrEnum(Type type) {
 860			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 861			            case TypeCode.Byte:
 862			            case TypeCode.SByte:
 863			            case TypeCode.Int16:
 864			            case TypeCode.Int32:
 865			            case TypeCode.Int64:
 866			            case TypeCode.UInt16:
 867			            case TypeCode.UInt32:
 868			            case TypeCode.UInt64:
 869			                return true;
 870			            default:
 871			                return false;
 872			        }
 873			    }
 874			
 875			    public static bool IsFloating(Type type) {
 876			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 877			            case TypeCode.Single:
 878			            case TypeCode.Double:
 879			                return true;
 880			            default:
 881			                return false;
 882			        }
 883			    }
 884			
 885			    public static Type GetNonNullableType(Type type) {
 886			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
 887			                type.GetGenericArguments()[0] :
 888			                type;
 889			    }
 890			}
 891			
 892		
 893	}
 894			
 895			//-------- Scenario 3174
 896			namespace Scenario3174{
 897				
 898				public class Test
 899				{
 900			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "longq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
 901			    public static Expression longq_ArrayIndex__() {
 902			       if(Main() != 0 ) {
 903			           throw new Exception();
 904			       } else { 
 905			           return Expression.Constant(0);
 906			       }
 907			    }
 908				public     static int Main()
 909				    {
 910				        Ext.StartCapture();
 911				        bool success = false;
 912				        try
 913				        {
 914				            success = check_longq_ArrayIndex();
 915				        }
 916				        finally
 917				        {
 918				            Ext.StopCapture();
 919				        }
 920				        return success ? 0 : 1;
 921				    }
 922				
 923				    static bool check_longq_ArrayIndex() {
 924				        return checkEx_longq_ArrayIndex(null, -1) &
 925				            checkEx_longq_ArrayIndex(null, 0) &
 926				            checkEx_longq_ArrayIndex(null, 1) &
 927				
 928				            check_longq_ArrayIndex(genArrlongq_ArrayIndex(0)) &
 929				            check_longq_ArrayIndex(genArrlongq_ArrayIndex(1)) &
 930				            check_longq_ArrayIndex(genArrlongq_ArrayIndex(5));
 931				    }
 932				
 933				    static long?[] genArrlongq_ArrayIndex(int size) {
 934				        long?[] vals = new long?[] { 0, 1, -1, long.MinValue, long.MaxValue };
 935				        long?[] result = new long?[size];
 936				        for (int i = 0; i < size; i++) {
 937				            result[i] = vals[i % vals.Length];
 938				        }
 939				        return result;
 940				    }
 941				
 942				    static bool check_longq_ArrayIndex(long?[] val) {
 943				        bool success = checkEx_longq_ArrayIndex(val, -1);
 944				        for (int i = 0; i < val.Length; i++) {
 945				            success &= check_longq_ArrayIndex(val, 0);
 946				        }
 947				        success &= checkEx_longq_ArrayIndex(val, val.Length);
 948				        return success;
 949				    }
 950				
 951				    static bool checkEx_longq_ArrayIndex(long?[] val, int index) {
 952				        try {
 953				            check_longq_ArrayIndex(val, index);
 954				            Console.WriteLine("longq_ArrayIndex[" + index + "] failed");
 955				            return false;
 956				        }
 957				        catch {
 958				            return true;
 959				        }
 960				    }
 961				
 962				    static bool check_longq_ArrayIndex(long?[] val, int index) {
 963				        Expression<Func<long?>> e =
 964				            Expression.Lambda<Func<long?>>(
 965				                Expression.ArrayIndex(Expression.Constant(val, typeof(long?[])),
 966				                    Expression.Constant(index, typeof(int))),
 967				                new System.Collections.Generic.List<ParameterExpression>());
 968				        Func<long?> f = e.Compile();
 969				        return object.Equals(f(), val[index]);
 970				    }
 971				}
 972			
 973			
 974			public  static class Ext {
 975			    public static void StartCapture() {
 976			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 977			//        m.Invoke(null, new object[] { "test.dll" });
 978			    }
 979			
 980			    public static void StopCapture() {
 981			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
 982			//        m.Invoke(null, new object[0]);
 983			    }
 984			
 985			    public static bool IsIntegralOrEnum(Type type) {
 986			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
 987			            case TypeCode.Byte:
 988			            case TypeCode.SByte:
 989			            case TypeCode.Int16:
 990			            case TypeCode.Int32:
 991			            case TypeCode.Int64:
 992			            case TypeCode.UInt16:
 993			            case TypeCode.UInt32:
 994			            case TypeCode.UInt64:
 995			                return true;
 996			            default:
 997			                return false;
 998			        }
 999			    }
1000			
1001			    public static bool IsFloating(Type type) {
1002			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
1003			            case TypeCode.Single:
1004			            case TypeCode.Double:
1005			                return true;
1006			            default:
1007			                return false;
1008			        }
1009			    }
1010			
1011			    public static Type GetNonNullableType(Type type) {
1012			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
1013			                type.GetGenericArguments()[0] :
1014			                type;
1015			    }
1016			}
1017			
1018		
1019	}
1020			
1021			//-------- Scenario 3175
1022			namespace Scenario3175{
1023				
1024				public class Test
1025				{
1026			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "floatq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
1027			    public static Expression floatq_ArrayIndex__() {
1028			       if(Main() != 0 ) {
1029			           throw new Exception();
1030			       } else { 
1031			           return Expression.Constant(0);
1032			       }
1033			    }
1034				public     static int Main()
1035				    {
1036				        Ext.StartCapture();
1037				        bool success = false;
1038				        try
1039				        {
1040				            success = check_floatq_ArrayIndex();
1041				        }
1042				        finally
1043				        {
1044				            Ext.StopCapture();
1045				        }
1046				        return success ? 0 : 1;
1047				    }
1048				
1049				    static bool check_floatq_ArrayIndex() {
1050				        return checkEx_floatq_ArrayIndex(null, -1) &
1051				            checkEx_floatq_ArrayIndex(null, 0) &
1052				            checkEx_floatq_ArrayIndex(null, 1) &
1053				
1054				            check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(0)) &
1055				            check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(1)) &
1056				            check_floatq_ArrayIndex(genArrfloatq_ArrayIndex(5));
1057				    }
1058				
1059				    static float?[] genArrfloatq_ArrayIndex(int size) {
1060				        float?[] vals = new float?[] { 0, 1, -1, float.MinValue, float.MaxValue, float.Epsilon, float.NegativeInfinity, float.PositiveInfinity, float.NaN };
1061				        float?[] result = new float?[size];
1062				        for (int i = 0; i < size; i++) {
1063				            result[i] = vals[i % vals.Length];
1064				        }
1065				        return result;
1066				    }
1067				
1068				    static bool check_floatq_ArrayIndex(float?[] val) {
1069				        bool success = checkEx_floatq_ArrayIndex(val, -1);
1070				        for (int i = 0; i < val.Length; i++) {
1071				            success &= check_floatq_ArrayIndex(val, 0);
1072				        }
1073				        success &= checkEx_floatq_ArrayIndex(val, val.Length);
1074				        return success;
1075				    }
1076				
1077				    static bool checkEx_floatq_ArrayIndex(float?[] val, int index) {
1078				        try {
1079				            check_floatq_ArrayIndex(val, index);
1080				            Console.WriteLine("floatq_ArrayIndex[" + index + "] failed");
1081				            return false;
1082				        }
1083				        catch {
1084				            return true;
1085				        }
1086				    }
1087				
1088				    static bool check_floatq_ArrayIndex(float?[] val, int index) {
1089				        Expression<Func<float?>> e =
1090				            Expression.Lambda<Func<float?>>(
1091				                Expression.ArrayIndex(Expression.Constant(val, typeof(float?[])),
1092				                    Expression.Constant(index, typeof(int))),
1093				                new System.Collections.Generic.List<ParameterExpression>());
1094				        Func<float?> f = e.Compile();
1095				        return object.Equals(f(), val[index]);
1096				    }
1097				}
1098			
1099			
1100			public  static class Ext {
1101			    public static void StartCapture() {
1102			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
1103			//        m.Invoke(null, new object[] { "test.dll" });
1104			    }
1105			
1106			    public static void StopCapture() {
1107			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
1108			//        m.Invoke(null, new object[0]);
1109			    }
1110			
1111			    public static bool IsIntegralOrEnum(Type type) {
1112			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
1113			            case TypeCode.Byte:
1114			            case TypeCode.SByte:
1115			            case TypeCode.Int16:
1116			            case TypeCode.Int32:
1117			            case TypeCode.Int64:
1118			            case TypeCode.UInt16:
1119			            case TypeCode.UInt32:
1120			            case TypeCode.UInt64:
1121			                return true;
1122			            default:
1123			                return false;
1124			        }
1125			    }
1126			
1127			    public static bool IsFloating(Type type) {
1128			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
1129			            case TypeCode.Single:
1130			            case TypeCode.Double:
1131			                return true;
1132			            default:
1133			                return false;
1134			        }
1135			    }
1136			
1137			    public static Type GetNonNullableType(Type type) {
1138			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
1139			                type.GetGenericArguments()[0] :
1140			                type;
1141			    }
1142			}
1143			
1144		
1145	}
1146			
1147			//-------- Scenario 3176
1148			namespace Scenario3176{
1149				
1150				public class Test
1151				{
1152			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "doubleq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
1153			    public static Expression doubleq_ArrayIndex__() {
1154			       if(Main() != 0 ) {
1155			           throw new Exception();
1156			       } else { 
1157			           return Expression.Constant(0);
1158			       }
1159			    }
1160				public     static int Main()
1161				    {
1162				        Ext.StartCapture();
1163				        bool success = false;
1164				        try
1165				        {
1166				            success = check_doubleq_ArrayIndex();
1167				        }
1168				        finally
1169				        {
1170				            Ext.StopCapture();
1171				        }
1172				        return success ? 0 : 1;
1173				    }
1174				
1175				    static bool check_doubleq_ArrayIndex() {
1176				        return checkEx_doubleq_ArrayIndex(null, -1) &
1177				            checkEx_doubleq_ArrayIndex(null, 0) &
1178				            checkEx_doubleq_ArrayIndex(null, 1) &
1179				
1180				            check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(0)) &
1181				            check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(1)) &
1182				            check_doubleq_ArrayIndex(genArrdoubleq_ArrayIndex(5));
1183				    }
1184				
1185				    static double?[] genArrdoubleq_ArrayIndex(int size) {
1186				        double?[] vals = new double?[] { 0, 1, -1, double.MinValue, double.MaxValue, double.Epsilon, double.NegativeInfinity, double.PositiveInfinity, double.NaN };
1187				        double?[] result = new double?[size];
1188				        for (int i = 0; i < size; i++) {
1189				            result[i] = vals[i % vals.Length];
1190				        }
1191				        return result;
1192				    }
1193				
1194				    static bool check_doubleq_ArrayIndex(double?[] val) {
1195				        bool success = checkEx_doubleq_ArrayIndex(val, -1);
1196				        for (int i = 0; i < val.Length; i++) {
1197				            success &= check_doubleq_ArrayIndex(val, 0);
1198				        }
1199				        success &= checkEx_doubleq_ArrayIndex(val, val.Length);
1200				        return success;
1201				    }
1202				
1203				    static bool checkEx_doubleq_ArrayIndex(double?[] val, int index) {
1204				        try {
1205				            check_doubleq_ArrayIndex(val, index);
1206				            Console.WriteLine("doubleq_ArrayIndex[" + index + "] failed");
1207				            return false;
1208				        }
1209				        catch {
1210				            return true;
1211				        }
1212				    }
1213				
1214				    static bool check_doubleq_ArrayIndex(double?[] val, int index) {
1215				        Expression<Func<double?>> e =
1216				            Expression.Lambda<Func<double?>>(
1217				                Expression.ArrayIndex(Expression.Constant(val, typeof(double?[])),
1218				                    Expression.Constant(index, typeof(int))),
1219				                new System.Collections.Generic.List<ParameterExpression>());
1220				        Func<double?> f = e.Compile();
1221				        return object.Equals(f(), val[index]);
1222				    }
1223				}
1224			
1225			
1226			public  static class Ext {
1227			    public static void StartCapture() {
1228			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StartCaptureToFile", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
1229			//        m.Invoke(null, new object[] { "test.dll" });
1230			    }
1231			
1232			    public static void StopCapture() {
1233			//        MethodInfo m = Assembly.GetAssembly(typeof(Expression)).GetType("System.Linq.Expressions.ExpressionCompiler").GetMethod("StopCapture", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
1234			//        m.Invoke(null, new object[0]);
1235			    }
1236			
1237			    public static bool IsIntegralOrEnum(Type type) {
1238			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
1239			            case TypeCode.Byte:
1240			            case TypeCode.SByte:
1241			            case TypeCode.Int16:
1242			            case TypeCode.Int32:
1243			            case TypeCode.Int64:
1244			            case TypeCode.UInt16:
1245			            case TypeCode.UInt32:
1246			            case TypeCode.UInt64:
1247			                return true;
1248			            default:
1249			                return false;
1250			        }
1251			    }
1252			
1253			    public static bool IsFloating(Type type) {
1254			        switch (Type.GetTypeCode(GetNonNullableType(type))) {
1255			            case TypeCode.Single:
1256			            case TypeCode.Double:
1257			                return true;
1258			            default:
1259			                return false;
1260			        }
1261			    }
1262			
1263			    public static Type GetNonNullableType(Type type) {
1264			        return type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>) ?
1265			                type.GetGenericArguments()[0] :
1266			                type;
1267			    }
1268			}
1269			
1270		
1271	}
1272			
1273			//-------- Scenario 3177
1274			namespace Scenario3177{
1275				
1276				public class Test
1277				{
1278			    [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "decimalq_ArrayIndex__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
1279			    public static Expression decimalq_ArrayIndex__() {
1280			       if(Main() != 0 ) {
1281			           throw new Exception();
1282			       } else { 
1283			           return Expression.Constant(0);
1284			       }
1285			    }
1286				public     static int Main()
1287				    {
1288				        Ext.StartCapture();
1289				        bool success = false;
1290				        try
1291				        {
1292				            success = check_decimalq_ArrayIndex();
1293				        }
1294				        finally
1295				        {
1296				            Ext.StopCapture();
1297				        }
1298				        return success ? 0 : 1;
1299				    }
1300				
1301				    static bool check_decimalq_ArrayIndex() {
1302				        return checkEx_decimalq_ArrayIndex(null, -1) &
1303				            checkEx_decimalq_ArrayIndex(null, 0) &
1304				            checkEx_decimalq_ArrayIndex(null, 1) &
1305				
1306				            check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(0)) &
1307				            check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(1)) &
1308				            check_decimalq_ArrayIndex(genArrdecimalq_ArrayIndex(5));
1309				    }
1310				
1311				    static decimal?[] genArrdecimalq_ArrayIndex(int size) {
1312				        decimal?[] vals = new decimal?[] { decimal.Zero, decimal.One, decimal.MinusOne, decimal.MinValue, decimal.MaxValue };
1313				        decimal?[] result = new decimal?[size];
1314				        for (int i = 0; i < size; i++) {
1315				            result[i] = vals[i % vals.Length];
1316				        }
1317				        return result;
1318				    }
1319				
1320				    static bool check_decimalq_ArrayIndex(decimal?[] val) {
1321				        bool success = checkEx_decimalq_ArrayIndex(val, -1);
1322				        for (int i = 0; i < val.Length; i++) {
1323				            success &= check_decimalq_ArrayIndex(val, 0);
1324				        }
1325				        success &= checkEx_decimalq_ArrayIndex(val, val.Length);
1326				        return success;
1327				    }
1328				
1329				    static bool checkEx_decimalq_ArrayIndex(decimal?[] val, int index) {
1330				        try {
1331				            check_decimalq_ArrayIndex(val, index);
1332				            Console.WriteLine("decimalq_ArrayIndex[" + index + "] failed");
1333				            return false;
1334				        }
1335				        catch {
1336				            return true;
1337				        }
1338				    }
1339				
1340				    static bool check_decimalq_ArrayIndex(decimal?[] val, int index) {
1341				        Expression<Func<decimal?>> e =
1342				            Expression.Lambda<Func<decimal?>>(
1343				                Expression.ArrayIndex(Expression.Constant(val, typeof(decimal?[])),
1344				                    Expression.Constant(index, typeof(int))),
1345				                new System.Collections.Generic.List<ParameterExpression>());
1346				        Func<decimal?> f = e.Compile();
1347				        return object.Equals(f(), val[index]);
1348				    }
1349				}
1350			
1351			
1352			public  static class Ext {
1353			    public static void StartCapture() {
1354			// …

Large files files are truncated, but you can click here to view the full file