(binding)
| 5 | module.exports = require('../common').runTest(test); |
| 6 | |
| 7 | function test (binding) { |
| 8 | function testHasOwnProperty (nativeHasOwnProperty) { |
| 9 | const obj = { one: 1 }; |
| 10 | |
| 11 | Object.defineProperty(obj, 'two', { value: 2 }); |
| 12 | |
| 13 | assert.strictEqual(nativeHasOwnProperty(obj, 'one'), true); |
| 14 | assert.strictEqual(nativeHasOwnProperty(obj, 'two'), true); |
| 15 | assert.strictEqual('toString' in obj, true); |
| 16 | assert.strictEqual(nativeHasOwnProperty(obj, 'toString'), false); |
| 17 | } |
| 18 | |
| 19 | function testShouldThrowErrorIfKeyIsInvalid (nativeHasOwnProperty) { |
| 20 | assert.throws(() => { |
| 21 | nativeHasOwnProperty(undefined, 'test'); |
| 22 | }, /Cannot convert undefined or null to object/); |
| 23 | } |
| 24 | |
| 25 | testHasOwnProperty(binding.object.hasOwnPropertyWithNapiValue); |
| 26 | testHasOwnProperty(binding.object.hasOwnPropertyWithNapiWrapperValue); |
| 27 | testHasOwnProperty(binding.object.hasOwnPropertyWithCStyleString); |
| 28 | testHasOwnProperty(binding.object.hasOwnPropertyWithCppStyleString); |
| 29 | |
| 30 | testShouldThrowErrorIfKeyIsInvalid(binding.object.hasOwnPropertyWithNapiValue); |
| 31 | testShouldThrowErrorIfKeyIsInvalid(binding.object.hasOwnPropertyWithNapiWrapperValue); |
| 32 | testShouldThrowErrorIfKeyIsInvalid(binding.object.hasOwnPropertyWithCStyleString); |
| 33 | testShouldThrowErrorIfKeyIsInvalid(binding.object.hasOwnPropertyWithCppStyleString); |
| 34 | } |
nothing calls this directly
no test coverage detected