test: add trailing commas in test/js-native-api

PR-URL: https://github.com/nodejs/node/pull/46385
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
This commit is contained in:
Antoine du Hamel
2023-01-25 07:05:09 +01:00
parent a466feaca7
commit 7079158d29
12 changed files with 43 additions and 44 deletions

View File

@@ -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) {

View File

@@ -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',
});

View File

@@ -58,5 +58,5 @@ assert.deepStrictEqual(TestConstructor.TestDefineClass(), {
cbIsNull: 'Invalid argument',
cbDataIsNull: 'napi_ok',
propertiesIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});

View File

@@ -143,28 +143,28 @@ 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',
});
@@ -172,47 +172,47 @@ 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',
});

View File

@@ -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();

View File

@@ -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
@@ -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

View File

@@ -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',
},
);

View File

@@ -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
@@ -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
@@ -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.

View File

@@ -61,7 +61,7 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
function compareToNative(theObject, theConstructor) {
assert.strictEqual(
addon.doInstanceOf(theObject, theConstructor),
(theObject instanceof theConstructor)
(theObject instanceof theConstructor),
);
}
@@ -69,7 +69,7 @@ if (typeof Symbol !== 'undefined' && 'hasInstance' in Symbol &&
Object.defineProperty(MyClass, Symbol.hasInstance, {
value: function(candidate) {
return 'mark' in candidate;
}
},
});
function MySubClass() {}

View File

@@ -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');
@@ -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 });
@@ -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));
@@ -236,7 +236,7 @@ assert.strictEqual(newObject.test_string, 'test string');
// and includes indices and converts them to strings.
const object = { __proto__: {
inherited: 1
inherited: 1,
} };
const fooSymbol = Symbol('foo');
@@ -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;
@@ -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
@@ -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
@@ -326,7 +326,7 @@ assert.deepStrictEqual(test_object.TestGetProperty(), {
envIsNull: 'Invalid argument',
objectIsNull: 'Invalid argument',
keyIsNull: 'Invalid argument',
resultIsNull: 'Invalid argument'
resultIsNull: 'Invalid argument',
});
{

View File

@@ -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);
@@ -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);