Debian Codegraph @

js/src/tests/test262/built-ins/parseInt/S15.1.2.2_A6.1_T6.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 If S contains any character that is not a radix-R digit,
7 then let Z be the substring of S consisting of all characters before
8 the first such character; otherwise, let Z be S
9 esid: sec-parseint-string-radix
10 description: Complex test. Radix-R notation in [0..9]
11 ---*/
12
13 assert.sameValue(parseInt("0123456789", 2), 1, 'parseInt("0123456789", 2) must return 1');
14 assert.sameValue(parseInt("01234567890", 3), 5, 'parseInt("01234567890", 3) must return 5');
15 assert.sameValue(parseInt("01234567890", 4), 27, 'parseInt("01234567890", 4) must return 27');
16 assert.sameValue(parseInt("01234567890", 5), 194, 'parseInt("01234567890", 5) must return 194');
17 assert.sameValue(parseInt("01234567890", 6), 1865, 'parseInt("01234567890", 6) must return 1865');
18 assert.sameValue(parseInt("01234567890", 7), 22875, 'parseInt("01234567890", 7) must return 22875');
19 assert.sameValue(parseInt("01234567890", 8), 342391, 'parseInt("01234567890", 8) must return 342391');
20 assert.sameValue(parseInt("01234567890", 9), 6053444, 'parseInt("01234567890", 9) must return 6053444');
21
22 assert.sameValue(
23 parseInt("01234567890", 10),
24 Number(1234567890),
25 'parseInt("01234567890", 10) must return the same value returned by Number(1234567890)'
26 );
27
28 reportCompare(0, 0);