StackOverflow.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // //-------------------------------------------------------------------------------------------------------
  2. // // Copyright (C) Microsoft. All rights reserved.
  3. // // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. // //-------------------------------------------------------------------------------------------------------
  5. WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");
  6. var tests = [
  7. {
  8. name: "plain recursive call with modified arguments",
  9. body: function () {
  10. function recursive(a) {
  11. recursive(a + 1);
  12. }
  13. try {
  14. recursive(42);
  15. assert(false); // should never reach this line
  16. }
  17. catch (e) {
  18. assert.areNotEqual(-1, e.message.indexOf("Out of stack space"), "Should be SO exception");
  19. }
  20. }
  21. },
  22. {
  23. name: "plain recursive call with no arguments",
  24. body: function () {
  25. function recursive() {
  26. recursive();
  27. }
  28. try {
  29. recursive();
  30. assert(false); // should never reach this line
  31. }
  32. catch (e) {
  33. assert.areNotEqual(-1, e.message.indexOf("Out of stack space"), "Should be SO exception");
  34. }
  35. }
  36. },
  37. {
  38. name: "recursive call to getter via proxy",
  39. body: function () {
  40. var obj = {};
  41. var handler = {
  42. get: function () {
  43. return obj.x;
  44. }
  45. };
  46. obj = new Proxy(obj, handler);
  47. try {
  48. var y = obj.x;
  49. assert(false); // should never reach this line
  50. }
  51. catch (e) {
  52. assert.areNotEqual(-1, e.message.indexOf("Out of stack space"), "Should be SO exception");
  53. }
  54. }
  55. },
  56. ];
  57. testRunner.runTests(tests, { verbose: false /*so no need to provide baseline*/ });