risei 2.0.1 → 3.1.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/README.md +50 -28
- package/index.js +18 -66
- package/package.json +7 -6
- package/system/CallTypes.js +10 -0
- package/system/Choices.js +92 -0
- package/system/ClassTestGroup.js +8 -8
- package/system/LocalCaller.js +47 -7
- package/system/MethodSpoofer.js +2 -2
- package/system/MethodTestGroup.js +8 -8
- package/system/Moment.js +29 -29
- package/system/NameAnalyzer.js +26 -26
- package/system/ObjectAnalyzer.js +36 -0
- package/system/PropertySpoofer.js +1 -1
- package/system/SpoofDef.js +73 -63
- package/system/TerminalReporter.js +102 -25
- package/system/TestDef.js +75 -17
- package/system/TestFinder.js +31 -29
- package/system/TestFrame.js +21 -12
- package/system/TestGroup.js +25 -25
- package/system/TestResult.js +63 -13
- package/system/TestRunner.js +44 -16
- package/system/TestStages.js +85 -26
- package/system/TestSummary.js +38 -37
- package/system/TotalComparer.js +54 -17
- package/system/TotalDisplayer.js +29 -6
- package/system/TypeAnalyzer.js +117 -26
- package/system/TypeIdentifier.js +10 -6
- package/system/Types.js +1 -0
- package/system/ATestCaller.js +0 -61
- package/system/ATestFinder.js +0 -38
- package/system/ATestReporter.js +0 -26
- package/system/ChosenTestFinder.js +0 -31
- package/system/Risei.js +0 -118
package/system/ATestCaller.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* Defines operations that a test caller (which requests
|
|
4
|
-
the running / reporting of tests) must implement.
|
|
5
|
-
Uses the ATestRunner to run all the tests via a generator,
|
|
6
|
-
and the ATestReporter for out / formatting if needed.
|
|
7
|
-
A = abstract. */
|
|
8
|
-
|
|
9
|
-
import TestRunner from "./TestRunner.js";
|
|
10
|
-
import ATestReporter from "./ATestReporter.js";
|
|
11
|
-
|
|
12
|
-
export default class ATestCaller {
|
|
13
|
-
// region Private fields
|
|
14
|
-
|
|
15
|
-
#finder;
|
|
16
|
-
#runner;
|
|
17
|
-
#reporter;
|
|
18
|
-
|
|
19
|
-
// endregion Private fields
|
|
20
|
-
|
|
21
|
-
// region Properties
|
|
22
|
-
|
|
23
|
-
get finder() {
|
|
24
|
-
return this.#finder;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
set finder(value) {
|
|
28
|
-
this.#finder = value;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
get runner() {
|
|
32
|
-
return this.#runner;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
set runner(value) {
|
|
36
|
-
this.#runner = value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get reporter() {
|
|
40
|
-
return this.#reporter;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set reporter(value) {
|
|
44
|
-
this.#reporter = value;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// endregion Properties
|
|
48
|
-
|
|
49
|
-
constructor(finder, runner, reporter) {
|
|
50
|
-
this.#finder = finder;
|
|
51
|
-
this.#runner = runner;
|
|
52
|
-
this.#reporter = reporter;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async runAllTests() {
|
|
56
|
-
throw new Error(
|
|
57
|
-
"Implement runAllTests() on a subclass, " +
|
|
58
|
-
"using .reporter for out / formatting if needed."
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
package/system/ATestFinder.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* Defines operations that test-finding classes should implement. A = abstract. */
|
|
4
|
-
|
|
5
|
-
import ATestSource from "./ATestSource.js";
|
|
6
|
-
|
|
7
|
-
export default class ATestFinder {
|
|
8
|
-
// region Fields
|
|
9
|
-
|
|
10
|
-
#testSources;
|
|
11
|
-
#thrown = [];
|
|
12
|
-
|
|
13
|
-
// endregion Fields
|
|
14
|
-
|
|
15
|
-
// region Properties
|
|
16
|
-
|
|
17
|
-
get testSources() {
|
|
18
|
-
return this.#testSources;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
set testSources(value) {
|
|
22
|
-
this.#testSources = value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get thrown() {
|
|
26
|
-
return this.#thrown;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// endregion Properties
|
|
30
|
-
|
|
31
|
-
constructor() {
|
|
32
|
-
this.#testSources = [];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async findAllTests() {
|
|
36
|
-
throw new Error("Implement findAllTests() on a subclass of ATestFinder.");
|
|
37
|
-
}
|
|
38
|
-
}
|
package/system/ATestReporter.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* Defines operations that a test reporter must implement. A = abstract. */
|
|
4
|
-
|
|
5
|
-
/* &cruft, ? replace with my own code eventually */
|
|
6
|
-
import chalk from "chalk";
|
|
7
|
-
|
|
8
|
-
export default class ATestReporter {
|
|
9
|
-
// Reports whatever was just provided by the TestRunner.
|
|
10
|
-
// Can delegate to the other report-x methods.
|
|
11
|
-
reportNext(result) {
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
reportGroup() {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
reportPassed(result) {
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
reportFailed(result) {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
reportSummary(summary) {
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* ChosenTestFinder is an ATestFinder that finds tests in the places coded in its constructor. */
|
|
4
|
-
|
|
5
|
-
import ATestFinder from "./ATestFinder.js";
|
|
6
|
-
import TopicTests from "../trial-tests/TopicTests.outward-rt.js";
|
|
7
|
-
import SelfTests from "../trial-tests/SelfTests.outward-rt.js";
|
|
8
|
-
|
|
9
|
-
export default class ChosenTestFinder extends ATestFinder {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
|
|
13
|
-
let testSource = new TopicTests();
|
|
14
|
-
let selfTestSource = new SelfTests();
|
|
15
|
-
|
|
16
|
-
this.testSources = [ testSource, selfTestSource ];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async findAllTests() {
|
|
20
|
-
let tests = [];
|
|
21
|
-
|
|
22
|
-
for (let source of this.testSources) {
|
|
23
|
-
let local = source.tests;
|
|
24
|
-
tests.push(...local);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Returning an awaitable value
|
|
28
|
-
// to match async signature.
|
|
29
|
-
return Promise.resolve(tests);
|
|
30
|
-
}
|
|
31
|
-
}
|
package/system/Risei.js
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* Copyright (c) 2023-2024 Ed Fallin. Published under the terms of the MIT license. */
|
|
4
|
-
|
|
5
|
-
/* This index.js is the entry point for running Risei tests from
|
|
6
|
-
other code. It imports other modules to perform its work.
|
|
7
|
-
It also exports modules that should / can be subclassed. */
|
|
8
|
-
|
|
9
|
-
// region Imports
|
|
10
|
-
|
|
11
|
-
// region Test-running dependencies
|
|
12
|
-
|
|
13
|
-
import TestRunner from "./TestRunner.js";
|
|
14
|
-
import LocalCaller from "./LocalCaller.js";
|
|
15
|
-
import TerminalReporter from "./TerminalReporter.js";
|
|
16
|
-
import TestFinder from "./TestFinder.js";
|
|
17
|
-
|
|
18
|
-
// endregion Test-running dependencies
|
|
19
|
-
|
|
20
|
-
// region Display dependencies
|
|
21
|
-
|
|
22
|
-
import chalk from "chalk";
|
|
23
|
-
import Moment from "./Moment.js";
|
|
24
|
-
|
|
25
|
-
// endregion Display dependencies
|
|
26
|
-
|
|
27
|
-
// endregion Imports
|
|
28
|
-
|
|
29
|
-
// region Named styles
|
|
30
|
-
|
|
31
|
-
/* Display styles for the start title and other general needs. */
|
|
32
|
-
const title = chalk.hex("FFFFFF").bgHex("191970").bold;
|
|
33
|
-
const fails = chalk.hex("000000").bgHex("FFD700").bold;
|
|
34
|
-
|
|
35
|
-
// endregion Named styles
|
|
36
|
-
|
|
37
|
-
// region Styling for color stripes
|
|
38
|
-
|
|
39
|
-
let wide = (text) => {
|
|
40
|
-
let width = process.stdout.columns;
|
|
41
|
-
text = text || "";
|
|
42
|
-
|
|
43
|
-
return text.padEnd(width, "\u00A0");
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// endregion Styling for color stripes
|
|
47
|
-
|
|
48
|
-
// region Key callable and its scripted call
|
|
49
|
-
|
|
50
|
-
async function runRiseiMetaTests(testFinderPath) {
|
|
51
|
-
// region Converting test-finder from path to class
|
|
52
|
-
|
|
53
|
-
testFinderPath = testFinderPath || "./TestFinder.js";
|
|
54
|
-
let finderModule = await import(testFinderPath);
|
|
55
|
-
|
|
56
|
-
let moduleKeys = Object.keys(finderModule);
|
|
57
|
-
let classKey = moduleKeys[0];
|
|
58
|
-
let finderClass = finderModule[classKey];
|
|
59
|
-
|
|
60
|
-
// endregion Converting test-finder from path to class
|
|
61
|
-
|
|
62
|
-
// region Intro / title
|
|
63
|
-
|
|
64
|
-
console.clear();
|
|
65
|
-
console.log();
|
|
66
|
-
console.log(title(wide()));
|
|
67
|
-
|
|
68
|
-
let now = new Date();
|
|
69
|
-
now = new Moment(now);
|
|
70
|
-
|
|
71
|
-
console.log(title(wide(` Risei tests run on ${ now.asReadable() } local time.`)));
|
|
72
|
-
console.log(title(wide()));
|
|
73
|
-
|
|
74
|
-
console.log();
|
|
75
|
-
|
|
76
|
-
// endregion Intro / title
|
|
77
|
-
|
|
78
|
-
// region Running tests
|
|
79
|
-
|
|
80
|
-
// Test-system objects and their relationships.
|
|
81
|
-
const finder = new finderClass.prototype.constructor();
|
|
82
|
-
finder.sourceBySearch = () => { return { tests: "**.outward-rt.js" }; };
|
|
83
|
-
|
|
84
|
-
const runner = new TestRunner();
|
|
85
|
-
const reporter = new TerminalReporter();
|
|
86
|
-
|
|
87
|
-
const caller = new LocalCaller(finder, runner, reporter);
|
|
88
|
-
|
|
89
|
-
// Actually running the tests using this system.
|
|
90
|
-
await caller.runAllTests();
|
|
91
|
-
|
|
92
|
-
// endregion Running tests
|
|
93
|
-
|
|
94
|
-
// region Trailing display of test-loading issues
|
|
95
|
-
|
|
96
|
-
if (finder.thrown.length !== 0) {
|
|
97
|
-
let loadFails = finder.thrown;
|
|
98
|
-
|
|
99
|
-
for (let fail of loadFails) {
|
|
100
|
-
console.log(fails(wide(` ${ fail }`)));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// endregion Trailing display of test-loading issues
|
|
105
|
-
|
|
106
|
-
// region Trailing formatting
|
|
107
|
-
|
|
108
|
-
console.log();
|
|
109
|
-
console.log();
|
|
110
|
-
|
|
111
|
-
// endregion Trailing formatting
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/* Runs tests now. */
|
|
115
|
-
await runRiseiMetaTests();
|
|
116
|
-
|
|
117
|
-
// endregion Key callable and its scripted call
|
|
118
|
-
|