Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: verify detail exception messages in addons-napi/test_constructor #14318

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions test/addons-napi/test_constructor/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ assert.strictEqual(test_object.readwriteValue, 1);
test_object.readwriteValue = 2;
assert.strictEqual(test_object.readwriteValue, 2);

assert.throws(() => { test_object.readonlyValue = 3; }, TypeError);
assert.throws(() => { test_object.readonlyValue = 3; },
/^TypeError: Cannot assign to read only property 'readonlyValue' of object '#<MyObject>'$/);

assert.ok(test_object.hiddenValue);

Expand All @@ -35,11 +36,13 @@ assert.ok(!propertyNames.includes('readonlyAccessor2'));
test_object.readwriteAccessor1 = 1;
assert.strictEqual(test_object.readwriteAccessor1, 1);
assert.strictEqual(test_object.readonlyAccessor1, 1);
assert.throws(() => { test_object.readonlyAccessor1 = 3; }, TypeError);
assert.throws(() => { test_object.readonlyAccessor1 = 3; },
/^TypeError: Cannot assign to read only property 'readonlyAccessor1' of object '#<MyObject>'$/);
test_object.readwriteAccessor2 = 2;
assert.strictEqual(test_object.readwriteAccessor2, 2);
assert.strictEqual(test_object.readonlyAccessor2, 2);
assert.throws(() => { test_object.readonlyAccessor2 = 3; }, TypeError);
assert.throws(() => { test_object.readonlyAccessor2 = 3; },
/^TypeError: Cannot assign to read only property 'readonlyAccessor2' of object '#<MyObject>'$/);

// validate that static properties are on the class as opposed
// to the instance
Expand Down