diff options
author | legendecas <legendecas@gmail.com> | 2019-05-29 13:25:07 +0800 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-06-17 12:07:08 +0200 |
commit | 10a346edde47c872de9afbcb79aa43095064078b (patch) | |
tree | 7d0f7362f223b8a2521f523aa56bf4564712cd4d /test/js-native-api/test_constructor | |
parent | 432958528ea5a68d68afe0f0bc379abd3f35e8a0 (diff) | |
download | node-new-10a346edde47c872de9afbcb79aa43095064078b.tar.gz |
n-api: define ECMAScript-compliant accessors on napi_define_class
PR-URL: https://github.com/nodejs/node/pull/27851
Fixes: https://github.com/nodejs/node/issues/26551
Fixes: https://github.com/nodejs/node-addon-api/issues/485
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'test/js-native-api/test_constructor')
-rw-r--r-- | test/js-native-api/test_constructor/test.js | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/js-native-api/test_constructor/test.js b/test/js-native-api/test_constructor/test.js index 8dc987a994..a58eac81ad 100644 --- a/test/js-native-api/test_constructor/test.js +++ b/test/js-native-api/test_constructor/test.js @@ -2,6 +2,9 @@ const common = require('../../common'); const assert = require('assert'); +const getterOnlyErrorRE = + /^TypeError: Cannot set property .* of #<.*> which has only a getter$/; + // Testing api calls for a constructor that defines properties const TestConstructor = require(`./build/${common.buildType}/test_constructor`); const test_object = new TestConstructor(); @@ -36,13 +39,11 @@ assert.ok(!propertyNames.includes('readonlyAccessor2')); test_object.readwriteAccessor1 = 1; assert.strictEqual(test_object.readwriteAccessor1, 1); assert.strictEqual(test_object.readonlyAccessor1, 1); -assert.throws(() => { test_object.readonlyAccessor1 = 3; }, - /^TypeError: Cannot assign to read only property 'readonlyAccessor1' of object '#<MyObject>'$/); +assert.throws(() => { test_object.readonlyAccessor1 = 3; }, getterOnlyErrorRE); test_object.readwriteAccessor2 = 2; assert.strictEqual(test_object.readwriteAccessor2, 2); assert.strictEqual(test_object.readonlyAccessor2, 2); -assert.throws(() => { test_object.readonlyAccessor2 = 3; }, - /^TypeError: Cannot assign to read only property 'readonlyAccessor2' of object '#<MyObject>'$/); +assert.throws(() => { test_object.readonlyAccessor2 = 3; }, getterOnlyErrorRE); // Validate that static properties are on the class as opposed // to the instance |