node/test/js-native-api/test_symbol/test1.js
Gabriel Schulhof c227b1be16
test: partition N-API tests
Partition test/addons-napi into test/js-native-api and test/node-api to
isolate the Node.js-agnostic portion of the N-API tests from the
Node.js-specific portion.

PR-URL: https://github.com/nodejs/node/pull/24557
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2018-12-07 13:32:42 +01:00

20 lines
575 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
// testing api calls for symbol
const test_symbol = require(`./build/${common.buildType}/test_symbol`);
const sym = test_symbol.New('test');
assert.strictEqual(sym.toString(), 'Symbol(test)');
const myObj = {};
const fooSym = test_symbol.New('foo');
const otherSym = test_symbol.New('bar');
myObj.foo = 'bar';
myObj[fooSym] = 'baz';
myObj[otherSym] = 'bing';
assert.strictEqual(myObj.foo, 'bar');
assert.strictEqual(myObj[fooSym], 'baz');
assert.strictEqual(myObj[otherSym], 'bing');