11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../../common'); 31cb0ef41Sopenharmony_ciconst assert = require('assert'); 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Test passing NULL to object-related N-APIs. 61cb0ef41Sopenharmony_ciconst { testNull } = require(`./build/${common.buildType}/test_object`); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst expectedForProperty = { 91cb0ef41Sopenharmony_ci envIsNull: 'Invalid argument', 101cb0ef41Sopenharmony_ci objectIsNull: 'Invalid argument', 111cb0ef41Sopenharmony_ci keyIsNull: 'Invalid argument', 121cb0ef41Sopenharmony_ci valueIsNull: 'Invalid argument', 131cb0ef41Sopenharmony_ci}; 141cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.setProperty(), expectedForProperty); 151cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getProperty(), expectedForProperty); 161cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.hasProperty(), expectedForProperty); 171cb0ef41Sopenharmony_ci// eslint-disable-next-line no-prototype-builtins 181cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.hasOwnProperty(), expectedForProperty); 191cb0ef41Sopenharmony_ci// It's OK not to want the result of a deletion. 201cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.deleteProperty(), 211cb0ef41Sopenharmony_ci Object.assign({}, 221cb0ef41Sopenharmony_ci expectedForProperty, 231cb0ef41Sopenharmony_ci { valueIsNull: 'napi_ok' })); 241cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.setNamedProperty(), expectedForProperty); 251cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getNamedProperty(), expectedForProperty); 261cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.hasNamedProperty(), expectedForProperty); 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ciconst expectedForElement = { 291cb0ef41Sopenharmony_ci envIsNull: 'Invalid argument', 301cb0ef41Sopenharmony_ci objectIsNull: 'Invalid argument', 311cb0ef41Sopenharmony_ci valueIsNull: 'Invalid argument', 321cb0ef41Sopenharmony_ci}; 331cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.setElement(), expectedForElement); 341cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getElement(), expectedForElement); 351cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.hasElement(), expectedForElement); 361cb0ef41Sopenharmony_ci// It's OK not to want the result of a deletion. 371cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.deleteElement(), 381cb0ef41Sopenharmony_ci Object.assign({}, 391cb0ef41Sopenharmony_ci expectedForElement, 401cb0ef41Sopenharmony_ci { valueIsNull: 'napi_ok' })); 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.defineProperties(), { 431cb0ef41Sopenharmony_ci envIsNull: 'Invalid argument', 441cb0ef41Sopenharmony_ci objectIsNull: 'Invalid argument', 451cb0ef41Sopenharmony_ci descriptorListIsNull: 'Invalid argument', 461cb0ef41Sopenharmony_ci utf8nameIsNull: 'Invalid argument', 471cb0ef41Sopenharmony_ci methodIsNull: 'Invalid argument', 481cb0ef41Sopenharmony_ci}); 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci// `expectedForElement` also works for the APIs below. 511cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getPropertyNames(), expectedForElement); 521cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getAllPropertyNames(), expectedForElement); 531cb0ef41Sopenharmony_ciassert.deepStrictEqual(testNull.getPrototype(), expectedForElement); 54