Skip to content

Commit

Permalink
test: add trailing commas in test/js-native-api
Browse files Browse the repository at this point in the history
PR-URL: #46385
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 3, 2023
1 parent 8dfa748 commit b0f2415
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 44 deletions.
1 change: 0 additions & 1 deletion test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ overrides:
- files:
- es-module/*.js
- es-module/*.mjs
- js-native-api/*/*.js
- parallel/*.js
- parallel/*.mjs
- pummel/*.js
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_array/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ assert.throws(
() => {
test_array.TestGetElement(array, array.length + 1);
},
/^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/
/^Error: assertion \(\(\(uint32_t\)index < length\)\) failed: Index out of bounds!$/,
);

assert.throws(
() => {
test_array.TestGetElement(array, -2);
},
/^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/
/^Error: assertion \(index >= 0\) failed: Invalid index\. Expects a positive integer\.$/,
);

array.forEach(function(element, index) {
Expand Down
2 changes: 1 addition & 1 deletion test/js-native-api/test_bigint/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ assert.throws(() => CreateTooBigBigInt(), {
// Test that we correctly forward exceptions from the engine.
assert.throws(() => MakeBigIntWordsThrow(), {
name: 'RangeError',
message: 'Maximum BigInt size exceeded'
message: 'Maximum BigInt size exceeded',
});
2 changes: 1 addition & 1 deletion test/js-native-api/test_constructor/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ assert.deepStrictEqual(TestConstructor.TestDefineClass(), {
cbIsNull: 'Invalid argument',
cbDataIsNull: 'napi_ok',
propertiesIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});
22 changes: 11 additions & 11 deletions test/js-native-api/test_conversions/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,76 +143,76 @@ assert.deepStrictEqual(test.testNull.getValueBool(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A boolean was expected'
inputTypeCheck: 'A boolean was expected',
});

assert.deepStrictEqual(test.testNull.getValueInt32(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.getValueUint32(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.getValueInt64(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});


assert.deepStrictEqual(test.testNull.getValueDouble(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'A number was expected'
inputTypeCheck: 'A number was expected',
});

assert.deepStrictEqual(test.testNull.coerceToBool(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.coerceToObject(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.coerceToString(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument',
inputTypeCheck: 'napi_ok'
inputTypeCheck: 'napi_ok',
});

assert.deepStrictEqual(test.testNull.getValueStringUtf8(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});

assert.deepStrictEqual(test.testNull.getValueStringLatin1(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});

assert.deepStrictEqual(test.testNull.getValueStringUtf16(), {
envIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument',
wrongTypeIn: 'A string was expected',
bufAndOutLengthIsNull: 'Invalid argument'
bufAndOutLengthIsNull: 'Invalid argument',
});
10 changes: 5 additions & 5 deletions test/js-native-api/test_error/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,35 +70,35 @@ assert.throws(() => {
(err) => {
assert.strictEqual(err, value);
return true;
}
},
));

assert.throws(
() => test_error.throwErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'Error [error]'
message: 'Error [error]',
});

assert.throws(
() => test_error.throwRangeErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'RangeError [range error]'
message: 'RangeError [range error]',
});

assert.throws(
() => test_error.throwTypeErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'TypeError [type error]'
message: 'TypeError [type error]',
});

assert.throws(
() => test_error.throwSyntaxErrorCode(),
{
code: 'ERR_TEST_CODE',
message: 'SyntaxError [syntax error]'
message: 'SyntaxError [syntax error]',
});

let error = test_error.createError();
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_exception/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const test_exception = (function() {
// Test that the native side passes the exception through
assert.throws(
() => { test_exception.allowException(throwTheError); },
(err) => err === theError
(err) => err === theError,
);

// Test that the exception thrown above was marked as pending
Expand Down Expand Up @@ -59,7 +59,7 @@ const test_exception = (function() {
// Test that the native side passes the exception through
assert.throws(
() => { test_exception.constructAllowException(throwTheError); },
(err) => err === theError
(err) => err === theError,
);

// Test that the exception thrown above was marked as pending
Expand Down
6 changes: 3 additions & 3 deletions test/js-native-api/test_function/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ assert.deepStrictEqual(test_function.TestCreateFunctionParameters(), {
envIsNull: 'Invalid argument',
nameIsNull: 'napi_ok',
cbIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

assert.throws(
() => test_function.TestBadReturnExceptionPending(),
{
code: 'throwing exception',
name: 'Error'
}
name: 'Error',
},
);
6 changes: 3 additions & 3 deletions test/js-native-api/test_general/testEnvCleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (process.argv[2] === 'child') {
'simple wrap': 0,
'wrap, removeWrap': 1,
'first wrap': 2,
'second wrap': 3
'second wrap': 3,
};

// We attach the three objects we will test to `module.exports` to ensure they
Expand Down Expand Up @@ -39,7 +39,7 @@ if (process.argv[2] === 'child') {
const { spawnSync } = require('child_process');

const child = spawnSync(process.execPath, [__filename, 'child'], {
stdio: [ process.stdin, 'pipe', process.stderr ]
stdio: [ process.stdin, 'pipe', process.stderr ],
});

// Grab the child's output and construct an object whose keys are the rows of
Expand All @@ -49,7 +49,7 @@ if (process.argv[2] === 'child') {
child.stdout.toString().split(/\r\n|\r|\n/g).reduce((obj, item) =>
Object.assign(obj, item ? { [item]: true } : {}), {}), {
'finalize at env cleanup for simple wrap': true,
'finalize at env cleanup for second wrap': true
'finalize at env cleanup for second wrap': true,
});

// Ensure that the child exited successfully.
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_general/testInstanceOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
function compareToNative(theObject, theConstructor) {
assert.strictEqual(
addon.doInstanceOf(theObject, theConstructor),
(theObject instanceof theConstructor)
(theObject instanceof theConstructor),
);
}

function MyClass() {}
Object.defineProperty(MyClass, Symbol.hasInstance, {
value: function(candidate) {
return 'mark' in candidate;
}
},
});

function MySubClass() {}
Expand Down
22 changes: 11 additions & 11 deletions test/js-native-api/test_object/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const object = {
1, 94, 'str', 12.321, { test: 'obj in arr' },
],
newObject: {
test: 'obj in obj'
}
test: 'obj in obj',
},
};

assert.strictEqual(test_object.Get(object, 'hello'), 'world');
Expand Down Expand Up @@ -91,7 +91,7 @@ assert.strictEqual(newObject.test_string, 'test string');
const cube = {
x: 10,
y: 10,
z: 10
z: 10,
};

assert.deepStrictEqual(test_object.Inflate(cube), { x: 11, y: 11, z: 11 });
Expand All @@ -107,7 +107,7 @@ assert.strictEqual(newObject.test_string, 'test string');
const sym4 = Symbol('4');
const object2 = {
[sym1]: '@@iterator',
[sym2]: sym3
[sym2]: sym3,
};

assert(test_object.Has(object2, sym1));
Expand Down Expand Up @@ -236,7 +236,7 @@ assert.strictEqual(newObject.test_string, 'test string');
// and includes indices and converts them to strings.

const object = Object.create({
inherited: 1
inherited: 1,
});

const fooSymbol = Symbol('foo');
Expand All @@ -247,19 +247,19 @@ assert.strictEqual(newObject.test_string, 'test string');
value: 4,
enumerable: false,
writable: true,
configurable: true
configurable: true,
});
Object.defineProperty(object, 'writable', {
value: 4,
enumerable: true,
writable: true,
configurable: false
configurable: false,
});
Object.defineProperty(object, 'configurable', {
value: 4,
enumerable: true,
writable: false,
configurable: true
configurable: true,
});
object[5] = 5;

Expand Down Expand Up @@ -308,7 +308,7 @@ assert.deepStrictEqual(test_object.TestSetProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
});

// Verify that passing NULL to napi_has_property() results in the correct
Expand All @@ -317,7 +317,7 @@ assert.deepStrictEqual(test_object.TestHasProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

// Verify that passing NULL to napi_get_property() results in the correct
Expand All @@ -326,7 +326,7 @@ assert.deepStrictEqual(test_object.TestGetProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

{
Expand Down
4 changes: 2 additions & 2 deletions test/js-native-api/test_object/test_null.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const expectedForProperty = {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
};
assert.deepStrictEqual(testNull.setProperty(), expectedForProperty);
assert.deepStrictEqual(testNull.getProperty(), expectedForProperty);
Expand All @@ -28,7 +28,7 @@ assert.deepStrictEqual(testNull.hasNamedProperty(), expectedForProperty);
const expectedForElement = {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
valueIsNull: 'Invalid argument'
valueIsNull: 'Invalid argument',
};
assert.deepStrictEqual(testNull.setElement(), expectedForElement);
assert.deepStrictEqual(testNull.getElement(), expectedForElement);
Expand Down

0 comments on commit b0f2415

Please sign in to comment.