Tests for NumericSeparatorLiteral, parseFloat(...)

This commit is contained in:
Rick Waldron 2017-08-16 17:05:14 -04:00
parent 9380826d5b
commit 3dd50181d2
30 changed files with 658 additions and 0 deletions

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0b StrBinaryDigits, 0B StrBinaryDigits
info: |
StrBinaryIntegerLiteral :::
0b StrBinaryDigits
0B StrBinaryDigits
StrBinaryDigits :::
BinaryDigit
StrBinaryDigits BinaryDigit
BinaryDigit ::: one of
0 1
---*/
assert.sameValue(parseFloat("0b0_1"), 0b0);
assert.sameValue(parseFloat("0B0_1"), 0B0);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0b StrBinaryDigits, 0B StrBinaryDigits
info: |
StrBinaryIntegerLiteral :::
0b StrBinaryDigits
0B StrBinaryDigits
StrBinaryDigits :::
BinaryDigit
StrBinaryDigits BinaryDigit
BinaryDigit ::: one of
0 1
---*/
assert.sameValue(parseFloat("0b0_10"), 0b0);
assert.sameValue(parseFloat("0B0_10"), 0B0);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0b StrBinaryDigits, 0B StrBinaryDigits
info: |
StrBinaryIntegerLiteral :::
0b StrBinaryDigits
0B StrBinaryDigits
StrBinaryDigits :::
BinaryDigit
StrBinaryDigits BinaryDigit
BinaryDigit ::: one of
0 1
---*/
assert.sameValue(parseFloat("0b01_0"), 0b01);
assert.sameValue(parseFloat("0B01_0"), 0B01);

View File

@ -0,0 +1,23 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0b StrBinaryDigits, 0B StrBinaryDigits
info: |
StrBinaryIntegerLiteral :::
0b StrBinaryDigits
0B StrBinaryDigits
StrBinaryDigits :::
BinaryDigit
StrBinaryDigits BinaryDigit
BinaryDigit ::: one of
0 1
---*/
assert.sameValue(parseFloat("0b01_00"), 0b01);
assert.sameValue(parseFloat("0B01_00"), 0B01);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
StrDecimalDigits . StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits NumericLiteralSeparator DecimalDigit
---*/
assert.sameValue(parseFloat("1.0e-1_0"), 1.0e-1);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
StrDecimalDigits . StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits NumericLiteralSeparator DecimalDigit
---*/
assert.sameValue(parseFloat("1.0e-10_0"), 1.0e-10);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: >
StrDecimalDigits . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
StrDecimalDigits . StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits NumericLiteralSeparator DecimalDigit
---*/
assert.sameValue(parseFloat("1.0e+1_0"), 1.0e+1);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
StrDecimalDigits . StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits NumericLiteralSeparator DecimalDigit
---*/
assert.sameValue(parseFloat("1.0e+10_0"), 1.0e+10);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrUnsignedDecimalLiteral
info: |
StrStrUnsignedDecimalLiteral :::
StrUnsignedDecimalLiteral
StrDecimalDigits :::
DecimalDigit
...
DecimalDigit ::: one of
0 1 2 3 4 5 6 7 8 9
---*/
assert.sameValue(parseFloat("1_0"), 1);
assert.sameValue(parseFloat("1_1"), 1);
assert.sameValue(parseFloat("1_2"), 1);
assert.sameValue(parseFloat("1_3"), 1);
assert.sameValue(parseFloat("1_4"), 1);
assert.sameValue(parseFloat("1_5"), 1);
assert.sameValue(parseFloat("1_6"), 1);
assert.sameValue(parseFloat("1_7"), 1);
assert.sameValue(parseFloat("1_8"), 1);
assert.sameValue(parseFloat("1_9"), 1);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
. StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat("10.00_01e2"), 10.00);

View File

@ -0,0 +1,24 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits
info: |
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat("123456789_0"), 123456789);
assert.sameValue(parseFloat("123456789_1"), 123456789);
assert.sameValue(parseFloat("123456789_2"), 123456789);
assert.sameValue(parseFloat("123456789_3"), 123456789);
assert.sameValue(parseFloat("123456789_4"), 123456789);
assert.sameValue(parseFloat("123456789_5"), 123456789);
assert.sameValue(parseFloat("123456789_6"), 123456789);
assert.sameValue(parseFloat("123456789_7"), 123456789);
assert.sameValue(parseFloat("123456789_8"), 123456789);
assert.sameValue(parseFloat("123456789_9"), 123456789);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
. StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
...
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat(".0_1e2"), .0);

View File

@ -0,0 +1,19 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
. StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
...
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat(".1_01e2"), .1);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
. StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat(".10_1e2"), .10);

View File

@ -0,0 +1,18 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: . StrDecimalDigits StrExponentPart
info: |
StrUnsignedDecimalLiteral :::
. StrDecimalDigits StrExponentPart
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat(".00_01e2"), .00);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0x StrHexDigits, 0X StrHexDigits
info: |
StrHexLiteral :::
0x StrHexDigits
0X StrHexDigits
StrHexDigits :::
HexDigit
StrHexDigits HexDigit
---*/
assert.sameValue(parseFloat("0x0_1"), 0x0);
assert.sameValue(parseFloat("0X0_1"), 0X0);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0x StrHexDigits, 0X StrHexDigits
info: |
StrHexLiteral :::
0x StrHexDigits
0X StrHexDigits
StrHexDigits :::
HexDigit
StrHexDigits HexDigit
---*/
assert.sameValue(parseFloat("0x0_10"), 0x0);
assert.sameValue(parseFloat("0X0_10"), 0X0);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0x StrHexDigits, 0X StrHexDigits
info: |
StrHexLiteral :::
0x StrHexDigits
0X StrHexDigits
StrHexDigits :::
HexDigit
StrHexDigits HexDigit
---*/
assert.sameValue(parseFloat("0x01_0"), 0x01);
assert.sameValue(parseFloat("0X01_0"), 0X01);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0x StrHexDigits, 0X StrHexDigits
info: |
StrHexLiteral :::
0x StrHexDigits
0X StrHexDigits
StrHexDigits :::
HexDigit
StrHexDigits HexDigit
---*/
assert.sameValue(parseFloat("0x01_00"), 0x01);
assert.sameValue(parseFloat("0X01_00"), 0X01);

View File

@ -0,0 +1,40 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0x StrHexDigits, 0X StrHexDigits
info: |
StrHexLiteral :::
0x StrHexDigits
0X StrHexDigits
StrHexDigits :::
HexDigit
StrHexDigits HexDigit
---*/
assert.sameValue(parseFloat("0x0_0"), 0x0);
assert.sameValue(parseFloat("0x1_1"), 0x1);
assert.sameValue(parseFloat("0x2_2"), 0x2);
assert.sameValue(parseFloat("0x3_3"), 0x3);
assert.sameValue(parseFloat("0x4_4"), 0x4);
assert.sameValue(parseFloat("0x5_5"), 0x5);
assert.sameValue(parseFloat("0x6_6"), 0x6);
assert.sameValue(parseFloat("0x7_7"), 0x7);
assert.sameValue(parseFloat("0x8_8"), 0x8);
assert.sameValue(parseFloat("0x9_9"), 0x9);
assert.sameValue(parseFloat("0xa_a"), 0xa);
assert.sameValue(parseFloat("0xb_b"), 0xb);
assert.sameValue(parseFloat("0xc_c"), 0xc);
assert.sameValue(parseFloat("0xd_d"), 0xd);
assert.sameValue(parseFloat("0xe_e"), 0xe);
assert.sameValue(parseFloat("0xf_f"), 0xf);
assert.sameValue(parseFloat("0xA_A"), 0xA);
assert.sameValue(parseFloat("0xB_B"), 0xB);
assert.sameValue(parseFloat("0xC_C"), 0xC);
assert.sameValue(parseFloat("0xD_D"), 0xD);
assert.sameValue(parseFloat("0xE_E"), 0xE);
assert.sameValue(parseFloat("0xF_F"), 0xF);

View File

@ -0,0 +1,33 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: NonZeroDigit NumericLiteralSeparator DecimalDigit
info: |
StrStrUnsignedDecimalLiteral :::
StrUnsignedDecimalLiteral
NonZeroDigit ::: one of
1 2 3 4 5 6 7 8 9
StrDecimalDigits :::
DecimalDigit
...
DecimalDigit ::: one of
0 1 2 3 4 5 6 7 8 9
---*/
assert.sameValue(parseFloat("1_0"), 1);
assert.sameValue(parseFloat("1_1"), 1);
assert.sameValue(parseFloat("2_2"), 2);
assert.sameValue(parseFloat("3_3"), 3);
assert.sameValue(parseFloat("4_4"), 4);
assert.sameValue(parseFloat("5_5"), 5);
assert.sameValue(parseFloat("6_6"), 6);
assert.sameValue(parseFloat("7_7"), 7);
assert.sameValue(parseFloat("8_8"), 8);
assert.sameValue(parseFloat("9_9"), 9);

View File

@ -0,0 +1,16 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrDecimalDigits
info: |
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
...
---*/
assert.sameValue(parseFloat("1_1"), 1);

View File

@ -0,0 +1,15 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: DecimalDigit
info: |
StrDecimalDigits :::
DecimalDigit
StrDecimalDigits DecimalDigit
---*/
assert.sameValue(parseFloat("1_0123456789"), 1);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0o StrOctalDigits, 0O StrOctalDigits
info: |
StrOctalLiteral :::
0o StrOctalDigits
0O StrOctalDigits
StrOctalDigits :::
OctalDigit
StrOctalDigits OctalDigit
---*/
assert.sameValue(parseFloat("0o0_0"), 0o0);
assert.sameValue(parseFloat("0o1_1"), 0o1);
assert.sameValue(parseFloat("0o2_2"), 0o2);
assert.sameValue(parseFloat("0o3_3"), 0o3);
assert.sameValue(parseFloat("0o4_4"), 0o4);
assert.sameValue(parseFloat("0o5_5"), 0o5);
assert.sameValue(parseFloat("0o6_6"), 0o6);
assert.sameValue(parseFloat("0o7_7"), 0o7);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0o StrOctalDigits, 0O StrOctalDigits
info: |
StrOctalLiteral :::
0o StrOctalDigits
0O StrOctalDigits
StrOctalDigits :::
OctalDigit
StrOctalDigits OctalDigit
---*/
assert.sameValue(parseFloat("0o0_1"), 0o0);
assert.sameValue(parseFloat("0O0_1"), 0O0);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0o StrOctalDigits, 0O StrOctalDigits
info: |
StrOctalLiteral :::
0o StrOctalDigits
0O StrOctalDigits
StrOctalDigits :::
OctalDigit
StrOctalDigits OctalDigit
---*/
assert.sameValue(parseFloat("0o0_10"), 0o0);
assert.sameValue(parseFloat("0O0_10"), 0O0);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0o StrOctalDigits, 0O StrOctalDigits
info: |
StrOctalLiteral :::
0o StrOctalDigits
0O StrOctalDigits
StrOctalDigits :::
OctalDigit
StrOctalDigits OctalDigit
---*/
assert.sameValue(parseFloat("0o01_0"), 0o01);
assert.sameValue(parseFloat("0O01_0"), 0O01);

View File

@ -0,0 +1,20 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: 0o StrOctalDigits, 0O StrOctalDigits
info: |
StrOctalLiteral :::
0o StrOctalDigits
0O StrOctalDigits
StrOctalDigits :::
OctalDigit
StrOctalDigits OctalDigit
---*/
assert.sameValue(parseFloat("0o01_00"), 0o01);
assert.sameValue(parseFloat("0O01_00"), 0O01);

View File

@ -0,0 +1,26 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: >
StrUnsignedDecimalLiteral, + StrUnsignedDecimalLiteral, - StrUnsignedDecimalLiteral
info: |
StrDecimalLiteral :::
StrUnsignedDecimalLiteral
+ StrUnsignedDecimalLiteral
- StrUnsignedDecimalLiteral
---*/
assert.sameValue(parseFloat("-123456789_0"), -123456789);
assert.sameValue(parseFloat("-123456789_1"), -123456789);
assert.sameValue(parseFloat("-123456789_2"), -123456789);
assert.sameValue(parseFloat("-123456789_3"), -123456789);
assert.sameValue(parseFloat("-123456789_4"), -123456789);
assert.sameValue(parseFloat("-123456789_5"), -123456789);
assert.sameValue(parseFloat("-123456789_6"), -123456789);
assert.sameValue(parseFloat("-123456789_7"), -123456789);
assert.sameValue(parseFloat("-123456789_8"), -123456789);
assert.sameValue(parseFloat("-123456789_9"), -123456789);

View File

@ -0,0 +1,25 @@
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-tonumber-applied-to-the-string-type
description: StrUnsignedDecimalLiteral
info: |
StrDecimalLiteral :::
StrUnsignedDecimalLiteral
+ StrUnsignedDecimalLiteral
- StrUnsignedDecimalLiteral
---*/
assert.sameValue(parseFloat("+123456789_0"), +123456789);
assert.sameValue(parseFloat("+123456789_1"), +123456789);
assert.sameValue(parseFloat("+123456789_2"), +123456789);
assert.sameValue(parseFloat("+123456789_3"), +123456789);
assert.sameValue(parseFloat("+123456789_4"), +123456789);
assert.sameValue(parseFloat("+123456789_5"), +123456789);
assert.sameValue(parseFloat("+123456789_6"), +123456789);
assert.sameValue(parseFloat("+123456789_7"), +123456789);
assert.sameValue(parseFloat("+123456789_8"), +123456789);
assert.sameValue(parseFloat("+123456789_9"), +123456789);