-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from mathjax/rewrite_tests
Rewrite tests
- Loading branch information
Showing
10 changed files
with
403 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"name": "KeyvalTest", | ||
"factory": "keyvalTest", | ||
"tests": { | ||
"Keyval Trival": { | ||
"input": "key={{}}", | ||
"expected": {"key": true} | ||
}, | ||
"Keyval Trivial 2": { | ||
"input": "key1={{}},key2={{{{}}}}", | ||
"expected": {"key1": true, "key2": true} | ||
}, | ||
"Keyval Trival3": { | ||
"input": "key={{}{}}", | ||
"expected": {"key": "{}{}"} | ||
}, | ||
"Keyval Trivial 4": { | ||
"input": "key1= { { } },key2= {{ { { }} } }", | ||
"expected": {"key1": true, "key2": true} | ||
}, | ||
"Keyval Single": { | ||
"input": "key=a", | ||
"expected": {"key": "a"} | ||
}, | ||
"Keyval Double": { | ||
"input": "key1=a,key2=b", | ||
"expected": {"key1": "a", "key2": "b"} | ||
}, | ||
"Keyval Space": { | ||
"input": "key1 = a , key2 = b", | ||
"expected": {"key1": "a", "key2": "b"} | ||
}, | ||
"Keyval Single True": { | ||
"input": "key1", | ||
"expected": {"key1": true} | ||
}, | ||
"Keyval Double True": { | ||
"input": "key1,key2", | ||
"expected": {"key1": true, "key2": true} | ||
}, | ||
"Keyval Mixed": { | ||
"input": "key1=a,key2,key3=c", | ||
"expected": {"key1": "a", "key2": true, "key3": "c"} | ||
}, | ||
"Keyval Empty Comma Begin": { | ||
"input": ",key1=a,key2,key3=c", | ||
"expected": {"key1": "a", "key2": true, "key3": "c"} | ||
}, | ||
"Keyval Empty Comma Mid": { | ||
"input": "key1=a,,key2,key3=c", | ||
"expected": {"key1": "a", "key2": true, "key3": "c"} | ||
}, | ||
"Keyval Empty Comma End": { | ||
"input": "key1=a,key2,key3=c,", | ||
"expected": {"key1": "a", "key2": true, "key3": "c"} | ||
}, | ||
"Keyval Empty Comma Multi": { | ||
"input": ",,key1=a,,,,key2,key3=c,,", | ||
"expected": {"key1": "a", "key2": true, "key3": "c"} | ||
}, | ||
"Keyval Braces": { | ||
"input": "key1={a},key2=b", | ||
"expected": {"key1": "a", "key2": "b"} | ||
}, | ||
"Keyval Braces 2": { | ||
"input": "key1={{a}},key2=b", | ||
"expected": {"key1": "a", "key2": "b"} | ||
}, | ||
"Keyval Braces 3": { | ||
"input": "key1={{{a}}},key2=b", | ||
"expected": {"key1": "a", "key2": "b"} | ||
}, | ||
"Keyval Braces Comma": { | ||
"input": "key1={a,b,c},key2=b", | ||
"expected": {"key1": "a,b,c", "key2": "b"} | ||
}, | ||
"Keyval Braces Equal": { | ||
"input": "key1={a=c},key2=b", | ||
"expected": {"key1": "a=c", "key2": "b"} | ||
}, | ||
"Keyval Braces Comma Equal": { | ||
"input": "key1={a=c,b},key2=b", | ||
"expected": {"key1": "a=c,b", "key2": "b"} | ||
}, | ||
"Keyval Braces Simple 1": { | ||
"input": "key1={{a}}", | ||
"expected": {"key1": "a"} | ||
}, | ||
"Keyval Braces Simple 2": { | ||
"input": "key1={{a{b}}}", | ||
"expected": {"key1": "a{b}"} | ||
}, | ||
"Keyval Braces Simple 3": { | ||
"input": "key1={{a={b}}}", | ||
"expected": {"key1": "a={b}"} | ||
}, | ||
"Keyval Braces Prefix": { | ||
"input": "key1={{}a}", | ||
"expected": {"key1": "{}a"} | ||
}, | ||
"Keyval Braces Prefix 2": { | ||
"input": "key1={{{}}a}", | ||
"expected": {"key1": "{{}}a"} | ||
}, | ||
"Keyval Braces Prefix 3": { | ||
"input": "key1={{}{}a}", | ||
"expected": {"key1": "{}{}a"} | ||
}, | ||
"Keyval Braces Prefix 4": { | ||
"input": "key1={{{}{}a}}", | ||
"expected": {"key1": "{}{}a"} | ||
}, | ||
"Keyval Braces Prefix 5": { | ||
"input": "key1={{}{a}}", | ||
"expected": {"key1": "{}{a}"} | ||
}, | ||
"Keyval Braces Prefix 6": { | ||
"input": "key1={{{}}{a}}", | ||
"expected": {"key1": "{{}}{a}"} | ||
}, | ||
"Keyval Braces Mixed 1": { | ||
"input": "key1={{a},{b}},key2=b", | ||
"expected": {"key1": "{a},{b}", "key2": "b"} | ||
}, | ||
"Keyval Braces Mixed 2": { | ||
"input": "key1={{{a},{b}}},key2=b", | ||
"expected": {"key1": "{a},{b}", "key2": "b"} | ||
}, | ||
"Keyval Braces Mixed 3": { | ||
"input": "key1={{{a}},{{b},{c}}},key2=b", | ||
"expected": {"key1": "{{a}},{{b},{c}}", "key2": "b"} | ||
}, | ||
"Keyval Braces Mixed 3 Spaces": { | ||
"input": "key1 = { { { a}},{{b},{c} } } ,key2=b", | ||
"expected": {"key1": "{ { a}},{{b},{c} }", "key2": "b"} | ||
}, | ||
"Keyval Braces Mixed 4 Spaces": { | ||
"input": "key1 = { { { { { { a}},{{b},{c} } } } } } ,key2=b", | ||
"expected": {"key1": "{ { a}},{{b},{c} }", "key2": "b"} | ||
}, | ||
"Keyval Braces Equals Mixed 3": { | ||
"input": "key1={{{a}}={{b},{c}}},key2=b", | ||
"expected": {"key1": "{{a}}={{b},{c}}", "key2": "b"} | ||
}, | ||
"Keyval Error 1": { | ||
"input": "key={{a}", | ||
"expected": "Extra open brace or missing close brace" | ||
}, | ||
"Keyval Error 2": { | ||
"input": "key={{a}{}", | ||
"expected": "Extra open brace or missing close brace" | ||
}, | ||
"Keyval Error 3": { | ||
"input": "key1=}, key2={", | ||
"expected": "Extra open brace or missing close brace" | ||
}, | ||
"Keyval Unbalanced 1": { | ||
"input": "key={a}}", | ||
"expected": {"key": "a}"} | ||
}, | ||
"Keyval Unbalanced 2": { | ||
"input": "key1={a}}, key2=}b", | ||
"expected": {"key1": "a}", "key2": "}b"} | ||
}, | ||
"Keyval Unbalanced 3": { | ||
"input": "key1=}, key2={}}", | ||
"expected": {"key1": true, "key2": true} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,45 @@ | ||
import {ParserJsonTest} from './parser-test.js'; | ||
import {Configuration} from '../node_modules/mathjax-full/js/input/tex/Configuration.js'; | ||
import {CharacterMap} from '../node_modules/mathjax-full/js/input/tex/SymbolMap.js'; | ||
import ParseMethods from '../node_modules/mathjax-full/js/input/tex/ParseMethods.js'; | ||
|
||
|
||
export class ParserMultirelTest extends ParserJsonTest { | ||
|
||
constructor(json) { | ||
// Just some things bogus attributes for testing. | ||
new CharacterMap('shadow', ParseMethods.mathchar0mo, { | ||
sim: ['\u223C', {something: 'nothing'}], | ||
simeq: ['\u2243', {something: 'nothing'}], | ||
asymp: ['\u224D', {something: 'else'}], | ||
cong: ['\u224D', {anything: 'nothing'}], | ||
lesssim: ['\u2272', {lspace: '1pt'}], | ||
gtrsim: ['\u2278', {rspace: '1pt'}] | ||
}); | ||
Configuration.create('multirel-test', {handler: {macro: ['shadow']}, priority: 4}); | ||
super(json); | ||
this.packages = ['base', 'ams', 'multirel-test']; | ||
/************************************************************* | ||
* | ||
* Copyright (c) 2020 The MathJax Consortium | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
|
||
/** | ||
* @fileoverview Various test classes that use JSON input. | ||
* | ||
* @author [email protected] (Volker Sorge) | ||
*/ | ||
|
||
import {JsonTest} from './test.js'; | ||
import ParseUtil from '../node_modules/mathjax-full/js/input/tex/ParseUtil.js'; | ||
|
||
|
||
export class KeyvalTest extends JsonTest { | ||
|
||
runTest(name, input, expected) { | ||
this.test( | ||
name, | ||
t => { | ||
try { | ||
let keyval = ParseUtil.keyvalOptions(input); | ||
t.deepEqual(keyval, expected, name); | ||
} catch (e) { | ||
t.deepEqual(e.message, expected, name); | ||
} | ||
} | ||
); | ||
} | ||
|
||
} | ||
|
||
|
||
export class ParserConfigMacrosTest extends ParserJsonTest { | ||
|
||
constructor(json) { | ||
super(json); | ||
this.packages = ['base', 'configmacros']; | ||
Object.assign(this.settings, {macros:{}}); | ||
} | ||
|
||
runTest(name, input, expected, {macro, control}) { | ||
Object.assign(this.settings.macros, macro); | ||
super.runTest(name, control, expected); | ||
super.runTest(name, input, expected); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.