async-jit-bugs.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Copyright (c) ChakraCore Project Contributors. All rights reserved.
  4. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  5. //-------------------------------------------------------------------------------------------------------
  6. function testOne() {
  7. const v2 = [13.37,13.37,13.37,13.37,13.37];
  8. async function v4(v5,v6,v7,v8) {
  9. const v10 = 0;
  10. for (let v14 = 0; v14 < 8; v14++) {
  11. v5["vEBD7ei78q"] = v14;
  12. }
  13. for (let v16 = 1; v16 < 1337; v16++) {
  14. const v17 = v2.__proto__;
  15. const v23 = [13.37,13.37,-2.2250738585072014e-308,13.37,13.37];
  16. const v24 = v23.length;
  17. const v25 = "-4294967296";
  18. const v26 = 7;
  19. function* v28(v29,v30,v31,...v32) {}
  20. let v33 = -2.2250738585072014e-308;
  21. const v34 = v28(v33,Object,Object);
  22. const v35 = 13.37;
  23. const v36 = 2384357829;
  24. const v37 = await "-4294967296";
  25. const v38 = --v33;
  26. }
  27. const v39 = 128;
  28. }
  29. return v4("vEBD7ei78q");
  30. }
  31. // BugIssue #7034
  32. function testTwo() {
  33. let finallyCount = 0;
  34. let throwCount = 0;
  35. async function asyncFinally() {
  36. for (let i = 0; i < 1000; ++i){
  37. try {
  38. if (i > 170) {
  39. ++throwCount;
  40. throw 1;
  41. }
  42. }
  43. finally {
  44. ++finallyCount;
  45. }
  46. }
  47. }
  48. return asyncFinally ().catch((e) => {
  49. if (throwCount != 1) {
  50. throw new Error ("Wrong number of throws within async function expected 1 but received " + throwCount);
  51. }
  52. if (e != 1) {
  53. throw new Error ("Wrong value thrown from async function expected 1 but received " + e);
  54. }
  55. if (finallyCount != 172) {
  56. throw new Error ("Wrong number of finally calls from async function expected 172 but received " + finallyCount);
  57. }
  58. });
  59. }
  60. function testThree() {
  61. let finallyCount = 0;
  62. let throwCount = 0;
  63. async function asyncFinallyAwait() {
  64. for (let i = 0; i < 1000; ++i){
  65. try {
  66. if (i > 170) {
  67. ++throwCount;
  68. throw 1;
  69. }
  70. }
  71. finally {
  72. await 5;
  73. ++finallyCount;
  74. }
  75. }
  76. }
  77. return asyncFinallyAwait().catch((e) => {
  78. if (throwCount != 1) {
  79. throw new Error ("Wrong number of throws within async function expected 1 but received " + throwCount);
  80. }
  81. if (e != 1) {
  82. throw new Error ("Wrong value thrown from async function expected 1 but received " + e);
  83. }
  84. if (finallyCount != 172) {
  85. throw new Error ("Wrong number of finally calls from async function expected 172 but received " + finallyCount);
  86. }
  87. });
  88. }
  89. // BugIssue #7016
  90. function testFour()
  91. {
  92. async function test() {
  93. var i8 = new Int8Array(256);
  94. var IntArr0 = [];
  95. for (var _strvar1 of i8) {
  96. for (var _strvar1 of IntArr0) {}
  97. }
  98. }
  99. return test();
  100. }
  101. Promise.all([testOne(), testTwo(), testThree(), testFour()]).then(()=>{print("pass")}, (e)=>{print (e)});