PageRenderTime 51ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
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

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

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