Skip to content

Commit 09c9539

Browse files
rdeforestGeoffreyBooth
authored andcommitted
Fix #5103: Add support for BigInt literals (#5104)
* Fix #5103: Add support for BigInt literals * Fix typos found in testing * Support binary, octal and hex BigInt literals * Make decimal BigInt test consistent other bases * Correct test BigInt test names * Add Node versions to CI
1 parent ddb5dac commit 09c9539

File tree

7 files changed

+34
-11
lines changed

7 files changed

+34
-11
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_js:
44
- 6
55
- 8
66
- 10
7+
- 12
8+
- node # Latest
79

810
cache:
911
directories:

Cakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ runTests = (CoffeeScript) ->
472472
skipUnless 'var a = 2 ** 2; a **= 3', ['exponentiation.coffee']
473473
skipUnless 'var {...a} = {}', ['object_rest_spread.coffee']
474474
skipUnless '/foo.bar/s.test("foo\tbar")', ['regex_dotall.coffee']
475+
skipUnless '1n', ['numbers_bigint.coffee']
475476
files = fs.readdirSync('test').filter (filename) ->
476477
filename not in testFilesToSkip
477478

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ environment:
33
- nodejs_version: '6'
44
- nodejs_version: '8'
55
- nodejs_version: '10'
6-
- nodejs_version: '' # Installs latest.
6+
- nodejs_version: '12'
7+
- nodejs_version: '' # Latest
78

89
install:
910
- ps: Install-Product node $env:nodejs_version

lib/coffeescript/lexer.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/coffeescript/parser.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lexer.coffee

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,9 +1212,10 @@ CSX_ATTRIBUTE = /// ^
12121212
///
12131213

12141214
NUMBER = ///
1215-
^ 0b[01]+ | # binary
1216-
^ 0o[0-7]+ | # octal
1217-
^ 0x[\da-f]+ | # hex
1215+
^ 0b[01]+n? | # binary
1216+
^ 0o[0-7]+n? | # octal
1217+
^ 0x[\da-f]+n? | # hex
1218+
^ \d+n | # decimal bigint
12181219
^ \d*\.?\d+ (?:e[+-]?\d+)? # decimal
12191220
///i
12201221

test/numbers_bigint.coffee

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# BigInt Literals
2+
# ---------------
3+
4+
test "BigInt exists", ->
5+
'object' is typeof BigInt
6+
7+
test "Parser recognizes decimal BigInt literals", ->
8+
eq 42n, BigInt 42
9+
10+
test "Parser recognizes binary BigInt literals", ->
11+
eq 42n, 0b101010n
12+
13+
test "Parser recognizes octal BigInt literals", ->
14+
eq 42n, 0o52n
15+
16+
test "Parser recognizes hexadecimal BigInt literals", ->
17+
eq 42n, 0x2an

0 commit comments

Comments
 (0)