diff --git a/tests/json/KeyvalTest.json b/tests/json/KeyvalTest.json new file mode 100644 index 0000000..b89a821 --- /dev/null +++ b/tests/json/KeyvalTest.json @@ -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} + } + } +} diff --git a/tests/json/ParserBussproofsRegInfTest.json b/tests/json/ParserBussproofsRegInfTest.json index 04aff1f..736985e 100644 --- a/tests/json/ParserBussproofsRegInfTest.json +++ b/tests/json/ParserBussproofsRegInfTest.json @@ -1,6 +1,6 @@ { "name": "ParserBussproofsRegInfTest", - "factory": "parserTest", + "factory": "parserOutputTest", "packages": [ "base", "ams", @@ -8067,4 +8067,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/json/ParserBussproofsRegProofsTest.json b/tests/json/ParserBussproofsRegProofsTest.json index a2da832..8684806 100644 --- a/tests/json/ParserBussproofsRegProofsTest.json +++ b/tests/json/ParserBussproofsRegProofsTest.json @@ -1,6 +1,6 @@ { "name": "ParserBussproofsRegProofsTest", - "factory": "parserTest", + "factory": "parserOutputTest", "packages": [ "base", "ams", @@ -29032,4 +29032,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/src/other-test.js b/tests/src/other-test.js index 4563af2..ce9d129 100644 --- a/tests/src/other-test.js +++ b/tests/src/other-test.js @@ -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 v.sorge@mathjax.org (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); - } - -} - diff --git a/tests/src/parser-test.js b/tests/src/parser-test.js index 385417a..c992eb0 100644 --- a/tests/src/parser-test.js +++ b/tests/src/parser-test.js @@ -1,7 +1,30 @@ +/************************************************************* + * + * 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 All classes that test the TeX parser. + * + * @author v.sorge@mathjax.org (Volker Sorge) + */ + import {mathjax} from '../node_modules/mathjax-full/js/mathjax.js'; import {TeX} from '../node_modules/mathjax-full/js/input/tex.js'; -import {SVG} from '../node_modules/mathjax-full/js/output/svg.js'; import {RegisterHTMLHandler} from "../node_modules/mathjax-full/js/handlers/html.js"; import {chooseAdaptor} from "../node_modules/mathjax-full/js/adaptors/chooseAdaptor.js"; import {JsonMmlVisitor} from '../node_modules/mathjax-full/js/core/MmlTree/JsonMmlVisitor.js'; @@ -9,88 +32,27 @@ import {STATE} from '../node_modules/mathjax-full/js/core/MathItem.js'; import {TagsFactory} from '../node_modules/mathjax-full/js/input/tex/Tags.js'; import {MapHandler} from "../node_modules/mathjax-full/js/input/tex/MapHandler.js"; +import {AllPackages} from '../node_modules/mathjax-full/js/input/tex/AllPackages.js'; import {JsonTest, Test} from './test.js'; -import {AllPackages} from '../node_modules/mathjax-full/js/input/tex/AllPackages.js'; -import '../node_modules/mathjax-full/js/input/tex/base/BaseConfiguration.js'; -import '../node_modules/mathjax-full/js/input/tex/ams/AmsConfiguration.js'; - let fs = require('fs'); RegisterHTMLHandler(chooseAdaptor()); -export class ParserTest extends Test { - - json = {}; - packages = ['ams', 'base']; - settings = {tags: 'none'}; - output = false; - - constructor() { - super(); - console.log(this.constructor.name); - console.log('\u001B\u005B\u0033\u0034\u006D' + - 'Running tests from ' + this.constructor.name + - '\u001B\u005B\u0033\u0037\u006D'); - this.json.name = this.constructor.name; - this.json.packages = this.packages; - this.json.settings = this.settings; - this.json.tests = {}; - } - - outTest(name, tex, expected) { - this.json.tests[name] = {input: tex, expected: expected}; - } - - printTime() { - super.printTime(); - if (this.output && !Object.keys(this.runningTests).length) { - console.log('Out: ' + this.json.name); - this.json.name = this.constructor.name; - this.json.packages = this.packages; - this.json.settings = this.settings; - fs.writeFileSync('json3/' + this.json.name + '.json', JSON.stringify(this.json, null, 2)); - } - } - - // Tests exclusively the timing of the Translate method. - runTest(name, tex, expected) { - this.outTest(name, tex,expected); - this.test( - name, - t => { - mathjax.handleRetriesFor(function() { - let options = {packages: this.packages}; - Object.assign(options, this.settings); - let html = mathjax.document('', { - InputJax: new TeX(options), OutputJax: new SVG() - }); - let root = html.convert(tex, {end: STATE.CONVERT}); - let jv = new JsonMmlVisitor(); - root.setTeXclass(null); - let actual = jv.visitTree(root); - t.deepEqual(actual, expected, name); - }.bind(this)).catch(err => { - console.log(err.message); - console.log(err.stack.replace(/\n.*\/system\.js:(.|\n)*/, '')); - }); - } - ); - } - - ignoreTest(name, tex, expected) { - } - -} - +/** + * Parser tests from JSON input files. + */ export class ParserJsonTest extends JsonTest { packages = ['ams', 'base']; settings = {tags: 'none'}; name = ''; + /** + * @override + */ constructor(json) { super(json); this.packages = this.json['packages'] || this.packages; @@ -111,7 +73,15 @@ export class ParserJsonTest extends JsonTest { } } + document(options) { + return mathjax.document('', { + InputJax: new TeX(options) + }); + } + /** + * @override + */ runTest(name, tex, expected, rest) { this.test( name, @@ -119,10 +89,7 @@ export class ParserJsonTest extends JsonTest { mathjax.handleRetriesFor(function() { let options = {packages: this.packages}; Object.assign(options, this.settings); - let html = mathjax.document('', { - InputJax: new TeX(options), OutputJax: new SVG() - }); - let root = html.convert(tex, {end: STATE.CONVERT}); + let root = this.document(options).convert(tex, {end: STATE.CONVERT}); let jv = new JsonMmlVisitor(); root.setTeXclass(null); let actual = jv.visitTree(root); @@ -136,3 +103,69 @@ export class ParserJsonTest extends JsonTest { } } + + +import {SVG} from '../node_modules/mathjax-full/js/output/svg.js'; + +/** + * Parser tests for packages that require an output jax. + */ +export class ParserOutputTest extends ParserJsonTest { + + /** + * @override + */ + document(options) { + return mathjax.document('', { + InputJax: new TeX(options), OutputJax: new SVG() + }); + } + +} + +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'; + +/** + * Parser tests for multi relations method. + */ +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']; + } + +} + + +/** + * Parser tests for macro configurations. + */ +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); + } + +} + diff --git a/tests/src/run-test.js b/tests/src/run-test.js index 13a712e..f30c787 100644 --- a/tests/src/run-test.js +++ b/tests/src/run-test.js @@ -1,3 +1,27 @@ +/************************************************************* + * + * 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 The current test runner. + * + * @author v.sorge@mathjax.org (Volker Sorge) + */ + import {TestFactory} from './test-factory.js'; let process = require('process'); diff --git a/tests/src/test-factory.js b/tests/src/test-factory.js index 7be1cc1..5668a4d 100644 --- a/tests/src/test-factory.js +++ b/tests/src/test-factory.js @@ -1,14 +1,40 @@ -import {ParserJsonTest} from './parser-test.js'; -import {ParserMultirelTest, ParserConfigMacrosTest} from './other-test.js'; +/************************************************************* + * + * 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 Factory for tests based on JSON input files. + * + * @author v.sorge@mathjax.org (Volker Sorge) + */ + +import * as pt from './parser-test.js'; +import {KeyvalTest} from './other-test.js'; import {JsonTest} from './test.js'; let fs = require('fs'); export class TestFactory { static factory = { - 'parserConfigMacros': ParserConfigMacrosTest, - 'parserMultirel': ParserMultirelTest, - 'parserTest': ParserJsonTest, + 'keyvalTest': KeyvalTest, + 'parserConfigMacros': pt.ParserConfigMacrosTest, + 'parserMultirel': pt.ParserMultirelTest, + 'parserOutput': pt.ParserOutputTest, + 'parserTest': pt.ParserJsonTest, 'test': JsonTest } diff --git a/tests/src/test.js b/tests/src/test.js index 2417d2d..eab10c5 100644 --- a/tests/src/test.js +++ b/tests/src/test.js @@ -1,3 +1,27 @@ +/************************************************************* + * + * 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 Basic test classes. + * + * @author v.sorge@mathjax.org (Volker Sorge) + */ + /* globals System: true */ let test = require('tape'); diff --git a/tests/src/tex-keyval-tests.js b/tests/src/tex-keyval-tests.js deleted file mode 100644 index 3dc9af4..0000000 --- a/tests/src/tex-keyval-tests.js +++ /dev/null @@ -1,234 +0,0 @@ -import ParseUtil from '../node_modules/mathjax-full/js/input/tex/ParseUtil.js'; -import {Test} from './test.js'; - - -class KeyvalTest extends Test { - - runTest(name, options, expected) { - this.test( - name, - t => { - try { - let keyval = ParseUtil.keyvalOptions(options); - t.deepEqual(keyval, expected, name); - } catch (e) { - t.deepEqual(e.message, expected, name); - } - } - ); - } - -} - -let keyvalTest = new KeyvalTest(); - -keyvalTest.runTest( - 'Keyval Trival', 'key={{}}', - {key: true} -); - -keyvalTest.runTest( - 'Keyval Trivial 2', 'key1={{}},key2={{{{}}}}', - {key1: true, key2: true} -); - - -keyvalTest.runTest( - 'Keyval Trival3', 'key={{}{}}', - {key: '{}{}'} -); - -keyvalTest.runTest( - 'Keyval Trivial 4', 'key1= { { } },key2= {{ { { }} } }', - {key1: true, key2: true} -); - - -keyvalTest.runTest( - 'Keyval Single', 'key=a', - {key: 'a'} -); - -keyvalTest.runTest( - 'Keyval Double', 'key1=a,key2=b', - {key1: 'a', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Space', 'key1 = a , key2 = b', - {key1: 'a', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Single True', 'key1', - {key1: true} -); - -keyvalTest.runTest( - 'Keyval Double True', 'key1,key2', - {key1: true, key2: true} -); - -keyvalTest.runTest( - 'Keyval Mixed', 'key1=a,key2,key3=c', - {key1: 'a', key2: true, key3: 'c'} -); - -keyvalTest.runTest( - 'Keyval Empty Comma Begin', ',key1=a,key2,key3=c', - {key1: 'a', key2: true, key3: 'c'} -); - -keyvalTest.runTest( - 'Keyval Empty Comma Mid', 'key1=a,,key2,key3=c', - {key1: 'a', key2: true, key3: 'c'} -); - -keyvalTest.runTest( - 'Keyval Empty Comma End', 'key1=a,key2,key3=c,', - {key1: 'a', key2: true, key3: 'c'} -); - -keyvalTest.runTest( - 'Keyval Empty Comma Multi', ',,key1=a,,,,key2,key3=c,,', - {key1: 'a', key2: true, key3: 'c'} -); - -keyvalTest.runTest( - 'Keyval Braces', 'key1={a},key2=b', - {key1: 'a', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces 2', 'key1={{a}},key2=b', - {key1: 'a', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces 3', 'key1={{{a}}},key2=b', - {key1: 'a', key2: 'b'} -); - - -keyvalTest.runTest( - 'Keyval Braces Comma', 'key1={a,b,c},key2=b', - {key1: 'a,b,c', key2: 'b'} -); - - -keyvalTest.runTest( - 'Keyval Braces Equal', 'key1={a=c},key2=b', - {key1: 'a=c', key2: 'b'} -); - - -keyvalTest.runTest( - 'Keyval Braces Comma Equal', 'key1={a=c,b},key2=b', - {key1: 'a=c,b', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Simple 1', 'key1={{a}}', - {key1: 'a'} -); - -keyvalTest.runTest( - 'Keyval Braces Simple 2', 'key1={{a{b}}}', - {key1: 'a{b}'} -); - -keyvalTest.runTest( - 'Keyval Braces Simple 3', 'key1={{a={b}}}', - {key1: 'a={b}'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix', 'key1={{}a}', - {key1: '{}a'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix 2', 'key1={{{}}a}', - {key1: '{{}}a'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix 3', 'key1={{}{}a}', - {key1: '{}{}a'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix 4', 'key1={{{}{}a}}', - {key1: '{}{}a'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix 5', 'key1={{}{a}}', - {key1: '{}{a}'} -); - -keyvalTest.runTest( - 'Keyval Braces Prefix 6', 'key1={{{}}{a}}', - {key1: '{{}}{a}'} -); - -keyvalTest.runTest( - 'Keyval Braces Mixed 1', 'key1={{a},{b}},key2=b', - {key1: '{a},{b}', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Mixed 2', 'key1={{{a},{b}}},key2=b', - {key1: '{a},{b}', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Mixed 3', 'key1={{{a}},{{b},{c}}},key2=b', - {key1: '{{a}},{{b},{c}}', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Mixed 3 Spaces', 'key1 = { { { a}},{{b},{c} } } ,key2=b', - {key1: '{ { a}},{{b},{c} }', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Mixed 4 Spaces', 'key1 = { { { { { { a}},{{b},{c} } } } } } ,key2=b', - {key1: '{ { a}},{{b},{c} }', key2: 'b'} -); - -keyvalTest.runTest( - 'Keyval Braces Equals Mixed 3', 'key1={{{a}}={{b},{c}}},key2=b', - {key1: '{{a}}={{b},{c}}', key2: 'b'} -); - - -keyvalTest.runTest( - 'Keyval Error 1', 'key={{a}', - 'Extra open brace or missing close brace' -); - -keyvalTest.runTest( - 'Keyval Error 2', 'key={{a}{}', - 'Extra open brace or missing close brace' -); - -keyvalTest.runTest( - 'Keyval Error 3', 'key1=}, key2={', - 'Extra open brace or missing close brace' -); - -keyvalTest.runTest( - 'Keyval Unbalanced 1', 'key={a}}', - {key: 'a}'} -); - -keyvalTest.runTest( - 'Keyval Unbalanced 2', 'key1={a}}, key2=}b', - {key1: 'a}', key2: '}b'} -); - -keyvalTest.runTest( - 'Keyval Unbalanced 3', 'key1=}, key2={}}', - {key1: true, key2: true} -); diff --git a/tests/tests.sh b/tests/tests.sh index 1160f1b..ad31909 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -5,7 +5,8 @@ JSON=$DIR/json if [ $# -eq 0 ]; then - $NODE $DIR/src/tex-keyval-tests.js + $NODE src/run-test.js $JSON/KeyvalTest.json + ## $NODE $DIR/src/tex-keyval-tests.js $NODE src/run-test.js $JSON/ParserActionTest.json ## Reordered