commit: 756d4366582bfce947aca17e9d79a0e3111a38b2
parent fba2cb52ed2d9ee243f189e61f454e1ead89834c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Sat, 16 Sep 2023 17:33:57 +0200
Add format script
Diffstat:
4 files changed, 54 insertions(+), 25 deletions(-)
diff --git a/.clang-format b/.clang-format
@@ -0,0 +1,23 @@
+# SPDX-FileCopyrightText: 2017-2022 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+AlignAfterOpenBracket: true
+AlignConsecutiveAssignments: true
+AlignOperands: true
+AlignTrailingComments: true
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: true
+AllowShortIfStatementsOnASingleLine: true
+AlwaysBreakAfterReturnType: AllDefinitions
+BinPackArguments: false
+BinPackParameters: false
+BreakBeforeBraces: Allman
+SpaceBeforeParens: Never
+IncludeBlocks: Regroup
+ReflowComments: false
+SortIncludes: true
+UseTab: ForIndentation
+IndentWidth: 2
+TabWidth: 2
+ColumnLimit: 100
+
+NamespaceIndentation: All
diff --git a/index.js b/index.js
@@ -5,15 +5,14 @@
const test = require('node:test');
-function notOk(value, msg) {
- return assert.ok(!value, msg);
-};
+function notOk(value, msg) { return assert.ok(!value, msg); };
var onFailure = [];
// test([name], [opts], cb)
module.exports = function(name, opts, cb) {
- function setup_cb(t) {
+ function setup_cb(t)
+ {
const assert = require('node:assert/strict');
// t.plan(n)
@@ -32,8 +31,8 @@ module.exports = function(name, opts, cb) {
// t.ok(value, msg) → assert.ok(value[, message])
// Aliases: t.true(), t.assert()
- t.ok = assert.ok;
- t.true = assert.ok;
+ t.ok = assert.ok;
+ t.true = assert.ok;
t.assert = assert.ok;
// t.notOk(value, msg) → assert.ok(!value[, message])
@@ -47,12 +46,12 @@ module.exports = function(name, opts, cb) {
// t.equal(actual, expected, msg) → assert.equal(actual, expected[, message])
// Aliases: t.equals(), t.isEqual(), t.strictEqual(), t.strictEquals(), t.is()
- t.equal = assert.equal;
- t.equals = assert.equal;
- t.isEqual = assert.equal;
- t.strictEqual = assert.strictEqual;
+ t.equal = assert.equal;
+ t.equals = assert.equal;
+ t.isEqual = assert.equal;
+ t.strictEqual = assert.strictEqual;
t.strictEquals = assert.strictEqual;
- t.is = assert.equal;
+ t.is = assert.equal;
// t.notEqual(actual, expected, msg)
// Aliases: t.notEquals(), t.isNotEqual(), t.doesNotEqual(), t.isInequal(), t.notStrictEqual(), t.notStrictEquals(), t.isNot(), t.not()
@@ -87,15 +86,25 @@ module.exports = function(name, opts, cb) {
// t.doesNotMatch(string, regexp, message)
};
- switch(arguments.length) {
+ switch(arguments.length)
+ {
case 1:
- test((t) => { setup_cb(t); arguments[0](t) });
+ test((t) => {
+ setup_cb(t);
+ arguments[0](t)
+ });
break;
case 2:
- test(arguments[0], (t) => { setup_cb(t); arguments[1](t) });
+ test(arguments[0], (t) => {
+ setup_cb(t);
+ arguments[1](t)
+ });
break;
case 3:
- test(arguments[0], arguments[1], (t) => { setup_cb(t); arguments[2](t) });
+ test(arguments[0], arguments[1], (t) => {
+ setup_cb(t);
+ arguments[2](t)
+ });
break;
default:
abort();
diff --git a/package.json b/package.json
@@ -16,7 +16,8 @@
},
"exports": "./index.js",
"scripts": {
- "test": "node test"
+ "test": "node test",
+ "format": "clang-format -i *.js"
},
"engines": {
"node": ">=18.0.0"
diff --git a/test.js b/test.js
@@ -4,17 +4,13 @@
var test = require('tape-lite');
// no name
-test(function(t) {
- t.equal(typeof Date.now, 'function');
-});
+test(function(t) { t.equal(typeof Date.now, 'function'); });
-test('name + callback', function (t) {
- t.equal(typeof Date.now, 'function');
-});
+test('name + callback', function(t) { t.equal(typeof Date.now, 'function'); });
-test('name + opts + callback', {skip: false}, function (t) {
- t.equal(typeof Date.now, 'function');
-});
+test('name + opts + callback',
+ {skip : false},
+ function(t) { t.equal(typeof Date.now, 'function'); });
/*
test('test using promises', async function (t) {