xref: /third_party/node/test/js-native-api/test_symbol/test2.js (revision 1cb0ef41)
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/js-native-api/test_symbol/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci// Testing api calls for symbol
61cb0ef41Sopenharmony_ciconst test_symbol = require(`./build/${common.buildType}/test_symbol`);
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst fooSym = test_symbol.New('foo');
91cb0ef41Sopenharmony_ciassert.strictEqual(fooSym.toString(), 'Symbol(foo)');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst myObj = {};
121cb0ef41Sopenharmony_cimyObj.foo = 'bar';
131cb0ef41Sopenharmony_cimyObj[fooSym] = 'baz';
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.keys(myObj), ['foo']);
161cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.getOwnPropertyNames(myObj), ['foo']);
171cb0ef41Sopenharmony_ciassert.deepStrictEqual(Object.getOwnPropertySymbols(myObj), [fooSym]);
18

Indexes created Thu Nov 07 10:32:03 CST 2024