summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/annexB/built-ins/String/prototype/substr/start-negative.js
blob: de56b29e68e7dc13592e4814dcbb6b6639148eec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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 "start" is a negative number
info: |
    [...]
    6. If intStart < 0, let intStart be max(size + intStart, 0).
---*/

assert.sameValue('abc'.substr(-1), 'c');
assert.sameValue('abc'.substr(-2), 'bc');
assert.sameValue('abc'.substr(-3), 'abc');
assert.sameValue('abc'.substr(-4), 'abc', 'size + intStart < 0');

assert.sameValue('abc'.substr(-1.1), 'c', 'floating point rounding semantics');

reportCompare(0, 0);