diff --git a/test/intl402/NumberFormat/prototype/format/this-value-not-numberformat.js b/test/intl402/NumberFormat/prototype/format/this-value-not-numberformat.js new file mode 100644 index 0000000000000000000000000000000000000000..50e9c2ac077df815112688c44587d5c093307eaf --- /dev/null +++ b/test/intl402/NumberFormat/prototype/format/this-value-not-numberformat.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Ujjwal Sharma. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-intl.numberformat.prototype.format +description: > + Tests that Intl.NumberFormat.prototype.format throws a TypeError + if called on a non-object value or an object that hasn't been + initialized as a NumberFormat. +---*/ + +const invalidTargets = [undefined, null, true, 0, 'NumberFormat', [], {}, Symbol()]; +const fn = Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'format').get; + +invalidTargets.forEach(target => { + assert.throws( + TypeError, + () => fn.call(target), + `Calling format getter on ${target} was not rejected.` + ); +}); diff --git a/test/intl402/NumberFormat/prototype/formatToParts/this-has-not-internal-throws.js b/test/intl402/NumberFormat/prototype/formatToParts/this-has-not-internal-throws.js deleted file mode 100644 index c478c92c5c1105e47d95f5f8efe2b3989042a88d..0000000000000000000000000000000000000000 --- a/test/intl402/NumberFormat/prototype/formatToParts/this-has-not-internal-throws.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2016 Mozilla Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: > - Throws a TypeError if this is not a NumberFormat object ----*/ - -var formatToParts = Intl.NumberFormat.prototype.formatToParts; - -assert.throws(TypeError, function() { - formatToParts.call({}); -}, "{}"); - -assert.throws(TypeError, function() { - formatToParts.call(new Number()); -}, "new Number()"); diff --git a/test/intl402/NumberFormat/prototype/formatToParts/this-is-not-object-throws.js b/test/intl402/NumberFormat/prototype/formatToParts/this-is-not-object-throws.js deleted file mode 100644 index def58e3d541eea3cb8d2968bc85928330918160c..0000000000000000000000000000000000000000 --- a/test/intl402/NumberFormat/prototype/formatToParts/this-is-not-object-throws.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2016 Mozilla Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Throws a TypeError if this is not Object -features: [Symbol] ----*/ - -var formatToParts = Intl.NumberFormat.prototype.formatToParts; - -assert.throws(TypeError, function() { - formatToParts.call(undefined); -}, "undefined"); - -assert.throws(TypeError, function() { - formatToParts.call(null); -}, "null"); - -assert.throws(TypeError, function() { - formatToParts.call(42); -}, "number"); - -assert.throws(TypeError, function() { - formatToParts.call("foo"); -}, "string"); - -assert.throws(TypeError, function() { - formatToParts.call(false); -}, "false"); - -assert.throws(TypeError, function() { - formatToParts.call(true); -}, "true"); - -var s = Symbol('1'); -assert.throws(TypeError, function() { - formatToParts.call(s); -}, "symbol"); - diff --git a/test/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js b/test/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js new file mode 100644 index 0000000000000000000000000000000000000000..2bba25c1f7a8326a6c43778b498129ed8c852e56 --- /dev/null +++ b/test/intl402/NumberFormat/prototype/formatToParts/this-value-not-numberformat.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Ujjwal Sharma. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.NumberFormat.prototype.formatToParts +description: > + Tests that Intl.NumberFormat.prototype.formatToParts throws a + TypeError if called on a non-object value or an object that hasn't + been initialized as a NumberFormat. +---*/ + +const invalidTargets = [undefined, null, true, 0, 'NumberFormat', [], {}, Symbol()]; +const fn = Intl.NumberFormat.prototype.formatToParts; + +invalidTargets.forEach(target => { + assert.throws( + TypeError, + () => fn.call(target), + `Calling formatToParts on ${target} was not rejected.` + ); +}); diff --git a/test/intl402/NumberFormat/prototype/resolvedOptions/this-value-not-numberformat.js b/test/intl402/NumberFormat/prototype/resolvedOptions/this-value-not-numberformat.js new file mode 100644 index 0000000000000000000000000000000000000000..bed737badd357a40fddc899e9b317bfa29a08f57 --- /dev/null +++ b/test/intl402/NumberFormat/prototype/resolvedOptions/this-value-not-numberformat.js @@ -0,0 +1,21 @@ +// Copyright (C) 2018 Ujjwal Sharma. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.NumberFormat.prototype.resolvedOptions +description: > + Tests that Intl.NumberFormat.prototype.resolvedOptions throws a + TypeError if called on a non-object value or an object that hasn't + been initialized as a NumberFormat. +---*/ + +const invalidTargets = [undefined, null, true, 0, 'NumberFormat', [], {}, Symbol()]; +const fn = Intl.NumberFormat.prototype.resolvedOptions; + +invalidTargets.forEach(target => { + assert.throws( + TypeError, + () => fn.call(target), + `Calling resolvedOptions on ${target} was not rejected.` + ); +}); diff --git a/test/intl402/NumberFormat/prototype/this-value-not-numberformat.js b/test/intl402/NumberFormat/prototype/this-value-not-numberformat.js deleted file mode 100644 index a5bfcbddc9e80df07d2174b9aa6466a3b4700f5c..0000000000000000000000000000000000000000 --- a/test/intl402/NumberFormat/prototype/this-value-not-numberformat.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 Mozilla Corporation. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -es5id: 11.3_b -description: > - Tests that Intl.NumberFormat.prototype functions throw a - TypeError if called on a non-object value or an object that hasn't - been initialized as a NumberFormat. -author: Norbert Lindenberg ----*/ - -var functions = { - "format getter": Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, "format").get, - formatToParts: Intl.NumberFormat.prototype.formatToParts, - resolvedOptions: Intl.NumberFormat.prototype.resolvedOptions -}; -var invalidTargets = [undefined, null, true, 0, "NumberFormat", [], {}, Symbol()]; - -Object.getOwnPropertyNames(functions).forEach(function (functionName) { - var f = functions[functionName]; - invalidTargets.forEach(function (target) { - assert.throws(TypeError, function() { - f.call(target); - }, "Calling " + functionName + " on " + target + " was not rejected."); - }); -});