Skip to content

Commit

Permalink
Fix a syntax error in test
Browse files Browse the repository at this point in the history
`npm test` command has been failed in old version node.js since
introducing `bitint` tests. The problem is caused that old version V8
doesn't support the bigint syntax(e.g. 11n, 22n). So, we just wrap the
syntax using `eval()` method to avoid the problem.

/home/jinho_bang/up/test/typedarray.js:81
      t[3] = 11n;
             ^^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:607:28)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at testModules.forEach.name (/home/jinho_bang/up/test/index.js:54:5)

Fixes: nodejs#349
  • Loading branch information
romandev committed Sep 20, 2018
1 parent b6e2d92 commit 989953e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test/typedarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ function test(binding) {
assert.strictEqual(binding.typedarray.getTypedArrayType(t), type);
assert.strictEqual(binding.typedarray.getTypedArrayLength(t), length);

t[3] = 11n;
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 11n);
binding.typedarray.setTypedArrayElement(t, 3, 22n);
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 22n);
assert.strictEqual(t[3], 22n);
t[3] = eval("11n");
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), eval("11n"));
binding.typedarray.setTypedArrayElement(t, 3, eval("22n"));
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), eval("22n"));
assert.strictEqual(t[3], eval("22n"));

const b = binding.typedarray.getTypedArrayBuffer(t);
assert.ok(b instanceof ArrayBuffer);
Expand All @@ -98,11 +98,11 @@ function test(binding) {
assert.strictEqual(binding.typedarray.getTypedArrayType(t), type);
assert.strictEqual(binding.typedarray.getTypedArrayLength(t), length);

t[3] = 11n;
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 11n);
binding.typedarray.setTypedArrayElement(t, 3, 22n);
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), 22n);
assert.strictEqual(t[3], 22n);
t[3] = eval("11n");
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), eval("11n"));
binding.typedarray.setTypedArrayElement(t, 3, eval("22n"));
assert.strictEqual(binding.typedarray.getTypedArrayElement(t, 3), eval("22n"));
assert.strictEqual(t[3], eval("22n"));

assert.strictEqual(binding.typedarray.getTypedArrayBuffer(t), b);
} catch (e) {
Expand Down

0 comments on commit 989953e

Please sign in to comment.