xref: /third_party/node/test/js-native-api/test_symbol/test1.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 sym = test_symbol.New('test');
91cb0ef41Sopenharmony_ciassert.strictEqual(sym.toString(), 'Symbol(test)');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst myObj = {};
121cb0ef41Sopenharmony_ciconst fooSym = test_symbol.New('foo');
131cb0ef41Sopenharmony_ciconst otherSym = test_symbol.New('bar');
141cb0ef41Sopenharmony_cimyObj.foo = 'bar';
151cb0ef41Sopenharmony_cimyObj[fooSym] = 'baz';
161cb0ef41Sopenharmony_cimyObj[otherSym] = 'bing';
171cb0ef41Sopenharmony_ciassert.strictEqual(myObj.foo, 'bar');
181cb0ef41Sopenharmony_ciassert.strictEqual(myObj[fooSym], 'baz');
191cb0ef41Sopenharmony_ciassert.strictEqual(myObj[otherSym], 'bing');
20

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