risei 1.1.0 → 1.1.2

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.
Files changed (38) hide show
  1. package/README.md +195 -338
  2. package/index.js +9 -9
  3. package/package.json +7 -7
  4. package/{public/javascript → system}/ChosenTestFinder.js +2 -2
  5. package/{public/javascript → system}/SpoofClassMethodsFixture.js +38 -22
  6. package/system/SpoofObjectMethodsFixture.js +58 -0
  7. package/{public/javascript → system}/SpoofTuple.js +14 -0
  8. package/system/TestFrame.js +187 -0
  9. package/{public/javascript → system}/TestFrameChooser.js +6 -47
  10. package/{public/javascript → system}/TestFrames.js +232 -180
  11. package/system/TestResult.js +187 -0
  12. package/system/TestStages.js +278 -0
  13. package/{public/javascript → system}/TestTuple.js +126 -18
  14. package/{public/javascript → system}/TotalComparer.js +12 -0
  15. package/system/TotalCopier.js +79 -0
  16. package/system/TotalDisplayer.js +143 -0
  17. package/system/TypeAnalyzer.js +103 -0
  18. package/system/TypeIdentifier.js +70 -0
  19. package/system/Types.js +17 -0
  20. package/public/javascript/SpoofObjectMethodsFixture.js +0 -52
  21. package/public/javascript/TestResult.js +0 -338
  22. /package/{public/javascript → system}/AComparer.js +0 -0
  23. /package/{public/javascript → system}/ASpoofingFixture.js +0 -0
  24. /package/{public/javascript → system}/ATestCaller.js +0 -0
  25. /package/{public/javascript → system}/ATestFinder.js +0 -0
  26. /package/{public/javascript → system}/ATestFixture.js +0 -0
  27. /package/{public/javascript → system}/ATestReporter.js +0 -0
  28. /package/{public/javascript → system}/ATestSource.js +0 -0
  29. /package/{public/javascript → system}/ClassTestGroup.js +0 -0
  30. /package/{public/javascript → system}/LocalCaller.js +0 -0
  31. /package/{public/javascript → system}/MethodTestGroup.js +0 -0
  32. /package/{public/javascript → system}/Moment.js +0 -0
  33. /package/{public/javascript → system}/Risei.js +0 -0
  34. /package/{public/javascript → system}/TerminalReporter.js +0 -0
  35. /package/{public/javascript → system}/TestFinder.js +0 -0
  36. /package/{public/javascript → system}/TestGroup.js +0 -0
  37. /package/{public/javascript → system}/TestRunner.js +0 -0
  38. /package/{public/javascript → system}/TestSummary.js +0 -0
@@ -1,338 +0,0 @@
1
- /**/
2
-
3
- export class TestResult {
4
- // region Fields
5
-
6
- #test;
7
-
8
- #identityText;
9
- #initorsText;
10
- #inputsText;
11
- #expectedText;
12
- #actualText;
13
-
14
- #didPass;
15
- #actual;
16
- #thrown;
17
-
18
- // endregion Fields
19
-
20
- // region Source properties
21
-
22
- get test() {
23
- return this.#test;
24
- }
25
-
26
- set test(value) {
27
- this.#test = value;
28
- }
29
-
30
- // endregion Source properties
31
-
32
- // region Nature properties
33
-
34
- get identityText() {
35
- return this.#identityText;
36
- }
37
-
38
- set identityText(value) {
39
- this.#identityText = value;
40
- }
41
-
42
- get initorsText() {
43
- return this.#initorsText;
44
- }
45
-
46
- set initorsText(value) {
47
- this.#initorsText = value;
48
- }
49
-
50
- get inputsText() {
51
- return this.#inputsText;
52
- }
53
-
54
- set inputsText(value) {
55
- this.#inputsText = value;
56
- }
57
-
58
- get expectedText() {
59
- return this.#expectedText;
60
- }
61
-
62
- set expectedText(value) {
63
- this.#expectedText = value;
64
- }
65
-
66
- // endregion Nature properties
67
-
68
- // region Outcome properties
69
-
70
- get actualText() {
71
- return this.#actualText;
72
- }
73
-
74
- set actualText(value) {
75
- this.#actualText = value;
76
- }
77
-
78
- get didPass() {
79
- return this.#didPass;
80
- }
81
-
82
- set didPass(value) {
83
- this.#didPass = value;
84
- }
85
-
86
- get anyThrow() {
87
- return this.#thrown;
88
- }
89
-
90
- set anyThrow(value) {
91
- this.#thrown = value;
92
- }
93
-
94
- // endregion Outcome properties
95
-
96
- // region Construction
97
-
98
- constructor(test) {
99
- this.#test = test;
100
- }
101
-
102
- // endregion Construction
103
-
104
- // region Before run: setNature() and dependencies
105
-
106
- setNature() {
107
- this.#identityText = this.#calculateIdentityText();
108
- this.#initorsText = this.#calculateInitorsText();
109
- this.#inputsText = this.#calculateInputsText();
110
- this.#expectedText = this.#calculateExpectedText();
111
- }
112
-
113
- #calculateIdentityText() {
114
- let text = `${ this.test.for } `;
115
- return text;
116
- }
117
-
118
- #calculateInitorsText() {
119
- let text = this.#improveValueRowDisplay(this.test.with);
120
- text = `Initors: ${ text }. `;
121
- return text;
122
- }
123
-
124
- #calculateInputsText() {
125
- let text = this.#improveValueRowDisplay(this.test.in);
126
- text = `Inputs: ${ text }. `;
127
- return text;
128
- }
129
-
130
- #calculateExpectedText() {
131
- let text = this.#improveValueDisplay(this.test.out);
132
- text = `Expected: ${ text }. `;
133
- return text;
134
- }
135
-
136
- // endregion Before run: setNature() and dependencies
137
-
138
- // region After run: setResults() and dependencies
139
-
140
- setResults() {
141
- // Direct results.
142
- this.#didPass = this.test.didPass;
143
- this.#actual = this.test.actual;
144
- this.#thrown = this.test.anyThrow;
145
-
146
- // Derived displayable results.
147
- this.#actualText = this.#calculateActualText();
148
- }
149
-
150
- #calculateActualText() {
151
- let text = this.#improveValueDisplay(this.test.actual);
152
- text = `Actual: ${ text }. `;
153
- return text;
154
- }
155
-
156
- // endregion After run: setResults() and dependencies
157
-
158
- // region Improving displaying
159
-
160
- #improveValueRowDisplay(row) {
161
- let items = row
162
- .map(x => this.#improveValueDisplay(x));
163
-
164
- if (items.length === 0) {
165
- return [ "\u2014" ];
166
- }
167
-
168
- return items.join(`, `);
169
- }
170
-
171
- #improveValueDisplay(value) {
172
- let output = this.#addQuotesIfString(value);
173
- output = this.#addArrayStyleIfArray(output);
174
- output = this.#jsonifyIfMap(output);
175
- output = this.#jsonifyIfSet(output);
176
- output = this.#jsonifyIfClass(output);
177
- output = this.#jsonifyIfFunction(output);
178
- output = this.#jsonifyIfObject(output);
179
- output = this.#stateUndefinedIfUndefined(output);
180
- output = this.#stateNullIfNull(output);
181
-
182
- return output;
183
- }
184
-
185
- // endregion Improving displaying
186
-
187
- // region Individual display improvements
188
-
189
- #addQuotesIfString(value) {
190
- let output = typeof value !== "string" ? value : `"${ value }"`;
191
- return output;
192
- }
193
-
194
- #addArrayStyleIfArray(value) {
195
- // Not-an-array path.
196
- if (!Array.isArray(value)) {
197
- return value;
198
- }
199
-
200
- // Each array value may be styled.
201
- let outputs = value
202
- .map(x => this.#improveValueDisplay(x));
203
-
204
- // Brackets around, commas between.
205
- let output = `[${ outputs.join(",") }]`;
206
-
207
- // And back to caller.
208
- return output;
209
- }
210
-
211
- #jsonifyIfMap(value) {
212
- // Not-a-map path.
213
- if (!(value instanceof Map)) {
214
- return value;
215
- }
216
-
217
- let items = [];
218
-
219
- // Each key-value pair is handled individually.
220
- for (let key of value.keys()) {
221
- // Keys are not styled.
222
- let item = value.get(key);
223
-
224
- // Cross-recursion for styling values.
225
- items.push(`${ key }:${ this.#improveValueDisplay(item) }`);
226
- }
227
-
228
- // Key-value pairs are all listed together.
229
- let output = `Map{${ items.join(",") }}`;
230
- return output;
231
- }
232
-
233
- #jsonifyIfSet(value) {
234
- // Not-a-set path.
235
- if (!(value instanceof Set)) {
236
- return value;
237
- }
238
-
239
- let items = [];
240
-
241
- // Each item is handled individually.
242
- for (let item of value) {
243
- // Cross-recursion for styling values.
244
- let display = `${ this.#improveValueDisplay(item) }`;
245
- items.push(display);
246
- }
247
-
248
- // Items are all listed together.
249
- let output = `Set{${ items.join(",") }}`;
250
- return output;
251
- }
252
-
253
- #jsonifyIfClass(value) {
254
- let isAFunction = value instanceof Function;
255
-
256
- // If not a Function, also not a class.
257
- if (!isAFunction) {
258
- return value;
259
- }
260
-
261
- // Definition of a class always starts with `class` and space.
262
- let definition = value.toString();
263
- let isAClass = definition.startsWith(`class` + ` `);
264
-
265
- // Not-a-class path.
266
- if (!isAClass) {
267
- return value;
268
- }
269
-
270
- // Class definitions have a .name.
271
- let output = value.name;
272
- return output;
273
- }
274
-
275
- #jsonifyIfFunction(value) {
276
- // Not-a-function path.
277
- if (!(value instanceof Function)) {
278
- return value;
279
- }
280
-
281
- // toString() lists the definition, including code.
282
- let output = value.toString();
283
-
284
- // Most whitespace is eliminated for readability.
285
- output = output.replace(/(\r\n?)/g, "");
286
- output = output.replace(/\s{2,}/g, " ");
287
-
288
- // Back to caller.
289
- return output;
290
- }
291
-
292
- #jsonifyIfObject(value) {
293
- // Not-an-object path.
294
- if (!(value instanceof Object)) {
295
- return value;
296
- }
297
-
298
- /* Use any meaningful toString() text for the object. */
299
- let asString = value.toString();
300
-
301
- if (asString !== "[object Object]") {
302
- return asString;
303
- }
304
-
305
- /* If no meaningful toString() value,
306
- use a list of all public members. */
307
- let items = [];
308
-
309
- // Each property of the object is handled individually.
310
- for (let p in value) {
311
- if (value[p] instanceof Function) {
312
- items.push(`${ p }:${ value[p].toString() }`);
313
- continue;
314
- }
315
-
316
- // Cross-recursion for nested items.
317
- let item = this.#improveValueDisplay(value[p]);
318
- items.push(`${ p }:${ item }`);
319
- }
320
-
321
- // Properties are all listed together.
322
- let output = `{ ${ items.join(", ") } }`;
323
- return output;
324
- }
325
-
326
- #stateUndefinedIfUndefined(value) {
327
- let output = value !== undefined ? value : "undefined";
328
- return output;
329
- }
330
-
331
- #stateNullIfNull(value) {
332
- let output = value !== null ? value : "null";
333
- return output;
334
- }
335
-
336
- // endregion Individual display improvements
337
-
338
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes