Stage 2: BigInt (#588)
* Stage 2: BigInt * Change plugin name to bigInt (camelcase). * Update based on PR review, add test cases. * Use hex for charCodes.
This commit is contained in:
committed by
Henry Zhu
parent
fecdb6feeb
commit
baa5f4dca7
1
test/fixtures/experimental/bigint/invalid-decimal/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-decimal/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
1.0n
|
||||
1
test/fixtures/experimental/bigint/invalid-decimal/options.json
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-decimal/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "throws": "Invalid BigIntLiteral (1:0)" }
|
||||
1
test/fixtures/experimental/bigint/invalid-e/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-e/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
2e9n
|
||||
1
test/fixtures/experimental/bigint/invalid-e/options.json
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-e/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "throws": "Invalid BigIntLiteral (1:0)" }
|
||||
1
test/fixtures/experimental/bigint/invalid-octal-legacy/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-octal-legacy/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
016432n
|
||||
1
test/fixtures/experimental/bigint/invalid-octal-legacy/options.json
vendored
Normal file
1
test/fixtures/experimental/bigint/invalid-octal-legacy/options.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{ "throws": "Invalid BigIntLiteral (1:0)" }
|
||||
3
test/fixtures/experimental/bigint/options.json
vendored
Normal file
3
test/fixtures/experimental/bigint/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["bigInt"]
|
||||
}
|
||||
1
test/fixtures/experimental/bigint/valid-binary/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/valid-binary/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0b101011101n
|
||||
69
test/fixtures/experimental/bigint/valid-binary/expected.json
vendored
Normal file
69
test/fixtures/experimental/bigint/valid-binary/expected.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BigIntLiteral",
|
||||
"start": 0,
|
||||
"end": 12,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 12
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "0b101011101",
|
||||
"raw": "0b101011101n"
|
||||
},
|
||||
"value": "0b101011101"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
test/fixtures/experimental/bigint/valid-hex/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/valid-hex/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0xFFF123n
|
||||
69
test/fixtures/experimental/bigint/valid-hex/expected.json
vendored
Normal file
69
test/fixtures/experimental/bigint/valid-hex/expected.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BigIntLiteral",
|
||||
"start": 0,
|
||||
"end": 9,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 9
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "0xFFF123",
|
||||
"raw": "0xFFF123n"
|
||||
},
|
||||
"value": "0xFFF123"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
test/fixtures/experimental/bigint/valid-large/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/valid-large/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
9223372036854775807n
|
||||
69
test/fixtures/experimental/bigint/valid-large/expected.json
vendored
Normal file
69
test/fixtures/experimental/bigint/valid-large/expected.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BigIntLiteral",
|
||||
"start": 0,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "9223372036854775807",
|
||||
"raw": "9223372036854775807n"
|
||||
},
|
||||
"value": "9223372036854775807"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
test/fixtures/experimental/bigint/valid-octal-new/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/valid-octal-new/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
0o16432n
|
||||
69
test/fixtures/experimental/bigint/valid-octal-new/expected.json
vendored
Normal file
69
test/fixtures/experimental/bigint/valid-octal-new/expected.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BigIntLiteral",
|
||||
"start": 0,
|
||||
"end": 8,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 8
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "0o16432",
|
||||
"raw": "0o16432n"
|
||||
},
|
||||
"value": "0o16432"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
test/fixtures/experimental/bigint/valid-small/actual.js
vendored
Normal file
1
test/fixtures/experimental/bigint/valid-small/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
100n
|
||||
69
test/fixtures/experimental/bigint/valid-small/expected.json
vendored
Normal file
69
test/fixtures/experimental/bigint/valid-small/expected.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 4,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 4,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"sourceType": "script",
|
||||
"body": [
|
||||
{
|
||||
"type": "ExpressionStatement",
|
||||
"start": 0,
|
||||
"end": 4,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"expression": {
|
||||
"type": "BigIntLiteral",
|
||||
"start": 0,
|
||||
"end": 4,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 4
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "100",
|
||||
"raw": "100n"
|
||||
},
|
||||
"value": "100"
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user