Skip to content

Commit

Permalink
test: verify napi_get_property() walks prototype
Browse files Browse the repository at this point in the history
Refs: #13925
PR-URL: #13961
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
cjihrig authored and addaleax committed Jul 11, 2017
1 parent ece8c98 commit ab85fc9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/addons-napi/test_object/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ assert(test_object.Has(newObject, 'test_number'));
assert.strictEqual(newObject.test_number, 987654321);
assert.strictEqual(newObject.test_string, 'test string');

{
// Verify that napi_get_property() walks the prototype chain.
function MyObject() {
this.foo = 42;
this.bar = 43;
}

MyObject.prototype.bar = 44;
MyObject.prototype.baz = 45;

const obj = new MyObject();

assert.strictEqual(test_object.Get(obj, 'foo'), 42);
assert.strictEqual(test_object.Get(obj, 'bar'), 43);
assert.strictEqual(test_object.Get(obj, 'baz'), 45);
assert.strictEqual(test_object.Get(obj, 'toString'),
Object.prototype.toString);
}

{
// test_object.Inflate increases all properties by 1
const cube = {
Expand Down

0 comments on commit ab85fc9

Please sign in to comment.