PageRenderTime 36ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

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

#
C# | 80 lines | 65 code | 13 blank | 2 comment | 8 complexity | 2ee13e10a5284e45ed07cefd53d120bf 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
  1. #if !CLR2 // inline linq expressions
  2. using System.Linq.Expressions;
  3. using System;
  4. namespace ExpressionCompiler {
  5. //-------- Scenario 3013
  6. namespace Scenario3013{
  7. public class BaseClass
  8. {
  9. }
  10. public class Test
  11. {
  12. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "test1__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  13. public static Expression test1__() {
  14. if(Main() != 0 ) {
  15. throw new Exception();
  16. } else {
  17. return Expression.Constant(0);
  18. }
  19. }
  20. public static int Main()
  21. {
  22. bool res = Test1();
  23. return res ? 0 : 1;
  24. }
  25. public static bool Test1()
  26. {
  27. Expression<Func<object[]>> expr = () => (object[])new BaseClass[1];
  28. expr.Compile();
  29. return true;
  30. }
  31. }
  32. }
  33. //-------- Scenario 3014
  34. namespace Scenario3014{
  35. public class Test
  36. {
  37. [ETUtils.TestAttribute(ETUtils.TestState.Enabled, "test2__", new string[] { "positive", "cslinq", "FullTrustOnly","Pri1" })]
  38. public static Expression test2__() {
  39. if(Main() != 0 ) {
  40. throw new Exception();
  41. } else {
  42. return Expression.Constant(0);
  43. }
  44. }
  45. public static int Main()
  46. {
  47. bool res = Test2();
  48. return res ? 0 : 1;
  49. }
  50. public static bool Test2()
  51. {
  52. Expression<Func<int,object>> x = c => new double[c,c];
  53. if (!x.ToString().Equals("c => new System.Double[,](c, c)"))
  54. {
  55. return false;
  56. }
  57. object y = x.Compile()(2);
  58. if (!y.ToString().Equals("System.Double[,]"))
  59. {
  60. return false;
  61. }
  62. return true;
  63. }
  64. }
  65. }
  66. }
  67. #endif