Skip to content

Commit f400939

Browse files
cjihrigaddaleax
authored andcommitted
test: verify napi_get_property() walks prototype
Refs: #13925 PR-URL: #13961 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent dc0ae8b commit f400939

File tree

1 file changed

+19
-0
lines changed
  • test/addons-napi/test_object

1 file changed

+19
-0
lines changed

‎test/addons-napi/test_object/test.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ assert(test_object.Has(newObject, 'test_number'));
3131
assert.strictEqual(newObject.test_number,987654321);
3232
assert.strictEqual(newObject.test_string,'test string');
3333

34+
{
35+
// Verify that napi_get_property() walks the prototype chain.
36+
functionMyObject(){
37+
this.foo=42;
38+
this.bar=43;
39+
}
40+
41+
MyObject.prototype.bar=44;
42+
MyObject.prototype.baz=45;
43+
44+
constobj=newMyObject();
45+
46+
assert.strictEqual(test_object.Get(obj,'foo'),42);
47+
assert.strictEqual(test_object.Get(obj,'bar'),43);
48+
assert.strictEqual(test_object.Get(obj,'baz'),45);
49+
assert.strictEqual(test_object.Get(obj,'toString'),
50+
Object.prototype.toString);
51+
}
52+
3453
{
3554
// test_object.Inflate increases all properties by 1
3655
constcube={

0 commit comments

Comments
(0)