| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
|
| 4 |
/*--- |
| 5 |
es6id: 20.1.1.1 |
| 6 |
description: Invalid binary literals yield NaN |
| 7 |
info: | |
| 8 |
BinaryIntegerLiteral :: |
| 9 |
0b BinaryDigits |
| 10 |
0B BinaryDigits |
| 11 |
BinaryDigits :: |
| 12 |
BinaryDigit |
| 13 |
BinaryDigits BinaryDigit |
| 14 |
BinaryDigit :: one of |
| 15 |
0 1 |
| 16 |
---*/ |
| 17 |
|
| 18 |
assert.sameValue(Number('0b2'), NaN, 'invalid digit'); |
| 19 |
assert.sameValue(Number('00b0'), NaN, 'leading zero'); |
| 20 |
assert.sameValue(Number('0b'), NaN, 'omitted digits'); |
| 21 |
assert.sameValue(Number('+0b1'), NaN, 'plus sign'); |
| 22 |
assert.sameValue(Number('-0b1'), NaN, 'minus sign'); |
| 23 |
assert.sameValue(Number('0b1.01'), NaN, 'fractional part'); |
| 24 |
assert.sameValue(Number('0b1e10'), NaN, 'exponent part'); |
| 25 |
assert.sameValue(Number('0b1e-10'), NaN, 'exponent part with a minus sign'); |
| 26 |
assert.sameValue(Number('0b1e+10'), NaN, 'exponent part with a plus sign'); |