diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js')
-rw-r--r-- | js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js new file mode 100644 index 0000000000..c690928c09 --- /dev/null +++ b/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js @@ -0,0 +1,30 @@ +// Copyright (C) 2016 Jordan Harband. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-string.prototype.padstart +description: > + String#padStart should fail if given a null or undefined value, + or an object not coercible to a string. +author: Jordan Harband +---*/ + +assert.throws(TypeError, function() { + String.prototype.padStart.call(null); +}); + +assert.throws(TypeError, function() { + String.prototype.padStart.call(undefined); +}); + +var notCoercible = { + toString: function() { + throw new Test262Error('attempted toString'); + } +}; + +assert.throws(Test262Error, function() { + String.prototype.padStart.call(notCoercible); +}); + +reportCompare(0, 0); |