Skip to content

feat: port test_constructor to CTS#29

Draft
kraenhansen wants to merge 6 commits intonodejs:mainfrom
kraenhansen:feat/port-test-constructor
Draft

feat: port test_constructor to CTS#29
kraenhansen wants to merge 6 commits intonodejs:mainfrom
kraenhansen:feat/port-test-constructor

Conversation

@kraenhansen
Copy link
Contributor

Note

This PR is stacked on #25 and should not be reviewed or merged until that PR lands.

Summary

Ports test_constructor from the Node.js test suite to the CTS.

  • Exercises napi_define_class with method, value, accessor, and static property descriptors
  • Verifies enumerable/non-enumerable and writable/readonly semantics on instance and static properties
  • Tests null-argument handling for napi_define_class (via test_null.c / test_null.js)
  • Three JS test files: test.js, test2.js, test_null.js

Test plan

  • npm run addons:configure && npm run addons:build — compiles cleanly
  • npm run node:test — all test files pass

🤖 Generated with Claude Code

kraenhansen and others added 6 commits February 28, 2026 12:35
Enumerates all 58 test directories from Node.js's test/js-native-api
and test/node-api, rates each by porting difficulty (Easy/Medium/Hard),
and documents special considerations for tests with deep runtime
dependencies (libuv, worker threads, SEA, node_api_post_finalizer, etc.).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the following to the Node.js implementor and harness in preparation
for porting the easy js-native-api tests:

- assert.js: expose assert.ok, .strictEqual, .notStrictEqual,
  .deepStrictEqual, and .throws as methods on the global assert object
- gc.js: new module providing a global gcUntil(name, condition) helper
  that drives GC until a condition is met (needed for finalizer tests)
- tests.ts: inject --expose-gc and gc.js into every test subprocess
- CMakeLists.txt: broaden add_node_api_cts_addon() to accept multiple
  source files via ARGN (needed for multi-file addons)
- tests/harness/assert.js: exercise all new assert methods
- tests/harness/gc.js: exercise gcUntil pass and failure paths

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port all "Easy" difficulty engine-specific tests from Node.js:
3_callbacks, 4_object_factory, 5_function_factory, 7_factory_wrap,
8_passing_wrapped, test_array, test_bigint, test_dataview, test_date,
test_handle_scope, test_instance_data, test_new_target, test_number,
test_promise, test_properties, test_reference_double_free, test_symbol.

C/C++ sources are copied from Node.js with minimal changes (entry_point.h
macro). JS tests are adapted to use CTS globals (loadAddon, assert,
gcUntil) instead of Node.js test harness (common.js, require).

test_dataview: removed SharedArrayBuffer tests that depend on experimental
node_api_is_sharedarraybuffer API (not in stable node-api-headers).

Also updates node-api-headers from 1.7.0 to 1.8.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Mark 17 easy js-native-api tests as Ported (test_dataview as Partial due
to missing experimental SharedArrayBuffer APIs in node-api-headers).

Add "Experimental Node-API Features" section documenting which tests
depend on experimental APIs not yet available in node-api-headers, and
the approach needed to support them. References nodejs#26.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Exercises napi_define_class with method, data value, accessor, and
static property descriptors. Includes null-argument tests for
napi_define_class via test_null.c/test_null.js.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

1 participant