summaryrefslogtreecommitdiff
path: root/test/addons-napi/test_symbol/test1.js
blob: 25eb473c4b1b9d9f7630a595adf4178ee98e0c62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
'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');