diff options
Diffstat (limited to 'js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js')
-rw-r--r-- | js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js new file mode 100644 index 0000000000..48e90b1aac --- /dev/null +++ b/js/src/tests/test262/annexB/built-ins/String/prototype/substr/length-negative.js @@ -0,0 +1,33 @@ +// 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" is a negative number +info: | + [...] + 7. Let resultLength be min(max(end, 0), size - intStart). + 8. If resultLength ≤ 0, return the empty String "". +---*/ + +assert.sameValue('abc'.substr(0, -1), '', '0, -1'); +assert.sameValue('abc'.substr(0, -2), '', '0, -2'); +assert.sameValue('abc'.substr(0, -3), '', '0, -3'); +assert.sameValue('abc'.substr(0, -4), '', '0, -4'); + +assert.sameValue('abc'.substr(1, -1), '', '1, -1'); +assert.sameValue('abc'.substr(1, -2), '', '1, -2'); +assert.sameValue('abc'.substr(1, -3), '', '1, -3'); +assert.sameValue('abc'.substr(1, -4), '', '1, -4'); + +assert.sameValue('abc'.substr(2, -1), '', '2, -1'); +assert.sameValue('abc'.substr(2, -2), '', '2, -2'); +assert.sameValue('abc'.substr(2, -3), '', '2, -3'); +assert.sameValue('abc'.substr(2, -4), '', '2, -4'); + +assert.sameValue('abc'.substr(3, -1), '', '3, -1'); +assert.sameValue('abc'.substr(3, -2), '', '3, -2'); +assert.sameValue('abc'.substr(3, -3), '', '3, -3'); +assert.sameValue('abc'.substr(3, -4), '', '3, -4'); + +reportCompare(0, 0); |