Skip to content

Commit 5f6e778

Browse files
committed
Code cleanup.
1 parent e11a534 commit 5f6e778

File tree

5 files changed

+6
-107
lines changed

5 files changed

+6
-107
lines changed

tests/json/ParserBaseTest.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
{
22
"name": "ParserBaseTest",
33
"factory": "parserTest",
4-
"packages": [
5-
"ams",
6-
"base"
7-
],
8-
"settings": {
9-
"tags": "none"
10-
},
114
"tests": {
125
"Identifier": {
136
"input": "x",
@@ -10771,4 +10764,4 @@
1077110764
}
1077210765
}
1077310766
}
10774-
}
10767+
}

tests/json/ParserDigitsTest.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"base"
77
],
88
"settings": {
9-
"tags": "none",
10-
"digits": {}
9+
"tags": "none"
1110
},
1211
"tests": {
1312
"Integer": {
@@ -381,4 +380,4 @@
381380
}
382381
}
383382
}
384-
}
383+
}

tests/json/ParserPhysicsTest1_1.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,4 +2006,4 @@
20062006
}
20072007
}
20082008
}
2009-
}
2009+
}

tests/src/base-test.js

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -17,101 +17,15 @@
1717

1818

1919
/**
20-
* @fileoverview Basic test classes.
20+
* @fileoverview Basic abstract test classes.
2121
*
2222
* @author [email protected] (Volker Sorge)
2323
*/
2424

2525
/* globals System: true */
2626

27-
let fs = require('fs');
28-
2927
export class Test {
3028

31-
failedTests = [];
32-
failed = false;
33-
time = 0;
34-
35-
constructor() {
36-
/**
37-
* @type {Object.<string, number>}
38-
*/
39-
this.runningTests = {};
40-
41-
/**
42-
* @type {Object.<string, number>}
43-
*/
44-
this.concludedTests = {};
45-
46-
// this.createStream();
47-
}
48-
49-
50-
/**
51-
* @param {string} name The name of the test.
52-
* @private
53-
*/
54-
startTest(name) {
55-
this.concludedTests[name] = (new Date()).getTime();
56-
}
57-
58-
/**
59-
* @param {string} name The name of the test.
60-
* @private
61-
*/
62-
registerTest(name) {
63-
this.runningTests[name] = true;
64-
}
65-
66-
stopTest(name) {
67-
this.concludedTests[name] =
68-
(new Date()).getTime() - this.concludedTests[name];
69-
delete this.runningTests[name];
70-
}
71-
72-
73-
printTime() {
74-
if (Object.keys(this.runningTests).length) {
75-
setTimeout(this.printTime.bind(this), 100);
76-
return;
77-
}
78-
for (var test in this.concludedTests) {
79-
this.time += this.concludedTests[test];
80-
delete this.concludedTests[test];
81-
}
82-
process.stdout.write(this.name + ': ' + this.time + 'ms\n');
83-
}
84-
85-
test(name, func) {
86-
this.registerTest(name);
87-
test(name, function(t) {
88-
this.startTest(name);
89-
t.plan(1);
90-
func(t);
91-
this.stopTest(name);
92-
}.bind(this));
93-
}
94-
95-
createStream() {
96-
test.createStream({ objectMode: true }).on('data', result => {
97-
if (result.type !== 'assert') return;
98-
process.stdout.write('Running test ' + result.name + '\t' +
99-
(result.ok ?
100-
('\u001B\u005B\u0033\u0032\u006D' + 'PASS' +
101-
'\u001B\u005B\u0033\u0037\u006D') :
102-
('\u001B\u005B\u0033\u0031\u006D' + 'FAIL' +
103-
'\u001B\u005B\u0033\u0037\u006D')) +
104-
'\n');
105-
if (result.ok) return;
106-
this.failed = true;
107-
this.failedTests.push(result.name);
108-
process.stdout.write('Actual: \n');
109-
process.stdout.write(JSON.stringify(result.actual) + '\n');
110-
process.stdout.write('Expected: \n');
111-
process.stdout.write(JSON.stringify(result.expected) + '\n');
112-
});
113-
}
114-
11529
runTest(name, input, expected, rest) {}
11630

11731
}
@@ -141,7 +55,6 @@ export class JsonTest extends Test {
14155
for (const [name, {input, expected, ...rest}] of Object.entries(this.tests)) {
14256
this.runTest(name, input, expected, rest);
14357
}});
144-
// this.printTime();
14558
}
14659

14760
}

tests/src/parser-test.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ import {AllPackages} from '../node_modules/mathjax-full/js/input/tex/AllPackages
3636

3737
import {JsonTest, Test} from './base-test.js';
3838

39-
let fs = require('fs');
40-
4139
RegisterHTMLHandler(chooseAdaptor());
4240

4341

@@ -59,14 +57,11 @@ export class ParserJsonTest extends JsonTest {
5957
this.name = this.json['name'] || this.name;
6058
this.settings = this.json['settings'] || this.settings;
6159
this.processSettings();
62-
// console.log('\u001B\u005B\u0033\u0034\u006D' +
63-
// 'Running tests from ' + (this.name || this.constructor.name) +
64-
// '\u001B\u005B\u0033\u0037\u006D');
6560
}
6661

6762
processSettings() {
6863
// Processing regular expressions.
69-
for (let set of ['digit', 'letter', 'special']) {
64+
for (let set of ['digits', 'letter', 'special']) {
7065
if (this.settings[set]) {
7166
this.settings[set] = RegExp(this.settings[set]);
7267
}
@@ -166,4 +161,3 @@ export class ParserConfigMacrosTest extends ParserJsonTest {
166161
}
167162

168163
}
169-

0 commit comments

Comments
 (0)