File tree 1 file changed +19
-0
lines changed
test/addons-napi/test_object
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,25 @@ assert(test_object.Has(newObject, 'test_number'));
31
31
assert . strictEqual ( newObject . test_number , 987654321 ) ;
32
32
assert . strictEqual ( newObject . test_string , 'test string' ) ;
33
33
34
+ {
35
+ // Verify that napi_get_property() walks the prototype chain.
36
+ function MyObject ( ) {
37
+ this . foo = 42 ;
38
+ this . bar = 43 ;
39
+ }
40
+
41
+ MyObject . prototype . bar = 44 ;
42
+ MyObject . prototype . baz = 45 ;
43
+
44
+ const obj = new MyObject ( ) ;
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
+
34
53
{
35
54
// test_object.Inflate increases all properties by 1
36
55
const cube = {
You can’t perform that action at this time.
0 commit comments