summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/parseInt/S15.1.2.2_A6.1_T6.js
blob: 3942540f0e7e14c63b25c99a2e70770fb8982c0e (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
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
info: |
    If S contains any character that is not a radix-R digit,
    then let Z be the substring of S consisting of all characters before
    the first such character; otherwise, let Z be S
esid: sec-parseint-string-radix
description: Complex test. Radix-R notation in [0..9]
---*/

assert.sameValue(parseInt("0123456789", 2), 1, 'parseInt("0123456789", 2) must return 1');
assert.sameValue(parseInt("01234567890", 3), 5, 'parseInt("01234567890", 3) must return 5');
assert.sameValue(parseInt("01234567890", 4), 27, 'parseInt("01234567890", 4) must return 27');
assert.sameValue(parseInt("01234567890", 5), 194, 'parseInt("01234567890", 5) must return 194');
assert.sameValue(parseInt("01234567890", 6), 1865, 'parseInt("01234567890", 6) must return 1865');
assert.sameValue(parseInt("01234567890", 7), 22875, 'parseInt("01234567890", 7) must return 22875');
assert.sameValue(parseInt("01234567890", 8), 342391, 'parseInt("01234567890", 8) must return 342391');
assert.sameValue(parseInt("01234567890", 9), 6053444, 'parseInt("01234567890", 9) must return 6053444');

assert.sameValue(
  parseInt("01234567890", 10),
  Number(1234567890),
  'parseInt("01234567890", 10) must return the same value returned by Number(1234567890)'
);

reportCompare(0, 0);