diff options
Diffstat (limited to 'js/src/tests/ecma_5/extensions/array-toString-recursion.js')
-rw-r--r-- | js/src/tests/ecma_5/extensions/array-toString-recursion.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/js/src/tests/ecma_5/extensions/array-toString-recursion.js b/js/src/tests/ecma_5/extensions/array-toString-recursion.js new file mode 100644 index 000000000..aa5d856c3 --- /dev/null +++ b/js/src/tests/ecma_5/extensions/array-toString-recursion.js @@ -0,0 +1,46 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 635389; +var summary = 'Infinite recursion via [].{toString,toLocaleString,join}'; + +print(BUGNUMBER + ": " + summary); + +/************** + * BEGIN TEST * + **************/ + +try +{ + var x = []; + x.join = Array.prototype.toString; + "" + x; + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +try +{ + var x = { toString: Array.prototype.toString, join: Array.prototype.toString }; + "" + x; + throw new Error("should have thrown"); +} +catch (e) +{ + assertEq(e instanceof InternalError, true, + "should have thrown for over-recursion"); +} + +/******************************************************************************/ + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("All tests passed!"); |