diff options
author | cjihrig <cjihrig@gmail.com> | 2017-06-28 19:06:47 +0300 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2017-06-30 22:22:37 +0300 |
commit | 0f1888f31366381575076f25b831a3395bcf3f96 (patch) | |
tree | cea7b7a99eadcc71ab6cacfb5e3797097137bccb /test/addons-napi/test_object | |
parent | c9cf7c2780e4f5ae8ad6583c8b179b59d676c1f1 (diff) |
test: verify napi_get_property() walks prototype
Refs: https://github.com/nodejs/node/issues/13925
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'test/addons-napi/test_object')
-rw-r--r-- | test/addons-napi/test_object/test.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/addons-napi/test_object/test.js b/test/addons-napi/test_object/test.js index 4b64fa4b381..c9c549c8274 100644 --- a/test/addons-napi/test_object/test.js +++ b/test/addons-napi/test_object/test.js @@ -32,6 +32,25 @@ 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 = { x: 10, |