Skip to content

Commit

Permalink
fixup! n-api: support for object freeze/seal
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Oct 7, 2020
1 parent e7c2fe9 commit ce959cf
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/js-native-api/test_object/test.js
Expand Up @@ -284,15 +284,16 @@ assert.deepStrictEqual(test_object.TestGetProperty(), {
assert.strictEqual(Object.isSealed(obj), true);

assert.throws(() => {
obj['w'] = 'd'
obj.w = 'd';
}, /Cannot add property w, object is not extensible/);

assert.throws(() => {
delete obj['x']
delete obj.x;
}, /Cannot delete property 'x' of #<Object>/);

// Sealed objects allow updating existing properties.
assert.doesNotThrow(() => { obj['x'] = 'd' });
// Sealed objects allow updating existing properties,
// so this should not throw.
obj.x = 'd';
}

{
Expand All @@ -303,14 +304,14 @@ assert.deepStrictEqual(test_object.TestGetProperty(), {
assert.strictEqual(Object.isFrozen(obj), true);

assert.throws(() => {
obj['x'] = 10
obj.x = 10;
}, /Cannot assign to read only property 'x' of object '#<Object>/);

assert.throws(() => {
obj['w'] = 15
obj.w = 15;
}, /Cannot add property w, object is not extensible/);

assert.throws(() => {
delete obj['x']
delete obj.x;
}, /Cannot delete property 'x' of #<Object>/);
}

0 comments on commit ce959cf

Please sign in to comment.