avajs / babel

Babel provider for AVA.
11 stars 3 forks source link

BigInt literals cause tests to not be recognized #4

Closed broofa closed 4 years ago

broofa commented 5 years ago

With node@10.15.3 (i.e. BigInt support enabled) and ava@2.2.0:

Runs test and passes

test('main', t => t.is(123, 123));

Output: 1 test passed [06:42:47]

test('main', t => t.is(123n, 123n));

Output: ✖ Couldn't find any files to test

broofa commented 5 years ago

FWIW, discovered this while looking into https://github.com/sindresorhus/fnv1a/issues/3

novemberborn commented 5 years ago

I'm pretty sure I have working tests that use BigInt literals. Could you share a reproduction?

novemberborn commented 5 years ago

(By which I mean a Gist or GitHub repo I can clone and run locally.)

broofa commented 5 years ago
kieffer@MacBook-Pro$ ava --version
2.2.0

kieffer@MacBook-Pro$ cat ava_bigint.js
import test from 'ava';

test('main', t => {
    t.is(123, 123);
    t.is(123n, 123n);
});

kieffer@MacBook-Pro$ ava ava_bigint.js

  ✖ Internal error
  SyntaxError: /Users/kieffer/work/ava_bigint.js: Identifier directly after number (5:9)

    3 | test('main', t => {
    4 |     t.is(123, 123);
  > 5 |     t.is(123n, 123n);
      |             ^
    6 | });
    7 |
  SyntaxError: /Users/kieffer/work/ava_bigint.js: Identifier directly after number (5:9)

    3 | test('main', t => {
    4 |     t.is(123, 123);
  > 5 |     t.is(123n, 123n);
      |             ^
    6 | });
    7 |
      at Parser.raise (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:6325:17)
      at Parser.readNumber (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:7215:12)
      at Parser.getTokenFromCode (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:6949:14)
      at Parser.nextToken (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:6525:12)
      at Parser.next (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:6465:10)
      at Parser.parseSubscript (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8509:12)
      at Parser.parseSubscripts (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8433:19)
      at Parser.parseExprSubscripts (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8422:17)
      at Parser.parseMaybeUnary (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8392:21)
      at Parser.parseExprOps (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8267:23)
      at Parser.parseMaybeConditional (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8240:23)
      at Parser.parseMaybeAssign (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8187:21)
      at Parser.parseExpression (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:8135:23)
      at Parser.parseStatementContent (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:9958:23)
      at Parser.parseStatement (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:9829:17)
      at Parser.parseBlockOrModuleBlockBody (/Users/kieffer/work/node_modules/@babel/parser/lib/index.js:10405:25)

kieffer@MacBook-Pro$
novemberborn commented 5 years ago

Ah of course, I'm using this while having disabled our Babel pipeline. We need to add the syntax plugin so Babel is able to parse sources with these literals. There's probably a couple other stage-4 things we need to add in.

broofa commented 4 years ago

Closed, as in "resolved" or "wont fix" or...?

novemberborn commented 4 years ago

As in, looks like this should already be working. With v2 even. I think.

Note that this is now part of a new package to be used with AVA v3. Which will be out soon (unofficially, I'm too tired to write the release notes).