Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
test: fix n-api test_constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
boingoing committed Aug 18, 2017
1 parent cde5789 commit d81f653
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions test/addons-napi/test_constructor/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ assert.strictEqual(test_object.readwriteValue, 1);
test_object.readwriteValue = 2;
assert.strictEqual(test_object.readwriteValue, 2);

assert.throws(() => { test_object.readonlyValue = 3; },
/^TypeError: Cannot assign to read only property 'readonlyValue' of object '#<MyObject>'$/);
assert.throws(
() => { test_object.readonlyValue = 3; },
common.engineSpecificMessage({
v8: /^TypeError: Cannot assign to read only property 'readonlyValue' of object '#<MyObject>'$/,
chakracore: /^TypeError: Assignment to read-only properties is not allowed in strict mode$/
})
);

assert.ok(test_object.hiddenValue);

Expand All @@ -36,13 +41,24 @@ 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: Cannot assign to read only property 'readonlyAccessor1' of object '#<MyObject>'$/);
assert.throws(
() => { test_object.readonlyAccessor1 = 3; },
common.engineSpecificMessage({
v8: /^TypeError: Cannot assign to read only property 'readonlyAccessor1' of object '#<MyObject>'$/,
chakracore: /^TypeError: Assignment to read-only properties is not allowed in strict mode$/
})
);

test_object.readwriteAccessor2 = 2;
assert.strictEqual(test_object.readwriteAccessor2, 2);
assert.strictEqual(test_object.readonlyAccessor2, 2);
assert.throws(() => { test_object.readonlyAccessor2 = 3; },
/^TypeError: Cannot assign to read only property 'readonlyAccessor2' of object '#<MyObject>'$/);
assert.throws(
() => { test_object.readonlyAccessor2 = 3; },
common.engineSpecificMessage({
v8: /^TypeError: Cannot assign to read only property 'readonlyAccessor2' of object '#<MyObject>'$/,
chakracore: /^TypeError: Assignment to read-only properties is not allowed in strict mode$/
})
);

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

0 comments on commit d81f653

Please sign in to comment.