From e0a06a0eb8497d9921c1533f478ea92e951c8f2a Mon Sep 17 00:00:00 2001 From: G-Lee1031 Date: Mon, 19 Jan 2026 16:43:12 +0900 Subject: [PATCH] Added coverage for abrupt completion where ToString throws because of getter --- .../prototype/toString/tostring-get-throws.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/built-ins/Error/prototype/toString/tostring-get-throws.js diff --git a/test/built-ins/Error/prototype/toString/tostring-get-throws.js b/test/built-ins/Error/prototype/toString/tostring-get-throws.js new file mode 100644 index 00000000000..6ddaf9de854 --- /dev/null +++ b/test/built-ins/Error/prototype/toString/tostring-get-throws.js @@ -0,0 +1,25 @@ +// Copyright (C) 2026 Garham Lee. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-error.prototype.tostring +description: > + Error.prototype.toString should throw when name or message getter throws +info: | + Error.prototype.toString ( ) + + 1. Let _O_ be the *this* value. + + 3. Let _name_ be ? Get(_O_, *"name"*). + + 5. Let _msg_ be ? Get(_O_, *"message"*). +---*/ +//Check #1 +assert.throws(Test262Error, function() { + Error.prototype.toString.call({get name () {throw new Test262Error;}}); +}, "name field getter should throw to cover abrupt completion return case in step 3") + +//Check #2 +assert.throws(Test262Error, function() { + Error.prototype.toString.call({get message () {throw new Test262Error;}}); +}, "message field getter should throw to cover abrupt completion return case in step 5")