xref: /third_party/node/test/parallel/test-internal-util-classwrapper.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci// Flags: --expose-internals
21cb0ef41Sopenharmony_ci'use strict';
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_cirequire('../common');
51cb0ef41Sopenharmony_ciconst assert = require('assert');
61cb0ef41Sopenharmony_ciconst util = require('internal/util');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst createClassWrapper = util.createClassWrapper;
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ciclass A {
111cb0ef41Sopenharmony_ci  constructor(a, b, c) {
121cb0ef41Sopenharmony_ci    this.a = a;
131cb0ef41Sopenharmony_ci    this.b = b;
141cb0ef41Sopenharmony_ci    this.c = c;
151cb0ef41Sopenharmony_ci  }
161cb0ef41Sopenharmony_ci}
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciconst B = createClassWrapper(A);
191cb0ef41Sopenharmony_ci
201cb0ef41Sopenharmony_ciassert.strictEqual(typeof B, 'function');
211cb0ef41Sopenharmony_ciassert(B(1, 2, 3) instanceof B);
221cb0ef41Sopenharmony_ciassert(B(1, 2, 3) instanceof A);
231cb0ef41Sopenharmony_ciassert(new B(1, 2, 3) instanceof B);
241cb0ef41Sopenharmony_ciassert(new B(1, 2, 3) instanceof A);
251cb0ef41Sopenharmony_ciassert.strictEqual(B.name, A.name);
261cb0ef41Sopenharmony_ciassert.strictEqual(B.length, A.length);
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciconst b = new B(1, 2, 3);
291cb0ef41Sopenharmony_ciassert.strictEqual(b.a, 1);
301cb0ef41Sopenharmony_ciassert.strictEqual(b.b, 2);
311cb0ef41Sopenharmony_ciassert.strictEqual(b.c, 3);
32

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