summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-to-int-err.js
blob: fe367827b0b63357208cb20446c2186f6552c6ba (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-string.prototype.substr
es6id: B.2.3.1
description: >
    Behavior when "length" integer conversion triggers an abrupt completion
info: |
    [...]
    3. Let intStart be ? ToInteger(start).
features: [Symbol]
---*/

var symbol = Symbol('');
var len = {
  valueOf: function() {
    throw new Test262Error();
  }
};

assert.throws(Test262Error, function() {
  ''.substr(0, len);
});

assert.throws(TypeError, function() {
  ''.substr(0, symbol);
});

reportCompare(0, 0);