| 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 |
Compute the mathematical integer value |
| 7 |
that is represented by Z in radix-R notation, using the |
| 8 |
letters A-Z and a-z for digits with values 10 through 35. |
| 9 |
Compute the number value for Result(16) |
| 10 |
esid: sec-parseint-string-radix |
| 11 |
description: Checking algorithm for R = 16 |
| 12 |
---*/ |
| 13 |
|
| 14 |
assert.sameValue(parseInt("0x1", 16), 1, 'parseInt("0x1", 16) must return 1'); |
| 15 |
assert.sameValue(parseInt("0X10", 16), 16, 'parseInt("0X10", 16) must return 16'); |
| 16 |
assert.sameValue(parseInt("0x100", 16), 256, 'parseInt("0x100", 16) must return 256'); |
| 17 |
assert.sameValue(parseInt("0X1000", 16), 4096, 'parseInt("0X1000", 16) must return 4096'); |
| 18 |
assert.sameValue(parseInt("0x10000", 16), 65536, 'parseInt("0x10000", 16) must return 65536'); |
| 19 |
assert.sameValue(parseInt("0X100000", 16), 1048576, 'parseInt("0X100000", 16) must return 1048576'); |
| 20 |
assert.sameValue(parseInt("0x1000000", 16), 16777216, 'parseInt("0x1000000", 16) must return 16777216'); |
| 21 |
assert.sameValue(parseInt("0x10000000", 16), 268435456, 'parseInt("0x10000000", 16) must return 268435456'); |
| 22 |
assert.sameValue(parseInt("0x100000000", 16), 4294967296, 'parseInt("0x100000000", 16) must return 4294967296'); |
| 23 |
assert.sameValue(parseInt("0x1000000000", 16), 68719476736, 'parseInt("0x1000000000", 16) must return 68719476736'); |
| 24 |
assert.sameValue(parseInt("0x10000000000", 16), 1099511627776, 'parseInt("0x10000000000", 16) must return 1099511627776'); |
| 25 |
|
| 26 |
assert.sameValue( |
| 27 |
parseInt("0x100000000000", 16), |
| 28 |
17592186044416, |
| 29 |
'parseInt("0x100000000000", 16) must return 17592186044416' |
| 30 |
); |
| 31 |
|
| 32 |
assert.sameValue( |
| 33 |
parseInt("0x1000000000000", 16), |
| 34 |
281474976710656, |
| 35 |
'parseInt("0x1000000000000", 16) must return 281474976710656' |
| 36 |
); |
| 37 |
|
| 38 |
assert.sameValue( |
| 39 |
parseInt("0x10000000000000", 16), |
| 40 |
4503599627370496, |
| 41 |
'parseInt("0x10000000000000", 16) must return 4503599627370496' |
| 42 |
); |
| 43 |
|
| 44 |
assert.sameValue( |
| 45 |
parseInt("0x100000000000000", 16), |
| 46 |
72057594037927936, |
| 47 |
'parseInt("0x100000000000000", 16) must return 72057594037927936' |
| 48 |
); |
| 49 |
|
| 50 |
assert.sameValue( |
| 51 |
parseInt("0x1000000000000000", 16), |
| 52 |
1152921504606846976, |
| 53 |
'parseInt("0x1000000000000000", 16) must return 1152921504606846976' |
| 54 |
); |
| 55 |
|
| 56 |
assert.sameValue( |
| 57 |
parseInt("0x10000000000000000", 16), |
| 58 |
18446744073709551616, |
| 59 |
'parseInt("0x10000000000000000", 16) must return 18446744073709551616' |
| 60 |
); |
| 61 |
|
| 62 |
assert.sameValue( |
| 63 |
parseInt("0x100000000000000000", 16), |
| 64 |
295147905179352825856, |
| 65 |
'parseInt("0x100000000000000000", 16) must return 295147905179352825856' |
| 66 |
); |
| 67 |
|
| 68 |
assert.sameValue( |
| 69 |
parseInt("0x1000000000000000000", 16), |
| 70 |
4722366482869645213696, |
| 71 |
'parseInt("0x1000000000000000000", 16) must return 4722366482869645213696' |
| 72 |
); |
| 73 |
|
| 74 |
assert.sameValue( |
| 75 |
parseInt("0x10000000000000000000", 16), |
| 76 |
75557863725914323419136, |
| 77 |
'parseInt("0x10000000000000000000", 16) must return 75557863725914323419136' |
| 78 |
); |
| 79 |
|
| 80 |
reportCompare(0, 0); |