@falsejs/falsejs 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/biome.json +7 -11
- package/dist/index.js +50 -9
- package/dist/index.js.map +1 -1
- package/package.json +405 -407
- package/preinstall.js +7 -0
- package/spec/ava.test.js +38 -35
- package/spec/jasmine.test.js +71 -75
- package/spec/jest.test.js +90 -90
- package/spec/manual.test.js +80 -80
- package/spec/mocha.test.js +73 -73
- package/spec/qunit.test.js +44 -34
- package/spec/run_all_tests.js +182 -171
- package/spec/tape.test.js +37 -33
- package/tsconfig.json +45 -45
- package/.falsejs/test-log.txt +0 -5201
package/spec/mocha.test.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
// spec/mocha.test.js
|
|
2
|
-
|
|
3
|
-
const { expect } = require("chai")
|
|
4
|
-
|
|
5
|
-
const fjs = require("../dist/index").default
|
|
6
|
-
const False = fjs.False
|
|
7
|
-
const isFalse = fjs.isFalse
|
|
8
|
-
const expressMiddleware = fjs.expressMiddleware
|
|
9
|
-
const injectIntojQuery = fjs.injectIntojQuery
|
|
10
|
-
|
|
11
|
-
// Define the expected boolean values based on the original code
|
|
12
|
-
const FALSE = 1 == 3
|
|
13
|
-
const TRUE = 1 == 1
|
|
14
|
-
|
|
15
|
-
// Load jQuery globally for the injection test
|
|
16
|
-
global.jQuery = require("jquery")
|
|
17
|
-
|
|
18
|
-
// --- Sampled Combinations ---
|
|
19
|
-
// The same small, representative set for fast testing.
|
|
20
|
-
const combinations = [
|
|
21
|
-
["no", "no", "no", "no", "no", "no", "none"],
|
|
22
|
-
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
23
|
-
["no", "yes", "no", "no", "yes", "yes", "ie5"],
|
|
24
|
-
["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
|
|
25
|
-
]
|
|
26
|
-
// ---
|
|
27
|
-
|
|
28
|
-
// Mock data for integration tests
|
|
29
|
-
const mockRequest = {}
|
|
30
|
-
const mockResponse = {}
|
|
31
|
-
const mockNext = () => {} // Simple next function for middleware
|
|
32
|
-
|
|
33
|
-
describe("FalseJS Library Tests (Mocha)", function () {
|
|
34
|
-
describe("Core Functions", function () {
|
|
35
|
-
// Test combinations using Mocha's dynamic test generation
|
|
36
|
-
combinations.forEach((params, index) => {
|
|
37
|
-
it(`Combination ${index + 1}: False(${params.join(", ")}) should return FALSE`, function () {
|
|
38
|
-
// Assertion: False(...params) should return the literal value 'false'
|
|
39
|
-
expect(False(...params)).to.equal(FALSE)
|
|
40
|
-
})
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it("isFalse(FALSE) should return TRUE", function () {
|
|
44
|
-
expect(isFalse(FALSE)).to.equal(TRUE)
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
it("isFalse(TRUE) should return FALSE", function () {
|
|
48
|
-
expect(isFalse(TRUE)).to.equal(FALSE)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
describe("Integration Tests", function () {
|
|
53
|
-
it("jQuery injection should work", function () {
|
|
54
|
-
injectIntojQuery()
|
|
55
|
-
expect(global.jQuery.False).to.equal(False)
|
|
56
|
-
expect(global.jQuery.isFalse).to.equal(isFalse)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it("Express middleware injection should work", function (done) {
|
|
60
|
-
// Run the middleware
|
|
61
|
-
expressMiddleware(mockRequest, mockResponse, mockNext)
|
|
62
|
-
|
|
63
|
-
// Check injections
|
|
64
|
-
expect(mockRequest.False).to.equal(False)
|
|
65
|
-
expect(mockRequest.isFalse).to.equal(isFalse)
|
|
66
|
-
|
|
67
|
-
// Use a timeout to ensure any async logging is complete, similar to Jest/Manual
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
done() // Signal Mocha the async test is complete
|
|
70
|
-
}, 100)
|
|
71
|
-
}).timeout(10000) // Set a high timeout for async stability
|
|
72
|
-
})
|
|
73
|
-
})
|
|
1
|
+
// spec/mocha.test.js
|
|
2
|
+
|
|
3
|
+
const { expect } = require("chai")
|
|
4
|
+
|
|
5
|
+
const fjs = require("../dist/index").default
|
|
6
|
+
const False = fjs.False
|
|
7
|
+
const isFalse = fjs.isFalse
|
|
8
|
+
const expressMiddleware = fjs.expressMiddleware
|
|
9
|
+
const injectIntojQuery = fjs.injectIntojQuery
|
|
10
|
+
|
|
11
|
+
// Define the expected boolean values based on the original code
|
|
12
|
+
const FALSE = 1 == 3
|
|
13
|
+
const TRUE = 1 == 1
|
|
14
|
+
|
|
15
|
+
// Load jQuery globally for the injection test
|
|
16
|
+
global.jQuery = require("jquery")
|
|
17
|
+
|
|
18
|
+
// --- Sampled Combinations ---
|
|
19
|
+
// The same small, representative set for fast testing.
|
|
20
|
+
const combinations = [
|
|
21
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
22
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
23
|
+
["no", "yes", "no", "no", "yes", "yes", "ie5"],
|
|
24
|
+
["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
|
|
25
|
+
]
|
|
26
|
+
// ---
|
|
27
|
+
|
|
28
|
+
// Mock data for integration tests
|
|
29
|
+
const mockRequest = {}
|
|
30
|
+
const mockResponse = {}
|
|
31
|
+
const mockNext = () => {} // Simple next function for middleware
|
|
32
|
+
|
|
33
|
+
describe("FalseJS Library Tests (Mocha)", function () {
|
|
34
|
+
describe("Core Functions", function () {
|
|
35
|
+
// Test combinations using Mocha's dynamic test generation
|
|
36
|
+
combinations.forEach((params, index) => {
|
|
37
|
+
it(`Combination ${index + 1}: False(${params.join(", ")}) should return FALSE`, function () {
|
|
38
|
+
// Assertion: False(...params) should return the literal value 'false'
|
|
39
|
+
expect(False(...params)).to.equal(FALSE)
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("isFalse(FALSE) should return TRUE", function () {
|
|
44
|
+
expect(isFalse(FALSE)).to.equal(TRUE)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
it("isFalse(TRUE) should return FALSE", function () {
|
|
48
|
+
expect(isFalse(TRUE)).to.equal(FALSE)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
describe("Integration Tests", function () {
|
|
53
|
+
it("jQuery injection should work", function () {
|
|
54
|
+
injectIntojQuery()
|
|
55
|
+
expect(global.jQuery.False).to.equal(False)
|
|
56
|
+
expect(global.jQuery.isFalse).to.equal(isFalse)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("Express middleware injection should work", function (done) {
|
|
60
|
+
// Run the middleware
|
|
61
|
+
expressMiddleware(mockRequest, mockResponse, mockNext)
|
|
62
|
+
|
|
63
|
+
// Check injections
|
|
64
|
+
expect(mockRequest.False).to.equal(False)
|
|
65
|
+
expect(mockRequest.isFalse).to.equal(isFalse)
|
|
66
|
+
|
|
67
|
+
// Use a timeout to ensure any async logging is complete, similar to Jest/Manual
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
done() // Signal Mocha the async test is complete
|
|
70
|
+
}, 100)
|
|
71
|
+
}).timeout(10000) // Set a high timeout for async stability
|
|
72
|
+
})
|
|
73
|
+
})
|
package/spec/qunit.test.js
CHANGED
|
@@ -1,34 +1,44 @@
|
|
|
1
|
-
// spec/qunit.test.js
|
|
2
|
-
|
|
3
|
-
const QUnit = require(
|
|
4
|
-
const fjs = require("../dist/index").default
|
|
5
|
-
const False = fjs.False
|
|
6
|
-
const isFalse = fjs.isFalse
|
|
7
|
-
|
|
8
|
-
// Define constants
|
|
9
|
-
const FALSE = 1 == 3
|
|
10
|
-
const TRUE = 1 == 1
|
|
11
|
-
|
|
12
|
-
// Sampled Combinations
|
|
13
|
-
const combinations = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
]
|
|
17
|
-
|
|
18
|
-
QUnit.module(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
// spec/qunit.test.js
|
|
2
|
+
|
|
3
|
+
const QUnit = require("qunit")
|
|
4
|
+
const fjs = require("../dist/index").default
|
|
5
|
+
const False = fjs.False
|
|
6
|
+
const isFalse = fjs.isFalse
|
|
7
|
+
|
|
8
|
+
// Define constants
|
|
9
|
+
const FALSE = 1 == 3
|
|
10
|
+
const TRUE = 1 == 1
|
|
11
|
+
|
|
12
|
+
// Sampled Combinations
|
|
13
|
+
const combinations = [
|
|
14
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
15
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
QUnit.module("FalseJS Library Tests (QUnit)", function (_hooks) {
|
|
19
|
+
QUnit.test(
|
|
20
|
+
"Core Function: isFalse(FALSE) should return TRUE",
|
|
21
|
+
function (assert) {
|
|
22
|
+
assert.true(isFalse(FALSE) === TRUE, "isFalse(false) must return true")
|
|
23
|
+
},
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
QUnit.test(
|
|
27
|
+
"Core Function: isFalse(TRUE) should return FALSE",
|
|
28
|
+
function (assert) {
|
|
29
|
+
assert.true(isFalse(TRUE) === FALSE, "isFalse(true) must return false")
|
|
30
|
+
},
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
combinations.forEach((params) => {
|
|
34
|
+
QUnit.test(
|
|
35
|
+
`Core Function: False(${params.join(", ")}) should return FALSE`,
|
|
36
|
+
function (assert) {
|
|
37
|
+
assert.true(
|
|
38
|
+
False(...params) === FALSE,
|
|
39
|
+
`False() must return false for params: ${params.join(", ")}`,
|
|
40
|
+
)
|
|
41
|
+
},
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
})
|
package/spec/run_all_tests.js
CHANGED
|
@@ -1,171 +1,182 @@
|
|
|
1
|
-
// run_all_tests.js
|
|
2
|
-
|
|
3
|
-
const { execSync } = require(
|
|
4
|
-
const fs = require(
|
|
5
|
-
const path = require(
|
|
6
|
-
const clc = require(
|
|
7
|
-
|
|
8
|
-
// --- Commands and Paths ---
|
|
9
|
-
const JEST_COMMAND =
|
|
10
|
-
const MOCHA_COMMAND =
|
|
11
|
-
const JASMINE_COMMAND =
|
|
12
|
-
const AVA_COMMAND =
|
|
13
|
-
const QUNIT_COMMAND =
|
|
14
|
-
const TAPE_COMMAND =
|
|
15
|
-
const MANUAL_COMMAND =
|
|
16
|
-
// INTERN_COMMAND has been removed
|
|
17
|
-
const OUTPUT_DIR =
|
|
18
|
-
const OUTPUT_FILE = path.join(OUTPUT_DIR,
|
|
19
|
-
|
|
20
|
-
let outputLog =
|
|
21
|
-
let jestPassed = false
|
|
22
|
-
let mochaPassed = false
|
|
23
|
-
let jasminePassed = false
|
|
24
|
-
let avaPassed = false
|
|
25
|
-
let qunitPassed = false
|
|
26
|
-
let tapePassed = false
|
|
27
|
-
// internPassed flag removed
|
|
28
|
-
let manualPassed = false
|
|
29
|
-
let allPassed = false
|
|
30
|
-
|
|
31
|
-
const log = (message, colorFn = clc.white) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function runCommand(command) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// --- Test Execution ---
|
|
47
|
-
|
|
48
|
-
log(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
//
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
//
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (!
|
|
170
|
-
|
|
171
|
-
}
|
|
1
|
+
// run_all_tests.js
|
|
2
|
+
|
|
3
|
+
const { execSync } = require("node:child_process")
|
|
4
|
+
const fs = require("node:fs")
|
|
5
|
+
const path = require("node:path")
|
|
6
|
+
const clc = require("cli-color")
|
|
7
|
+
|
|
8
|
+
// --- Commands and Paths ---
|
|
9
|
+
const JEST_COMMAND = "npx jest spec/jest.test.js"
|
|
10
|
+
const MOCHA_COMMAND = "npx mocha spec/mocha.test.js"
|
|
11
|
+
const JASMINE_COMMAND = "npx jasmine spec/jasmine.test.js"
|
|
12
|
+
const AVA_COMMAND = "npx ava spec/ava.test.js"
|
|
13
|
+
const QUNIT_COMMAND = "node spec/qunit.test.js"
|
|
14
|
+
const TAPE_COMMAND = "node spec/tape.test.js"
|
|
15
|
+
const MANUAL_COMMAND = "node spec/manual.test.js"
|
|
16
|
+
// INTERN_COMMAND has been removed
|
|
17
|
+
const OUTPUT_DIR = ".falsejs"
|
|
18
|
+
const OUTPUT_FILE = path.join(OUTPUT_DIR, "test-log.txt")
|
|
19
|
+
|
|
20
|
+
let outputLog = ""
|
|
21
|
+
let jestPassed = false
|
|
22
|
+
let mochaPassed = false
|
|
23
|
+
let jasminePassed = false
|
|
24
|
+
let avaPassed = false
|
|
25
|
+
let qunitPassed = false
|
|
26
|
+
let tapePassed = false
|
|
27
|
+
// internPassed flag removed
|
|
28
|
+
let manualPassed = false
|
|
29
|
+
let allPassed = false
|
|
30
|
+
|
|
31
|
+
const log = (message, colorFn = clc.white) => {
|
|
32
|
+
console.log(colorFn(message))
|
|
33
|
+
outputLog += `${message}\n`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function runCommand(command) {
|
|
37
|
+
try {
|
|
38
|
+
const output = execSync(command, { encoding: "utf8", stdio: "pipe" })
|
|
39
|
+
return { success: true, output }
|
|
40
|
+
} catch (error) {
|
|
41
|
+
const errorOutput = (error.stdout || "") + (error.stderr || "")
|
|
42
|
+
return { success: false, output: errorOutput }
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// --- Test Execution ---
|
|
47
|
+
|
|
48
|
+
log("--- Starting Comprehensive Test Suite (7 Suites) ---", clc.yellow)
|
|
49
|
+
|
|
50
|
+
// 1. Run Manual Tests (First)
|
|
51
|
+
// -----------------------------------------------------------------------------
|
|
52
|
+
log("\n>> Running Manual Test (spec/manual.test.js)...", clc.cyan)
|
|
53
|
+
const manualResult = runCommand(MANUAL_COMMAND)
|
|
54
|
+
outputLog += manualResult.output
|
|
55
|
+
|
|
56
|
+
if (manualResult.success && manualResult.output.includes("✓ TESTS PASSED")) {
|
|
57
|
+
manualPassed = true
|
|
58
|
+
log("✓ MANUAL TESTS PASSED.", clc.green)
|
|
59
|
+
} else {
|
|
60
|
+
log("× MANUAL TESTS FAILED (Exit Code Error).", clc.red)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 2. Run Jest Tests (Second)
|
|
64
|
+
// -----------------------------------------------------------------------------
|
|
65
|
+
log("\n>> Running Jest Test (spec/jest.test.js)...", clc.cyan)
|
|
66
|
+
const jestResult = runCommand(JEST_COMMAND)
|
|
67
|
+
outputLog += jestResult.output
|
|
68
|
+
|
|
69
|
+
if (jestResult.success) {
|
|
70
|
+
jestPassed = true
|
|
71
|
+
log("✓ JEST TESTS PASSED.", clc.green)
|
|
72
|
+
} else {
|
|
73
|
+
log("× JEST TESTS FAILED.", clc.red)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 3. Run Tape Tests (Third)
|
|
77
|
+
// -----------------------------------------------------------------------------
|
|
78
|
+
log("\n>> Running Tape Test (spec/tape.test.js)...", clc.cyan)
|
|
79
|
+
const tapeResult = runCommand(TAPE_COMMAND)
|
|
80
|
+
outputLog += tapeResult.output
|
|
81
|
+
|
|
82
|
+
if (tapeResult.success && !tapeResult.output.includes("not ok")) {
|
|
83
|
+
tapePassed = true
|
|
84
|
+
log("✓ TAPE TESTS PASSED.", clc.green)
|
|
85
|
+
} else {
|
|
86
|
+
log("× TAPE TESTS FAILED.", clc.red)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 4. Run Mocha Tests (Fourth)
|
|
90
|
+
// -----------------------------------------------------------------------------
|
|
91
|
+
log("\n>> Running Mocha Test (spec/mocha.test.js)...", clc.cyan)
|
|
92
|
+
const mochaResult = runCommand(MOCHA_COMMAND)
|
|
93
|
+
outputLog += mochaResult.output
|
|
94
|
+
|
|
95
|
+
if (mochaResult.success) {
|
|
96
|
+
mochaPassed = true
|
|
97
|
+
log("✓ MOCHA TESTS PASSED.", clc.green)
|
|
98
|
+
} else {
|
|
99
|
+
log("× MOCHA TESTS FAILED.", clc.red)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 5. Run Jasmine Tests (Fifth)
|
|
103
|
+
// -----------------------------------------------------------------------------
|
|
104
|
+
log("\n>> Running Jasmine Test (spec/jasmine.test.js)...", clc.cyan)
|
|
105
|
+
const jasmineResult = runCommand(JASMINE_COMMAND)
|
|
106
|
+
outputLog += jasmineResult.output
|
|
107
|
+
|
|
108
|
+
if (jasmineResult.success) {
|
|
109
|
+
jasminePassed = true
|
|
110
|
+
log("✓ JASMINE TESTS PASSED.", clc.green)
|
|
111
|
+
} else {
|
|
112
|
+
log("× JASMINE TESTS FAILED.", clc.red)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// 6. Run AVA Tests (Sixth)
|
|
116
|
+
// -----------------------------------------------------------------------------
|
|
117
|
+
log("\n>> Running AVA Test (spec/ava.test.js)...", clc.cyan)
|
|
118
|
+
const avaResult = runCommand(AVA_COMMAND)
|
|
119
|
+
outputLog += avaResult.output
|
|
120
|
+
|
|
121
|
+
if (avaResult.success) {
|
|
122
|
+
avaPassed = true
|
|
123
|
+
log("✓ AVA TESTS PASSED.", clc.green)
|
|
124
|
+
} else {
|
|
125
|
+
log("× AVA TESTS FAILED.", clc.red)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 7. Run QUnit Tests (Seventh)
|
|
129
|
+
// -----------------------------------------------------------------------------
|
|
130
|
+
log("\n>> Running QUnit Test (spec/qunit.test.js)...", clc.cyan)
|
|
131
|
+
const qunitResult = runCommand(QUNIT_COMMAND)
|
|
132
|
+
outputLog += qunitResult.output
|
|
133
|
+
|
|
134
|
+
if (qunitResult.success && !qunitResult.output.includes("failed: 0")) {
|
|
135
|
+
qunitPassed = true
|
|
136
|
+
log("✓ QUNIT TESTS PASSED.", clc.green)
|
|
137
|
+
} else if (qunitResult.success && qunitResult.output.includes("failed: 0")) {
|
|
138
|
+
qunitPassed = true
|
|
139
|
+
log("✓ QUNIT TESTS PASSED.", clc.green)
|
|
140
|
+
} else {
|
|
141
|
+
log("× QUNIT TESTS FAILED.", clc.red)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 8. Final Result Summary
|
|
145
|
+
// -----------------------------------------------------------------------------
|
|
146
|
+
log("\n--- Final Test Suite Result ---", clc.yellow)
|
|
147
|
+
|
|
148
|
+
if (
|
|
149
|
+
jestPassed &&
|
|
150
|
+
mochaPassed &&
|
|
151
|
+
jasminePassed &&
|
|
152
|
+
manualPassed &&
|
|
153
|
+
avaPassed &&
|
|
154
|
+
qunitPassed &&
|
|
155
|
+
tapePassed
|
|
156
|
+
) {
|
|
157
|
+
allPassed = true
|
|
158
|
+
log(" ALL 7 TEST SUITES PASSED SUCCESSFULLY! ", clc.bgGreen.bold)
|
|
159
|
+
} else {
|
|
160
|
+
log(
|
|
161
|
+
" 1 or more TEST SUITES FAILED. Check logs above and in test-log.txt. ",
|
|
162
|
+
clc.bgRed.bold,
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// 9. Output to File and Exit
|
|
167
|
+
// -----------------------------------------------------------------------------
|
|
168
|
+
try {
|
|
169
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
170
|
+
fs.mkdirSync(OUTPUT_DIR)
|
|
171
|
+
}
|
|
172
|
+
fs.writeFileSync(OUTPUT_FILE, outputLog)
|
|
173
|
+
console.log(clc.yellow(`\nTest results written to ${OUTPUT_FILE}`))
|
|
174
|
+
} catch {
|
|
175
|
+
console.error(
|
|
176
|
+
clc.red("\nERROR: Could not write test results to output file."),
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (!allPassed) {
|
|
181
|
+
process.exit(1)
|
|
182
|
+
}
|
package/spec/tape.test.js
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
|
-
// spec/tape.test.js
|
|
2
|
-
|
|
3
|
-
const test = require(
|
|
4
|
-
|
|
5
|
-
// Load the library components from the specified path
|
|
6
|
-
const fjs = require("../dist/index").default
|
|
7
|
-
const False = fjs.False
|
|
8
|
-
const isFalse = fjs.isFalse
|
|
9
|
-
|
|
10
|
-
// Define constants
|
|
11
|
-
const FALSE = 1 == 3
|
|
12
|
-
const TRUE = 1 == 1
|
|
13
|
-
|
|
14
|
-
// Sampled Combinations
|
|
15
|
-
const combinations = [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
]
|
|
19
|
-
|
|
20
|
-
// Tape uses the 't' object for assertions (t.equal, t.ok, t.plan)
|
|
21
|
-
|
|
22
|
-
test(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
// spec/tape.test.js
|
|
2
|
+
|
|
3
|
+
const test = require("tape")
|
|
4
|
+
|
|
5
|
+
// Load the library components from the specified path
|
|
6
|
+
const fjs = require("../dist/index").default
|
|
7
|
+
const False = fjs.False
|
|
8
|
+
const isFalse = fjs.isFalse
|
|
9
|
+
|
|
10
|
+
// Define constants
|
|
11
|
+
const FALSE = 1 == 3
|
|
12
|
+
const TRUE = 1 == 1
|
|
13
|
+
|
|
14
|
+
// Sampled Combinations
|
|
15
|
+
const combinations = [
|
|
16
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
17
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
// Tape uses the 't' object for assertions (t.equal, t.ok, t.plan)
|
|
21
|
+
|
|
22
|
+
test("FalseJS Core Functions", function (t) {
|
|
23
|
+
// Plan the number of assertions expected in this main block (2 assertions + 2 combination blocks * 2 assertions each)
|
|
24
|
+
t.plan(2 + combinations.length)
|
|
25
|
+
|
|
26
|
+
t.equal(isFalse(FALSE), TRUE, "isFalse(FALSE) should return TRUE")
|
|
27
|
+
t.equal(isFalse(TRUE), FALSE, "isFalse(TRUE) should return FALSE")
|
|
28
|
+
|
|
29
|
+
combinations.forEach((params) => {
|
|
30
|
+
// Check if False() returns the exact FALSE constant (which is boolean false)
|
|
31
|
+
t.equal(
|
|
32
|
+
False(...params),
|
|
33
|
+
FALSE,
|
|
34
|
+
`False(${params.join(", ")}) should return FALSE`,
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
})
|