summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/String/prototype/padStart/exception-not-object-coercible.js
blob: c690928c09bf1f655355932dcd696a9ef4149a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);