PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 2ms

/IronPython_Main/Runtime/Tests/ETScenariosCSLinq/CSLinq/ExpressionCompiler/array_BackSl_index_BackSl_test0.cs

#
C# | 10651 lines | 9016 code | 1420 blank | 215 comment | 846 complexity | 58772e2b18712478e6f2280faba6af92 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0

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

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

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