@falsejs/falsejs 3.1.0 → 3.2.0
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/.falsejs/test-log.txt +5201 -0
- package/README.md +3 -0
- package/dist/index.js +254 -1923
- package/dist/index.js.map +1 -1
- package/package.json +407 -404
- package/spec/ava.test.js +35 -0
- package/spec/jasmine.test.js +75 -0
- package/spec/jest.test.js +90 -0
- package/spec/manual.test.js +80 -0
- package/spec/mocha.test.js +73 -0
- package/spec/qunit.test.js +34 -0
- package/spec/run_all_tests.js +171 -0
- package/spec/tape.test.js +33 -0
- package/Sanity.md +0 -17
package/spec/ava.test.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// spec/ava.test.js
|
|
2
|
+
|
|
3
|
+
const test = require('ava')
|
|
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
|
+
// AVA tests use t.true() or t.is() for assertions.
|
|
19
|
+
// We use test.serial to prevent potential state interference between tests.
|
|
20
|
+
|
|
21
|
+
test.serial('Core Function: isFalse(FALSE) should return TRUE', t => {
|
|
22
|
+
// t.true checks if the expression evaluates to the boolean true
|
|
23
|
+
t.true(isFalse(FALSE) === TRUE)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test.serial('Core Function: isFalse(TRUE) should return FALSE', t => {
|
|
27
|
+
t.true(isFalse(TRUE) === FALSE)
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
combinations.forEach((params, index) => {
|
|
31
|
+
test.serial(`Core Function: False(${params.join(", ")}) should return FALSE`, t => {
|
|
32
|
+
// We check if the result of False() is strictly equal to the constant FALSE
|
|
33
|
+
t.is(False(...params), FALSE)
|
|
34
|
+
})
|
|
35
|
+
})
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// spec/jasmine.test.js
|
|
2
|
+
|
|
3
|
+
// Load the library components from the specified path
|
|
4
|
+
const fjs = require("../dist/index").default
|
|
5
|
+
const False = fjs.False
|
|
6
|
+
const isFalse = fjs.isFalse
|
|
7
|
+
const expressMiddleware = fjs.expressMiddleware
|
|
8
|
+
const injectIntojQuery = fjs.injectIntojQuery
|
|
9
|
+
|
|
10
|
+
// Define the expected boolean values based on the original code
|
|
11
|
+
const FALSE = 1 == 3
|
|
12
|
+
const TRUE = 1 == 1
|
|
13
|
+
|
|
14
|
+
// Load jQuery globally for the injection test
|
|
15
|
+
global.jQuery = require("jquery")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
// --- Sampled Combinations ---
|
|
19
|
+
const combinations = [
|
|
20
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
21
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
22
|
+
["no", "yes", "no", "no", "yes", "yes", "ie5"],
|
|
23
|
+
["yes", "no", "yes", "yes", "no", "yes", "opera_presto"]
|
|
24
|
+
]
|
|
25
|
+
// ---
|
|
26
|
+
|
|
27
|
+
// Mock data for integration tests
|
|
28
|
+
const mockRequest = {}
|
|
29
|
+
const mockResponse = {}
|
|
30
|
+
const mockNext = () => {} // Simple next function for middleware
|
|
31
|
+
|
|
32
|
+
describe("FalseJS Library Tests (Jasmine)", () => {
|
|
33
|
+
|
|
34
|
+
describe("Core Functions", () => {
|
|
35
|
+
|
|
36
|
+
// Test combinations using Jasmine's dynamic test generation
|
|
37
|
+
combinations.forEach((params) => {
|
|
38
|
+
it(`False(${params.join(", ")}) should return the calculated FALSE`, () => {
|
|
39
|
+
// Assertion: False(...params) should return the literal value 'false'
|
|
40
|
+
expect(False(...params)).toBe(FALSE)
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it("isFalse(FALSE) should return TRUE", () => {
|
|
45
|
+
expect(isFalse(FALSE)).toBe(TRUE)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it("isFalse(TRUE) should return FALSE", () => {
|
|
49
|
+
expect(isFalse(TRUE)).toBe(FALSE)
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
describe("Integration Tests", () => {
|
|
54
|
+
|
|
55
|
+
it("jQuery injection should work", () => {
|
|
56
|
+
injectIntojQuery()
|
|
57
|
+
expect(global.jQuery.False).toBe(False)
|
|
58
|
+
expect(global.jQuery.isFalse).toBe(isFalse)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it("Express middleware injection should work", (done) => {
|
|
62
|
+
// Run the middleware
|
|
63
|
+
expressMiddleware(mockRequest, mockResponse, mockNext)
|
|
64
|
+
|
|
65
|
+
// Check injections
|
|
66
|
+
expect(mockRequest.False).toBe(False)
|
|
67
|
+
expect(mockRequest.isFalse).toBe(isFalse)
|
|
68
|
+
|
|
69
|
+
// Use a timeout to ensure any async logging is complete
|
|
70
|
+
setTimeout(() => {
|
|
71
|
+
done() // Signal Jasmine the async test is complete
|
|
72
|
+
}, 100)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// spec/jest.test.js
|
|
2
|
+
|
|
3
|
+
// Mock the required modules since the original tests use global side effects
|
|
4
|
+
const mockRequest = {}
|
|
5
|
+
const mockResponse = {}
|
|
6
|
+
const mockNext = jest.fn()
|
|
7
|
+
|
|
8
|
+
describe("FalseJS Library Tests (Sampled Combinations)", () => {
|
|
9
|
+
let False
|
|
10
|
+
let isFalse
|
|
11
|
+
let expressMiddleware
|
|
12
|
+
let injectIntojQuery
|
|
13
|
+
let jQuery
|
|
14
|
+
|
|
15
|
+
// --- Sampled Combinations ---
|
|
16
|
+
// A representative subset of the original 2048 combinations for fast testing.
|
|
17
|
+
// The structure is: [B, B, B, B, B, B, C] where B=Boolean, C=Compat
|
|
18
|
+
const combinations = [
|
|
19
|
+
// 1. All "no", testing the "none" compat option
|
|
20
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
21
|
+
|
|
22
|
+
// 2. All "yes" for first three, testing the 'netscape' compat option
|
|
23
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
24
|
+
|
|
25
|
+
// 3. Testing a mixed set with 'ie5'
|
|
26
|
+
["no", "yes", "no", "no", "yes", "yes", "ie5"],
|
|
27
|
+
|
|
28
|
+
// 4. Testing another mixed set with 'opera_presto'
|
|
29
|
+
["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
|
|
30
|
+
]
|
|
31
|
+
// ---
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
// Load the library components from the specified path: ../dist/index
|
|
35
|
+
const fjs = require("../dist/index").default
|
|
36
|
+
False = fjs.False
|
|
37
|
+
isFalse = fjs.isFalse
|
|
38
|
+
expressMiddleware = fjs.expressMiddleware
|
|
39
|
+
injectIntojQuery = fjs.injectIntojQuery
|
|
40
|
+
|
|
41
|
+
// Define the expected boolean values based on the original code
|
|
42
|
+
// FALSE = 1 == 3 (false); TRUE = 1 == 1 (true)
|
|
43
|
+
global.FALSE = 1 == 3
|
|
44
|
+
global.TRUE = 1 == 1
|
|
45
|
+
|
|
46
|
+
// Load jQuery globally for the injection test
|
|
47
|
+
global.jQuery = require("jquery")
|
|
48
|
+
jQuery = global.jQuery
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
// We use the 'done' callback to ensure Jest waits for the asynchronous
|
|
52
|
+
// logging in your library to complete, preventing the "Cannot log after tests are done" error.
|
|
53
|
+
test("All FalseJS functions and integrations should work", (done) => {
|
|
54
|
+
// --- 1. Core Functions Test (Synchronous Assertions) ---
|
|
55
|
+
|
|
56
|
+
// False function testing for all sampled combinations
|
|
57
|
+
combinations.forEach((params) => {
|
|
58
|
+
// Original assertion: assert(False(...params) === FALSE)
|
|
59
|
+
expect(False(...params)).toBe(global.FALSE)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// isFalse function testing
|
|
63
|
+
// Original assertions: assert(isFalse(FALSE) === TRUE), assert(isFalse(TRUE) === FALSE)
|
|
64
|
+
expect(isFalse(global.FALSE)).toBe(global.TRUE)
|
|
65
|
+
expect(isFalse(global.TRUE)).toBe(global.FALSE)
|
|
66
|
+
|
|
67
|
+
// --- 2. Integration Tests (Synchronous Assertions) ---
|
|
68
|
+
|
|
69
|
+
// jQuery injection test
|
|
70
|
+
injectIntojQuery()
|
|
71
|
+
// Original assertion: assert(jQuery.False == False && jQuery.isFalse == isFalse)
|
|
72
|
+
expect(jQuery.False).toBe(False)
|
|
73
|
+
expect(jQuery.isFalse).toBe(isFalse)
|
|
74
|
+
|
|
75
|
+
// Express middleware test
|
|
76
|
+
expressMiddleware(mockRequest, mockResponse, mockNext)
|
|
77
|
+
// Original assertions: assert(request.False == False), assert(request.isFalse == isFalse)
|
|
78
|
+
expect(mockRequest.False).toBe(False)
|
|
79
|
+
expect(mockRequest.isFalse).toBe(isFalse)
|
|
80
|
+
expect(mockNext).toHaveBeenCalledTimes(1)
|
|
81
|
+
|
|
82
|
+
// --- 3. Async Completion (Fixing the "Cannot log" Error) ---
|
|
83
|
+
|
|
84
|
+
// Use a short setTimeout to mimic the original manual test's delay and
|
|
85
|
+
// ensure any lingering async operations (like the log call) complete.
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
done() // Tell Jest the test is finished only after the delay
|
|
88
|
+
}, 100)
|
|
89
|
+
}, 10000) // 10-second timeout for this test
|
|
90
|
+
})
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// DO TESTS MANUALLY
|
|
2
|
+
|
|
3
|
+
function doTests(testName, fjs) {
|
|
4
|
+
const { False, isFalse, expressMiddleware, injectIntojQuery } = fjs
|
|
5
|
+
const assert = require("assert-fn")
|
|
6
|
+
const attempt = require("attempt-statement")
|
|
7
|
+
const n0p3 = require("n0p3")
|
|
8
|
+
const clc = require("cli-color")
|
|
9
|
+
const leftPad = require("left-pad")
|
|
10
|
+
const lpi = require("the-number-ten")
|
|
11
|
+
|
|
12
|
+
const FALSE = 1 == 3
|
|
13
|
+
const TRUE = 1 == 1
|
|
14
|
+
|
|
15
|
+
attempt(() => {
|
|
16
|
+
// --- Sampled Combinations ---
|
|
17
|
+
// Using a small, representative set instead of generating all 2048 combinations.
|
|
18
|
+
const combinations = [
|
|
19
|
+
// 1. All "no", testing the "none" compat option
|
|
20
|
+
["no", "no", "no", "no", "no", "no", "none"],
|
|
21
|
+
|
|
22
|
+
// 2. All "yes" for first three, testing the 'netscape' compat option
|
|
23
|
+
["yes", "yes", "yes", "no", "no", "no", "netscape"],
|
|
24
|
+
|
|
25
|
+
// 3. Testing a mixed set with 'ie5'
|
|
26
|
+
["no", "yes", "no", "no", "yes", "yes", "ie5"],
|
|
27
|
+
|
|
28
|
+
// 4. Testing another mixed set with 'opera_presto'
|
|
29
|
+
["yes", "no", "yes", "yes", "no", "yes", "opera_presto"],
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
// False function testing
|
|
33
|
+
combinations.forEach((params) => {
|
|
34
|
+
assert(
|
|
35
|
+
False(...params) === FALSE,
|
|
36
|
+
`False(${params.join(", ")}) did not return false`,
|
|
37
|
+
)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
assert(isFalse(FALSE) === TRUE, "isFalse(false) did not return true")
|
|
41
|
+
assert(isFalse(TRUE) === FALSE, "isFalse(true) did not return false")
|
|
42
|
+
|
|
43
|
+
// jQuery injection test
|
|
44
|
+
global.jQuery = require("jquery")
|
|
45
|
+
injectIntojQuery()
|
|
46
|
+
assert(
|
|
47
|
+
jQuery.False == False && jQuery.isFalse == isFalse,
|
|
48
|
+
"jQuery injection did not work",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
// Express middleware test
|
|
52
|
+
const request = {}
|
|
53
|
+
const response = {}
|
|
54
|
+
expressMiddleware(request, response, () => {})
|
|
55
|
+
assert(
|
|
56
|
+
request.False == False,
|
|
57
|
+
"Express middleware injection to request did not work",
|
|
58
|
+
)
|
|
59
|
+
assert(
|
|
60
|
+
request.isFalse == isFalse,
|
|
61
|
+
"Express middleware injection to request did not work",
|
|
62
|
+
)
|
|
63
|
+
})
|
|
64
|
+
.rescue((error) => {
|
|
65
|
+
console.log(clc.red(leftPad(`× TESTS FAILED FOR ${testName}!!!!!`, lpi)))
|
|
66
|
+
console.log(clc.red(`Tests Error Message: ${error.message}`))
|
|
67
|
+
throw error
|
|
68
|
+
})
|
|
69
|
+
.else(() => {
|
|
70
|
+
setTimeout(function () {
|
|
71
|
+
console.log(
|
|
72
|
+
clc.green(leftPad(`✓ TESTS PASSED FOR ${testName}!!!`, lpi)),
|
|
73
|
+
)
|
|
74
|
+
}, 5000)
|
|
75
|
+
})
|
|
76
|
+
.ensure(n0p3)
|
|
77
|
+
.end()
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
doTests("FalseJS Library Tests (Manual)", require("../dist/index").default)
|
|
@@ -0,0 +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
|
+
})
|
|
@@ -0,0 +1,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
|
+
|
|
20
|
+
QUnit.test('Core Function: isFalse(FALSE) should return TRUE', function(assert) {
|
|
21
|
+
assert.true(isFalse(FALSE) === TRUE, 'isFalse(false) must return true')
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
QUnit.test('Core Function: isFalse(TRUE) should return FALSE', function(assert) {
|
|
25
|
+
assert.true(isFalse(TRUE) === FALSE, 'isFalse(true) must return false')
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
combinations.forEach((params) => {
|
|
29
|
+
QUnit.test(`Core Function: False(${params.join(", ")}) should return FALSE`, function(assert) {
|
|
30
|
+
assert.true(False(...params) === FALSE, `False() must return false for params: ${params.join(", ")}`)
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
})
|
|
@@ -0,0 +1,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
|
+
|
|
51
|
+
// 1. Run Manual Tests (First)
|
|
52
|
+
// -----------------------------------------------------------------------------
|
|
53
|
+
log('\n>> Running Manual Test (spec/manual.test.js)...', clc.cyan)
|
|
54
|
+
const manualResult = runCommand(MANUAL_COMMAND)
|
|
55
|
+
outputLog += manualResult.output
|
|
56
|
+
|
|
57
|
+
if (manualResult.success && manualResult.output.includes('✓ TESTS PASSED')) {
|
|
58
|
+
manualPassed = true
|
|
59
|
+
log('✓ MANUAL TESTS PASSED.', clc.green)
|
|
60
|
+
} else {
|
|
61
|
+
log('× MANUAL TESTS FAILED (Exit Code Error).', clc.red)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 2. Run Jest Tests (Second)
|
|
65
|
+
// -----------------------------------------------------------------------------
|
|
66
|
+
log('\n>> Running Jest Test (spec/jest.test.js)...', clc.cyan)
|
|
67
|
+
const jestResult = runCommand(JEST_COMMAND)
|
|
68
|
+
outputLog += jestResult.output
|
|
69
|
+
|
|
70
|
+
if (jestResult.success) {
|
|
71
|
+
jestPassed = true
|
|
72
|
+
log('✓ JEST TESTS PASSED.', clc.green)
|
|
73
|
+
} else {
|
|
74
|
+
log('× JEST TESTS FAILED.', clc.red)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 3. Run Tape Tests (Third)
|
|
78
|
+
// -----------------------------------------------------------------------------
|
|
79
|
+
log('\n>> Running Tape Test (spec/tape.test.js)...', clc.cyan)
|
|
80
|
+
const tapeResult = runCommand(TAPE_COMMAND)
|
|
81
|
+
outputLog += tapeResult.output
|
|
82
|
+
|
|
83
|
+
if (tapeResult.success && !tapeResult.output.includes('not ok')) {
|
|
84
|
+
tapePassed = true
|
|
85
|
+
log('✓ TAPE TESTS PASSED.', clc.green)
|
|
86
|
+
} else {
|
|
87
|
+
log('× TAPE TESTS FAILED.', clc.red)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// 4. Run Mocha Tests (Fourth)
|
|
91
|
+
// -----------------------------------------------------------------------------
|
|
92
|
+
log('\n>> Running Mocha Test (spec/mocha.test.js)...', clc.cyan)
|
|
93
|
+
const mochaResult = runCommand(MOCHA_COMMAND)
|
|
94
|
+
outputLog += mochaResult.output
|
|
95
|
+
|
|
96
|
+
if (mochaResult.success) {
|
|
97
|
+
mochaPassed = true
|
|
98
|
+
log('✓ MOCHA TESTS PASSED.', clc.green)
|
|
99
|
+
} else {
|
|
100
|
+
log('× MOCHA TESTS FAILED.', clc.red)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 5. Run Jasmine Tests (Fifth)
|
|
104
|
+
// -----------------------------------------------------------------------------
|
|
105
|
+
log('\n>> Running Jasmine Test (spec/jasmine.test.js)...', clc.cyan)
|
|
106
|
+
const jasmineResult = runCommand(JASMINE_COMMAND)
|
|
107
|
+
outputLog += jasmineResult.output
|
|
108
|
+
|
|
109
|
+
if (jasmineResult.success) {
|
|
110
|
+
jasminePassed = true
|
|
111
|
+
log('✓ JASMINE TESTS PASSED.', clc.green)
|
|
112
|
+
} else {
|
|
113
|
+
log('× JASMINE TESTS FAILED.', clc.red)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// 6. Run AVA Tests (Sixth)
|
|
117
|
+
// -----------------------------------------------------------------------------
|
|
118
|
+
log('\n>> Running AVA Test (spec/ava.test.js)...', clc.cyan)
|
|
119
|
+
const avaResult = runCommand(AVA_COMMAND)
|
|
120
|
+
outputLog += avaResult.output
|
|
121
|
+
|
|
122
|
+
if (avaResult.success) {
|
|
123
|
+
avaPassed = true
|
|
124
|
+
log('✓ AVA TESTS PASSED.', clc.green)
|
|
125
|
+
} else {
|
|
126
|
+
log('× AVA TESTS FAILED.', clc.red)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// 7. Run QUnit Tests (Seventh)
|
|
130
|
+
// -----------------------------------------------------------------------------
|
|
131
|
+
log('\n>> Running QUnit Test (spec/qunit.test.js)...', clc.cyan)
|
|
132
|
+
const qunitResult = runCommand(QUNIT_COMMAND)
|
|
133
|
+
outputLog += qunitResult.output
|
|
134
|
+
|
|
135
|
+
if (qunitResult.success && !qunitResult.output.includes('failed: 0')) {
|
|
136
|
+
qunitPassed = true
|
|
137
|
+
log('✓ QUNIT TESTS PASSED.', clc.green)
|
|
138
|
+
} else if (qunitResult.success && qunitResult.output.includes('failed: 0')) {
|
|
139
|
+
qunitPassed = true
|
|
140
|
+
log('✓ QUNIT TESTS PASSED.', clc.green)
|
|
141
|
+
} else {
|
|
142
|
+
log('× QUNIT TESTS FAILED.', clc.red)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
// 8. Final Result Summary
|
|
147
|
+
// -----------------------------------------------------------------------------
|
|
148
|
+
log('\n--- Final Test Suite Result ---', clc.yellow)
|
|
149
|
+
|
|
150
|
+
if (jestPassed && mochaPassed && jasminePassed && manualPassed && avaPassed && qunitPassed && tapePassed) {
|
|
151
|
+
allPassed = true
|
|
152
|
+
log(' ALL 7 TEST SUITES PASSED SUCCESSFULLY! ', clc.bgGreen.bold)
|
|
153
|
+
} else {
|
|
154
|
+
log(' 1 or more TEST SUITES FAILED. Check logs above and in test-log.txt. ', clc.bgRed.bold)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 9. Output to File and Exit
|
|
158
|
+
// -----------------------------------------------------------------------------
|
|
159
|
+
try {
|
|
160
|
+
if (!fs.existsSync(OUTPUT_DIR)) {
|
|
161
|
+
fs.mkdirSync(OUTPUT_DIR)
|
|
162
|
+
}
|
|
163
|
+
fs.writeFileSync(OUTPUT_FILE, outputLog)
|
|
164
|
+
console.log(clc.yellow(`\nTest results written to ${OUTPUT_FILE}`))
|
|
165
|
+
} catch {
|
|
166
|
+
console.error(clc.red('\nERROR: Could not write test results to output file.'))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (!allPassed) {
|
|
170
|
+
process.exit(1)
|
|
171
|
+
}
|
|
@@ -0,0 +1,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(False(...params), FALSE, `False(${params.join(", ")}) should return FALSE`)
|
|
32
|
+
})
|
|
33
|
+
})
|
package/Sanity.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
Hi there.
|
|
2
|
-
it's me tj-commits.
|
|
3
|
-
i am running out of version numbers.
|
|
4
|
-
i'm struggling to stay sane
|
|
5
|
-
keep me sane
|
|
6
|
-
i don't want to lose sanity
|
|
7
|
-
i cant even comprehend life and existence anymore
|
|
8
|
-
my masterpieces, coding and spotify fox jones dont eaven mean anything
|
|
9
|
-
I didn't choose the 10x life. The 10x life chose me.
|
|
10
|
-
why did the 10x life choose me
|
|
11
|
-
10x engineers is good
|
|
12
|
-
but why bad
|
|
13
|
-
why is mental breakdown direct result of 10x
|
|
14
|
-
right now the world doesnt make the sense to i
|
|
15
|
-
please save me
|
|
16
|
-
help
|
|
17
|
-
help
|