mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 06:20:37 +02:00
36 lines
766 B
JavaScript
36 lines
766 B
JavaScript
// Copyright (C) 2020 Alexey Shvayka. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
/*---
|
|
esid: sec-json.stringify
|
|
description: >
|
|
Stack overflow due to infinite recursion in replacer throws an expected error.
|
|
---*/
|
|
|
|
var getStackOverflowError = function() {
|
|
try {
|
|
return getStackOverflowError();
|
|
} catch (err) {
|
|
return err;
|
|
}
|
|
};
|
|
|
|
var StackOverflowError = getStackOverflowError().constructor;
|
|
|
|
var obj = {};
|
|
var objReplacer = function() {
|
|
return {key: obj};
|
|
};
|
|
|
|
assert.throws(StackOverflowError, function() {
|
|
JSON.stringify(null, objReplacer);
|
|
});
|
|
|
|
var arr = [];
|
|
var arrReplacer = function() {
|
|
return [arr];
|
|
};
|
|
|
|
assert.throws(StackOverflowError, function() {
|
|
JSON.stringify(null, arrReplacer);
|
|
});
|