diff --git a/test/artifacts/json5-tests/LICENSE.md b/test/artifacts/json5-tests/LICENSE.md new file mode 100644 index 0000000000..ae4049bbf0 --- /dev/null +++ b/test/artifacts/json5-tests/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2012-2016 Aseem Kishore, and [others](https://github.com/json5/json5/contributors). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/test/artifacts/json5-tests/README.md b/test/artifacts/json5-tests/README.md new file mode 100644 index 0000000000..76b9c81e58 --- /dev/null +++ b/test/artifacts/json5-tests/README.md @@ -0,0 +1,22 @@ +# Parse Test Cases for JSON5 + +The test cases' file extension signals the expected behavior: + +- Valid JSON should remain valid JSON5. These cases have a `.json` extension + and are tested via `JSON.parse()`. + +- JSON5's new features should remain valid ES5. These cases have a `.json5` + extension are tested via `eval()`. + +- Valid ES5 that's explicitly disallowed by JSON5 is also invalid JSON. These + cases have a `.js` extension and are expected to fail. + +- Invalid ES5 should remain invalid JSON5. These cases have a `.txt` extension + and are expected to fail. + +This should cover all our bases. Most of the cases are unit tests for each +supported data type, but aggregate test cases are welcome, too. + +## License + +MIT. See [LICENSE.md](./LICENSE.md) for details. diff --git a/test/artifacts/json5-tests/arrays/empty-array.json b/test/artifacts/json5-tests/arrays/empty-array.json new file mode 100644 index 0000000000..0637a088a0 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/empty-array.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/leading-comma-array.js b/test/artifacts/json5-tests/arrays/leading-comma-array.js new file mode 100644 index 0000000000..23c097c065 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/leading-comma-array.js @@ -0,0 +1,3 @@ +[ + ,null +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/lone-trailing-comma-array.js b/test/artifacts/json5-tests/arrays/lone-trailing-comma-array.js new file mode 100644 index 0000000000..013b45c5bb --- /dev/null +++ b/test/artifacts/json5-tests/arrays/lone-trailing-comma-array.js @@ -0,0 +1,3 @@ +[ + , +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/no-comma-array.errorSpec b/test/artifacts/json5-tests/arrays/no-comma-array.errorSpec new file mode 100644 index 0000000000..b476eca846 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/no-comma-array.errorSpec @@ -0,0 +1,6 @@ +{ + at: 16, + lineNumber: 3, + columnNumber: 5, + message: "Expected ']' instead of 'f'" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/no-comma-array.txt b/test/artifacts/json5-tests/arrays/no-comma-array.txt new file mode 100644 index 0000000000..22b41c10c2 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/no-comma-array.txt @@ -0,0 +1,4 @@ +[ + true + false +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/regular-array.json b/test/artifacts/json5-tests/arrays/regular-array.json new file mode 100644 index 0000000000..9072780299 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/regular-array.json @@ -0,0 +1,5 @@ +[ + true, + false, + null +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/arrays/trailing-comma-array.json5 b/test/artifacts/json5-tests/arrays/trailing-comma-array.json5 new file mode 100644 index 0000000000..6e6b6ede52 --- /dev/null +++ b/test/artifacts/json5-tests/arrays/trailing-comma-array.json5 @@ -0,0 +1,3 @@ +[ + null, +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/block-comment-following-array-element.json5 b/test/artifacts/json5-tests/comments/block-comment-following-array-element.json5 new file mode 100644 index 0000000000..8677f63db3 --- /dev/null +++ b/test/artifacts/json5-tests/comments/block-comment-following-array-element.json5 @@ -0,0 +1,6 @@ +[ + false + /* + true + */ +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/block-comment-following-top-level-value.json5 b/test/artifacts/json5-tests/comments/block-comment-following-top-level-value.json5 new file mode 100644 index 0000000000..1e6ccfd273 --- /dev/null +++ b/test/artifacts/json5-tests/comments/block-comment-following-top-level-value.json5 @@ -0,0 +1,5 @@ +null +/* + Some non-comment top-level value is needed; + we use null above. +*/ \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/block-comment-in-string.json b/test/artifacts/json5-tests/comments/block-comment-in-string.json new file mode 100644 index 0000000000..7d2916c50c --- /dev/null +++ b/test/artifacts/json5-tests/comments/block-comment-in-string.json @@ -0,0 +1 @@ +"This /* block comment */ isn't really a block comment." \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/block-comment-preceding-top-level-value.json5 b/test/artifacts/json5-tests/comments/block-comment-preceding-top-level-value.json5 new file mode 100644 index 0000000000..df1e52044e --- /dev/null +++ b/test/artifacts/json5-tests/comments/block-comment-preceding-top-level-value.json5 @@ -0,0 +1,5 @@ +/* + Some non-comment top-level value is needed; + we use null below. +*/ +null \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/block-comment-with-asterisks.json5 b/test/artifacts/json5-tests/comments/block-comment-with-asterisks.json5 new file mode 100644 index 0000000000..94c44e79e3 --- /dev/null +++ b/test/artifacts/json5-tests/comments/block-comment-with-asterisks.json5 @@ -0,0 +1,7 @@ +/** + * This is a JavaDoc-like block comment. + * It contains asterisks inside of it. + * It might also be closed with multiple asterisks. + * Like this: + **/ +true \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/inline-comment-following-array-element.json5 b/test/artifacts/json5-tests/comments/inline-comment-following-array-element.json5 new file mode 100644 index 0000000000..d6a3f8c64b --- /dev/null +++ b/test/artifacts/json5-tests/comments/inline-comment-following-array-element.json5 @@ -0,0 +1,3 @@ +[ + false // true +] \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/inline-comment-following-top-level-value.json5 b/test/artifacts/json5-tests/comments/inline-comment-following-top-level-value.json5 new file mode 100644 index 0000000000..cf9ed019bb --- /dev/null +++ b/test/artifacts/json5-tests/comments/inline-comment-following-top-level-value.json5 @@ -0,0 +1 @@ +null // Some non-comment top-level value is needed; we use null here. \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/inline-comment-in-string.json b/test/artifacts/json5-tests/comments/inline-comment-in-string.json new file mode 100644 index 0000000000..f0fb14f694 --- /dev/null +++ b/test/artifacts/json5-tests/comments/inline-comment-in-string.json @@ -0,0 +1 @@ +"This inline comment // isn't really an inline comment." \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/inline-comment-preceding-top-level-value.json5 b/test/artifacts/json5-tests/comments/inline-comment-preceding-top-level-value.json5 new file mode 100644 index 0000000000..d4b9b4d13f --- /dev/null +++ b/test/artifacts/json5-tests/comments/inline-comment-preceding-top-level-value.json5 @@ -0,0 +1,2 @@ +// Some non-comment top-level value is needed; we use null below. +null \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/top-level-block-comment.errorSpec b/test/artifacts/json5-tests/comments/top-level-block-comment.errorSpec new file mode 100644 index 0000000000..9bf5cf517d --- /dev/null +++ b/test/artifacts/json5-tests/comments/top-level-block-comment.errorSpec @@ -0,0 +1,6 @@ +{ + at: 77, + lineNumber: 4, + columnNumber: 3, + message: "Unexpected EOF" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/top-level-block-comment.txt b/test/artifacts/json5-tests/comments/top-level-block-comment.txt new file mode 100644 index 0000000000..7466bd2c0b --- /dev/null +++ b/test/artifacts/json5-tests/comments/top-level-block-comment.txt @@ -0,0 +1,4 @@ +/* + This should fail; + comments cannot be the only top-level value. +*/ \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/top-level-inline-comment.errorSpec b/test/artifacts/json5-tests/comments/top-level-inline-comment.errorSpec new file mode 100644 index 0000000000..3d915cd40f --- /dev/null +++ b/test/artifacts/json5-tests/comments/top-level-inline-comment.errorSpec @@ -0,0 +1,6 @@ +{ + at: 66, + lineNumber: 1, + columnNumber: 67, + message: "Unexpected EOF" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/top-level-inline-comment.txt b/test/artifacts/json5-tests/comments/top-level-inline-comment.txt new file mode 100644 index 0000000000..c5577f19dc --- /dev/null +++ b/test/artifacts/json5-tests/comments/top-level-inline-comment.txt @@ -0,0 +1 @@ +// This should fail; comments cannot be the only top-level value. \ No newline at end of file diff --git a/test/artifacts/json5-tests/comments/unterminated-block-comment.txt b/test/artifacts/json5-tests/comments/unterminated-block-comment.txt new file mode 100644 index 0000000000..627b7bd17c --- /dev/null +++ b/test/artifacts/json5-tests/comments/unterminated-block-comment.txt @@ -0,0 +1,5 @@ +true +/* + This block comment doesn't terminate. + There was a legitimate value before this, + but this is still invalid JS/JSON5. diff --git a/test/artifacts/json5-tests/misc/empty.txt b/test/artifacts/json5-tests/misc/empty.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/artifacts/json5-tests/misc/npm-package.json b/test/artifacts/json5-tests/misc/npm-package.json new file mode 100644 index 0000000000..85568da173 --- /dev/null +++ b/test/artifacts/json5-tests/misc/npm-package.json @@ -0,0 +1,106 @@ +{ + "name": "npm", + "publishConfig": { + "proprietary-attribs": false + }, + "description": "A package manager for node", + "keywords": [ + "package manager", + "modules", + "install", + "package.json" + ], + "version": "1.1.22", + "preferGlobal": true, + "config": { + "publishtest": false + }, + "homepage": "http://npmjs.org/", + "author": "Isaac Z. Schlueter (http://blog.izs.me)", + "repository": { + "type": "git", + "url": "https://github.com/isaacs/npm" + }, + "bugs": { + "email": "npm-@googlegroups.com", + "url": "http://github.com/isaacs/npm/issues" + }, + "directories": { + "doc": "./doc", + "man": "./man", + "lib": "./lib", + "bin": "./bin" + }, + "main": "./lib/npm.js", + "bin": "./bin/npm-cli.js", + "dependencies": { + "semver": "~1.0.14", + "ini": "1", + "slide": "1", + "abbrev": "1", + "graceful-fs": "~1.1.1", + "minimatch": "~0.2", + "nopt": "1", + "node-uuid": "~1.3", + "proto-list": "1", + "rimraf": "2", + "request": "~2.9", + "which": "1", + "tar": "~0.1.12", + "fstream": "~0.1.17", + "block-stream": "*", + "inherits": "1", + "mkdirp": "0.3", + "read": "0", + "lru-cache": "1", + "node-gyp": "~0.4.1", + "fstream-npm": "0 >=0.0.5", + "uid-number": "0", + "archy": "0", + "chownr": "0" + }, + "bundleDependencies": [ + "slide", + "ini", + "semver", + "abbrev", + "graceful-fs", + "minimatch", + "nopt", + "node-uuid", + "rimraf", + "request", + "proto-list", + "which", + "tar", + "fstream", + "block-stream", + "inherits", + "mkdirp", + "read", + "lru-cache", + "node-gyp", + "fstream-npm", + "uid-number", + "archy", + "chownr" + ], + "devDependencies": { + "ronn": "https://github.com/isaacs/ronnjs/tarball/master" + }, + "engines": { + "node": "0.6 || 0.7 || 0.8", + "npm": "1" + }, + "scripts": { + "test": "node ./test/run.js", + "prepublish": "npm prune; rm -rf node_modules/*/{test,example,bench}*; make -j4 doc", + "dumpconf": "env | grep npm | sort | uniq" + }, + "licenses": [ + { + "type": "MIT +no-false-attribs", + "url": "http://github.com/isaacs/npm/raw/master/LICENSE" + } + ] +} diff --git a/test/artifacts/json5-tests/misc/npm-package.json5 b/test/artifacts/json5-tests/misc/npm-package.json5 new file mode 100644 index 0000000000..699440659d --- /dev/null +++ b/test/artifacts/json5-tests/misc/npm-package.json5 @@ -0,0 +1,106 @@ +{ + name: 'npm', + publishConfig: { + 'proprietary-attribs': false, + }, + description: 'A package manager for node', + keywords: [ + 'package manager', + 'modules', + 'install', + 'package.json', + ], + version: '1.1.22', + preferGlobal: true, + config: { + publishtest: false, + }, + homepage: 'http://npmjs.org/', + author: 'Isaac Z. Schlueter (http://blog.izs.me)', + repository: { + type: 'git', + url: 'https://github.com/isaacs/npm', + }, + bugs: { + email: 'npm-@googlegroups.com', + url: 'http://github.com/isaacs/npm/issues', + }, + directories: { + doc: './doc', + man: './man', + lib: './lib', + bin: './bin', + }, + main: './lib/npm.js', + bin: './bin/npm-cli.js', + dependencies: { + semver: '~1.0.14', + ini: '1', + slide: '1', + abbrev: '1', + 'graceful-fs': '~1.1.1', + minimatch: '~0.2', + nopt: '1', + 'node-uuid': '~1.3', + 'proto-list': '1', + rimraf: '2', + request: '~2.9', + which: '1', + tar: '~0.1.12', + fstream: '~0.1.17', + 'block-stream': '*', + inherits: '1', + mkdirp: '0.3', + read: '0', + 'lru-cache': '1', + 'node-gyp': '~0.4.1', + 'fstream-npm': '0 >=0.0.5', + 'uid-number': '0', + archy: '0', + chownr: '0', + }, + bundleDependencies: [ + 'slide', + 'ini', + 'semver', + 'abbrev', + 'graceful-fs', + 'minimatch', + 'nopt', + 'node-uuid', + 'rimraf', + 'request', + 'proto-list', + 'which', + 'tar', + 'fstream', + 'block-stream', + 'inherits', + 'mkdirp', + 'read', + 'lru-cache', + 'node-gyp', + 'fstream-npm', + 'uid-number', + 'archy', + 'chownr', + ], + devDependencies: { + ronn: 'https://github.com/isaacs/ronnjs/tarball/master', + }, + engines: { + node: '0.6 || 0.7 || 0.8', + npm: '1', + }, + scripts: { + test: 'node ./test/run.js', + prepublish: 'npm prune; rm -rf node_modules/*/{test,example,bench}*; make -j4 doc', + dumpconf: 'env | grep npm | sort | uniq', + }, + licenses: [ + { + type: 'MIT +no-false-attribs', + url: 'http://github.com/isaacs/npm/raw/master/LICENSE', + }, + ], +} diff --git a/test/artifacts/json5-tests/misc/readme-example.json5 b/test/artifacts/json5-tests/misc/readme-example.json5 new file mode 100644 index 0000000000..25c920a3ce --- /dev/null +++ b/test/artifacts/json5-tests/misc/readme-example.json5 @@ -0,0 +1,25 @@ +{ + foo: 'bar', + while: true, + + this: 'is a \ +multi-line string', + + // this is an inline comment + here: 'is another', // inline comment + + /* this is a block comment + that continues on another line */ + + hex: 0xDEADbeef, + half: .5, + delta: +10, + to: Infinity, // and beyond! + + finally: 'a trailing comma', + oh: [ + "we shouldn't forget", + 'arrays can have', + 'trailing commas too', + ], +} diff --git a/test/artifacts/json5-tests/misc/valid-whitespace.json5 b/test/artifacts/json5-tests/misc/valid-whitespace.json5 new file mode 100644 index 0000000000..5cb57d3648 --- /dev/null +++ b/test/artifacts/json5-tests/misc/valid-whitespace.json5 @@ -0,0 +1,5 @@ +{ + // An invalid form feed character (\x0c) has been entered before this comment. + // Be careful not to delete it. + "a": true +} diff --git a/test/artifacts/json5-tests/new-lines/.editorconfig b/test/artifacts/json5-tests/new-lines/.editorconfig new file mode 100644 index 0000000000..1784f9e321 --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/.editorconfig @@ -0,0 +1,13 @@ +# Since we're testing different representations of new lines, +# make sure the editor doesn't mangle line endings. +# Don't commit files in this directory unless you've checked +# their escaped new lines. + +[*-lf.*] +end_of_line = lf + +[*-cr.*] +end_of_line = cr + +[*-crlf.*] +end_of_line = crlf diff --git a/test/artifacts/json5-tests/new-lines/.gitattributes b/test/artifacts/json5-tests/new-lines/.gitattributes new file mode 100644 index 0000000000..2b3eea6957 --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/.gitattributes @@ -0,0 +1,4 @@ +# Since we're testing different representations of new lines, +# treat all tests in this folder as binary files. + +* binary diff --git a/test/artifacts/json5-tests/new-lines/comment-cr.json5 b/test/artifacts/json5-tests/new-lines/comment-cr.json5 new file mode 100644 index 0000000000..e55aff8832 --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/comment-cr.json5 @@ -0,0 +1 @@ +{ // This comment is terminated with `\r`. } \ No newline at end of file diff --git a/test/artifacts/json5-tests/new-lines/comment-crlf.json5 b/test/artifacts/json5-tests/new-lines/comment-crlf.json5 new file mode 100644 index 0000000000..3791ee6bda --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/comment-crlf.json5 @@ -0,0 +1,3 @@ +{ + // This comment is terminated with `\r\n`. +} diff --git a/test/artifacts/json5-tests/new-lines/comment-lf.json5 b/test/artifacts/json5-tests/new-lines/comment-lf.json5 new file mode 100644 index 0000000000..e17dd72c6e --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/comment-lf.json5 @@ -0,0 +1,3 @@ +{ + // This comment is terminated with `\n`. +} diff --git a/test/artifacts/json5-tests/new-lines/escaped-cr.json5 b/test/artifacts/json5-tests/new-lines/escaped-cr.json5 new file mode 100644 index 0000000000..38e55b6cc3 --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/escaped-cr.json5 @@ -0,0 +1 @@ +{ // the following string contains an escaped `\r` a: 'line 1 \ line 2' } \ No newline at end of file diff --git a/test/artifacts/json5-tests/new-lines/escaped-crlf.json5 b/test/artifacts/json5-tests/new-lines/escaped-crlf.json5 new file mode 100644 index 0000000000..7e3f1ce4d5 --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/escaped-crlf.json5 @@ -0,0 +1,5 @@ +{ + // the following string contains an escaped `\r\n` + a: 'line 1 \ +line 2' +} diff --git a/test/artifacts/json5-tests/new-lines/escaped-lf.json5 b/test/artifacts/json5-tests/new-lines/escaped-lf.json5 new file mode 100644 index 0000000000..2235e8c7fe --- /dev/null +++ b/test/artifacts/json5-tests/new-lines/escaped-lf.json5 @@ -0,0 +1,5 @@ +{ + // the following string contains an escaped `\n` + a: 'line 1 \ +line 2' +} diff --git a/test/artifacts/json5-tests/numbers/float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/float-leading-decimal-point.json5 new file mode 100644 index 0000000000..d6c9fff3d7 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float-leading-decimal-point.json5 @@ -0,0 +1 @@ +.5 diff --git a/test/artifacts/json5-tests/numbers/float-leading-zero.json b/test/artifacts/json5-tests/numbers/float-leading-zero.json new file mode 100644 index 0000000000..2eb3c4fe4e --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float-leading-zero.json @@ -0,0 +1 @@ +0.5 diff --git a/test/artifacts/json5-tests/numbers/float-trailing-decimal-point-with-integer-exponent.json5 b/test/artifacts/json5-tests/numbers/float-trailing-decimal-point-with-integer-exponent.json5 new file mode 100644 index 0000000000..70b872070d --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float-trailing-decimal-point-with-integer-exponent.json5 @@ -0,0 +1 @@ +5.e4 diff --git a/test/artifacts/json5-tests/numbers/float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..e4c8c3130a --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float-trailing-decimal-point.json5 @@ -0,0 +1 @@ +5. diff --git a/test/artifacts/json5-tests/numbers/float-with-integer-exponent.json b/test/artifacts/json5-tests/numbers/float-with-integer-exponent.json new file mode 100644 index 0000000000..0e957c6332 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float-with-integer-exponent.json @@ -0,0 +1 @@ +1.2e3 diff --git a/test/artifacts/json5-tests/numbers/float.json b/test/artifacts/json5-tests/numbers/float.json new file mode 100644 index 0000000000..5625e59da8 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/float.json @@ -0,0 +1 @@ +1.2 diff --git a/test/artifacts/json5-tests/numbers/hexadecimal-empty.txt b/test/artifacts/json5-tests/numbers/hexadecimal-empty.txt new file mode 100644 index 0000000000..ec687260b8 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/hexadecimal-empty.txt @@ -0,0 +1 @@ +0x diff --git a/test/artifacts/json5-tests/numbers/hexadecimal-lowercase-letter.json5 b/test/artifacts/json5-tests/numbers/hexadecimal-lowercase-letter.json5 new file mode 100644 index 0000000000..57e27eede0 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/hexadecimal-lowercase-letter.json5 @@ -0,0 +1 @@ +0xc8 diff --git a/test/artifacts/json5-tests/numbers/hexadecimal-uppercase-x.json5 b/test/artifacts/json5-tests/numbers/hexadecimal-uppercase-x.json5 new file mode 100644 index 0000000000..1a35066be7 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/hexadecimal-uppercase-x.json5 @@ -0,0 +1 @@ +0XC8 diff --git a/test/artifacts/json5-tests/numbers/hexadecimal-with-integer-exponent.json5 b/test/artifacts/json5-tests/numbers/hexadecimal-with-integer-exponent.json5 new file mode 100644 index 0000000000..3c2204af84 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/hexadecimal-with-integer-exponent.json5 @@ -0,0 +1 @@ +0xc8e4 diff --git a/test/artifacts/json5-tests/numbers/hexadecimal.json5 b/test/artifacts/json5-tests/numbers/hexadecimal.json5 new file mode 100644 index 0000000000..cf832ed1da --- /dev/null +++ b/test/artifacts/json5-tests/numbers/hexadecimal.json5 @@ -0,0 +1 @@ +0xC8 diff --git a/test/artifacts/json5-tests/numbers/infinity.json5 b/test/artifacts/json5-tests/numbers/infinity.json5 new file mode 100644 index 0000000000..3c62151db7 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/infinity.json5 @@ -0,0 +1 @@ +Infinity diff --git a/test/artifacts/json5-tests/numbers/integer-with-float-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-float-exponent.txt new file mode 100644 index 0000000000..fa0688c933 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-float-exponent.txt @@ -0,0 +1 @@ +1e2.3 diff --git a/test/artifacts/json5-tests/numbers/integer-with-hexadecimal-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-hexadecimal-exponent.txt new file mode 100644 index 0000000000..0f58237dcf --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-hexadecimal-exponent.txt @@ -0,0 +1 @@ +1e0x4 diff --git a/test/artifacts/json5-tests/numbers/integer-with-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-integer-exponent.json new file mode 100644 index 0000000000..0d5cde84b5 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-integer-exponent.json @@ -0,0 +1 @@ +2e23 diff --git a/test/artifacts/json5-tests/numbers/integer-with-negative-float-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-negative-float-exponent.txt new file mode 100644 index 0000000000..5be09158f5 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-negative-float-exponent.txt @@ -0,0 +1 @@ +1e-2.3 diff --git a/test/artifacts/json5-tests/numbers/integer-with-negative-hexadecimal-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-negative-hexadecimal-exponent.txt new file mode 100644 index 0000000000..adeb2b9836 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-negative-hexadecimal-exponent.txt @@ -0,0 +1 @@ +1e-0x4 diff --git a/test/artifacts/json5-tests/numbers/integer-with-negative-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-negative-integer-exponent.json new file mode 100644 index 0000000000..6118c3ecd3 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-negative-integer-exponent.json @@ -0,0 +1 @@ +2e-23 diff --git a/test/artifacts/json5-tests/numbers/integer-with-negative-zero-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-negative-zero-integer-exponent.json new file mode 100644 index 0000000000..eb67bf46c2 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-negative-zero-integer-exponent.json @@ -0,0 +1 @@ +5e-0 diff --git a/test/artifacts/json5-tests/numbers/integer-with-positive-float-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-positive-float-exponent.txt new file mode 100644 index 0000000000..f89d55ecf3 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-positive-float-exponent.txt @@ -0,0 +1 @@ +1e+2.3 diff --git a/test/artifacts/json5-tests/numbers/integer-with-positive-hexadecimal-exponent.txt b/test/artifacts/json5-tests/numbers/integer-with-positive-hexadecimal-exponent.txt new file mode 100644 index 0000000000..a6c75d9495 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-positive-hexadecimal-exponent.txt @@ -0,0 +1 @@ +1e+0x4 diff --git a/test/artifacts/json5-tests/numbers/integer-with-positive-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-positive-integer-exponent.json new file mode 100644 index 0000000000..90c0616f53 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-positive-integer-exponent.json @@ -0,0 +1 @@ +1e+2 diff --git a/test/artifacts/json5-tests/numbers/integer-with-positive-zero-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-positive-zero-integer-exponent.json new file mode 100644 index 0000000000..1d7002f9f2 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-positive-zero-integer-exponent.json @@ -0,0 +1 @@ +5e+0 diff --git a/test/artifacts/json5-tests/numbers/integer-with-zero-integer-exponent.json b/test/artifacts/json5-tests/numbers/integer-with-zero-integer-exponent.json new file mode 100644 index 0000000000..a5e3196e3a --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer-with-zero-integer-exponent.json @@ -0,0 +1 @@ +5e0 diff --git a/test/artifacts/json5-tests/numbers/integer.json b/test/artifacts/json5-tests/numbers/integer.json new file mode 100644 index 0000000000..60d3b2f4a4 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/integer.json @@ -0,0 +1 @@ +15 diff --git a/test/artifacts/json5-tests/numbers/lone-decimal-point.txt b/test/artifacts/json5-tests/numbers/lone-decimal-point.txt new file mode 100644 index 0000000000..9c558e357c --- /dev/null +++ b/test/artifacts/json5-tests/numbers/lone-decimal-point.txt @@ -0,0 +1 @@ +. diff --git a/test/artifacts/json5-tests/numbers/nan.json5 b/test/artifacts/json5-tests/numbers/nan.json5 new file mode 100644 index 0000000000..736991a138 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/nan.json5 @@ -0,0 +1 @@ +NaN diff --git a/test/artifacts/json5-tests/numbers/negative-float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/negative-float-leading-decimal-point.json5 new file mode 100644 index 0000000000..c6eaee5ce7 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-float-leading-decimal-point.json5 @@ -0,0 +1 @@ +-.5 diff --git a/test/artifacts/json5-tests/numbers/negative-float-leading-zero.json b/test/artifacts/json5-tests/numbers/negative-float-leading-zero.json new file mode 100644 index 0000000000..e118203f34 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-float-leading-zero.json @@ -0,0 +1 @@ +-0.5 diff --git a/test/artifacts/json5-tests/numbers/negative-float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/negative-float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..52e52459fc --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-float-trailing-decimal-point.json5 @@ -0,0 +1 @@ +-5. diff --git a/test/artifacts/json5-tests/numbers/negative-float.json b/test/artifacts/json5-tests/numbers/negative-float.json new file mode 100644 index 0000000000..1d94c8a014 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-float.json @@ -0,0 +1 @@ +-1.2 diff --git a/test/artifacts/json5-tests/numbers/negative-hexadecimal.json5 b/test/artifacts/json5-tests/numbers/negative-hexadecimal.json5 new file mode 100644 index 0000000000..8882fae361 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-hexadecimal.json5 @@ -0,0 +1 @@ +-0xC8 diff --git a/test/artifacts/json5-tests/numbers/negative-infinity.json5 b/test/artifacts/json5-tests/numbers/negative-infinity.json5 new file mode 100644 index 0000000000..879e80ee34 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-infinity.json5 @@ -0,0 +1 @@ +-Infinity diff --git a/test/artifacts/json5-tests/numbers/negative-integer.json b/test/artifacts/json5-tests/numbers/negative-integer.json new file mode 100644 index 0000000000..21922364cc --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-integer.json @@ -0,0 +1 @@ +-15 diff --git a/test/artifacts/json5-tests/numbers/negative-noctal.js b/test/artifacts/json5-tests/numbers/negative-noctal.js new file mode 100644 index 0000000000..8826f48663 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-noctal.js @@ -0,0 +1 @@ +-098 diff --git a/test/artifacts/json5-tests/numbers/negative-octal.txt b/test/artifacts/json5-tests/numbers/negative-octal.txt new file mode 100644 index 0000000000..2e7a4b4500 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-octal.txt @@ -0,0 +1 @@ +-0123 diff --git a/test/artifacts/json5-tests/numbers/negative-zero-float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/negative-zero-float-leading-decimal-point.json5 new file mode 100644 index 0000000000..8dd8e037eb --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-float-leading-decimal-point.json5 @@ -0,0 +1 @@ +-.0 diff --git a/test/artifacts/json5-tests/numbers/negative-zero-float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/negative-zero-float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..90cc048c59 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-float-trailing-decimal-point.json5 @@ -0,0 +1 @@ +-0. diff --git a/test/artifacts/json5-tests/numbers/negative-zero-float.json b/test/artifacts/json5-tests/numbers/negative-zero-float.json new file mode 100644 index 0000000000..1344bfd9db --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-float.json @@ -0,0 +1 @@ +-0.0 diff --git a/test/artifacts/json5-tests/numbers/negative-zero-hexadecimal.json5 b/test/artifacts/json5-tests/numbers/negative-zero-hexadecimal.json5 new file mode 100644 index 0000000000..8847d0524d --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-hexadecimal.json5 @@ -0,0 +1 @@ +-0x0 diff --git a/test/artifacts/json5-tests/numbers/negative-zero-integer.json b/test/artifacts/json5-tests/numbers/negative-zero-integer.json new file mode 100644 index 0000000000..ec064f61ba --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-integer.json @@ -0,0 +1 @@ +-0 diff --git a/test/artifacts/json5-tests/numbers/negative-zero-octal.txt b/test/artifacts/json5-tests/numbers/negative-zero-octal.txt new file mode 100644 index 0000000000..200a801846 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/negative-zero-octal.txt @@ -0,0 +1 @@ +-00 diff --git a/test/artifacts/json5-tests/numbers/noctal-with-leading-octal-digit.js b/test/artifacts/json5-tests/numbers/noctal-with-leading-octal-digit.js new file mode 100644 index 0000000000..1fd7c08c14 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/noctal-with-leading-octal-digit.js @@ -0,0 +1 @@ +0780 diff --git a/test/artifacts/json5-tests/numbers/noctal.js b/test/artifacts/json5-tests/numbers/noctal.js new file mode 100644 index 0000000000..fa5c7835bd --- /dev/null +++ b/test/artifacts/json5-tests/numbers/noctal.js @@ -0,0 +1 @@ +080 diff --git a/test/artifacts/json5-tests/numbers/octal.txt b/test/artifacts/json5-tests/numbers/octal.txt new file mode 100644 index 0000000000..9e8493eaee --- /dev/null +++ b/test/artifacts/json5-tests/numbers/octal.txt @@ -0,0 +1 @@ +010 diff --git a/test/artifacts/json5-tests/numbers/positive-float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/positive-float-leading-decimal-point.json5 new file mode 100644 index 0000000000..043460803c --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-float-leading-decimal-point.json5 @@ -0,0 +1 @@ ++.5 diff --git a/test/artifacts/json5-tests/numbers/positive-float-leading-zero.json5 b/test/artifacts/json5-tests/numbers/positive-float-leading-zero.json5 new file mode 100644 index 0000000000..d89b45d161 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-float-leading-zero.json5 @@ -0,0 +1 @@ ++0.5 diff --git a/test/artifacts/json5-tests/numbers/positive-float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/positive-float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..bee758a7bc --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-float-trailing-decimal-point.json5 @@ -0,0 +1 @@ ++5. diff --git a/test/artifacts/json5-tests/numbers/positive-float.json5 b/test/artifacts/json5-tests/numbers/positive-float.json5 new file mode 100644 index 0000000000..c5732cbcfb --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-float.json5 @@ -0,0 +1 @@ ++1.2 diff --git a/test/artifacts/json5-tests/numbers/positive-hexadecimal.json5 b/test/artifacts/json5-tests/numbers/positive-hexadecimal.json5 new file mode 100644 index 0000000000..c91ede9698 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-hexadecimal.json5 @@ -0,0 +1 @@ ++0xC8 diff --git a/test/artifacts/json5-tests/numbers/positive-infinity.json5 b/test/artifacts/json5-tests/numbers/positive-infinity.json5 new file mode 100644 index 0000000000..9bcb989f10 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-infinity.json5 @@ -0,0 +1 @@ ++Infinity diff --git a/test/artifacts/json5-tests/numbers/positive-integer.json5 b/test/artifacts/json5-tests/numbers/positive-integer.json5 new file mode 100644 index 0000000000..8ed01e070e --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-integer.json5 @@ -0,0 +1 @@ ++15 diff --git a/test/artifacts/json5-tests/numbers/positive-noctal.js b/test/artifacts/json5-tests/numbers/positive-noctal.js new file mode 100644 index 0000000000..2f450fce46 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-noctal.js @@ -0,0 +1 @@ ++098 diff --git a/test/artifacts/json5-tests/numbers/positive-octal.txt b/test/artifacts/json5-tests/numbers/positive-octal.txt new file mode 100644 index 0000000000..faa86009c5 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-octal.txt @@ -0,0 +1 @@ ++0123 diff --git a/test/artifacts/json5-tests/numbers/positive-zero-float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/positive-zero-float-leading-decimal-point.json5 new file mode 100644 index 0000000000..557bcde17b --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-float-leading-decimal-point.json5 @@ -0,0 +1 @@ ++.0 diff --git a/test/artifacts/json5-tests/numbers/positive-zero-float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/positive-zero-float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..d8912d161a --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-float-trailing-decimal-point.json5 @@ -0,0 +1 @@ ++0. diff --git a/test/artifacts/json5-tests/numbers/positive-zero-float.json5 b/test/artifacts/json5-tests/numbers/positive-zero-float.json5 new file mode 100644 index 0000000000..11e8402c56 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-float.json5 @@ -0,0 +1 @@ ++0.0 diff --git a/test/artifacts/json5-tests/numbers/positive-zero-hexadecimal.json5 b/test/artifacts/json5-tests/numbers/positive-zero-hexadecimal.json5 new file mode 100644 index 0000000000..40a9ce6374 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-hexadecimal.json5 @@ -0,0 +1 @@ ++0x0 diff --git a/test/artifacts/json5-tests/numbers/positive-zero-integer.json5 b/test/artifacts/json5-tests/numbers/positive-zero-integer.json5 new file mode 100644 index 0000000000..9317bcb621 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-integer.json5 @@ -0,0 +1 @@ ++0 diff --git a/test/artifacts/json5-tests/numbers/positive-zero-octal.txt b/test/artifacts/json5-tests/numbers/positive-zero-octal.txt new file mode 100644 index 0000000000..80959e57a5 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/positive-zero-octal.txt @@ -0,0 +1 @@ ++00 diff --git a/test/artifacts/json5-tests/numbers/zero-float-leading-decimal-point.json5 b/test/artifacts/json5-tests/numbers/zero-float-leading-decimal-point.json5 new file mode 100644 index 0000000000..7d856fdb3f --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-float-leading-decimal-point.json5 @@ -0,0 +1 @@ +.0 diff --git a/test/artifacts/json5-tests/numbers/zero-float-trailing-decimal-point.json5 b/test/artifacts/json5-tests/numbers/zero-float-trailing-decimal-point.json5 new file mode 100644 index 0000000000..17a5757b17 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-float-trailing-decimal-point.json5 @@ -0,0 +1 @@ +0. diff --git a/test/artifacts/json5-tests/numbers/zero-float.json b/test/artifacts/json5-tests/numbers/zero-float.json new file mode 100644 index 0000000000..ba66466c2a --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-float.json @@ -0,0 +1 @@ +0.0 diff --git a/test/artifacts/json5-tests/numbers/zero-hexadecimal.json5 b/test/artifacts/json5-tests/numbers/zero-hexadecimal.json5 new file mode 100644 index 0000000000..9982566dc0 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-hexadecimal.json5 @@ -0,0 +1 @@ +0x0 diff --git a/test/artifacts/json5-tests/numbers/zero-integer-with-integer-exponent.json b/test/artifacts/json5-tests/numbers/zero-integer-with-integer-exponent.json new file mode 100644 index 0000000000..da219e3f10 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-integer-with-integer-exponent.json @@ -0,0 +1 @@ +0e23 diff --git a/test/artifacts/json5-tests/numbers/zero-integer.json b/test/artifacts/json5-tests/numbers/zero-integer.json new file mode 100644 index 0000000000..573541ac97 --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-integer.json @@ -0,0 +1 @@ +0 diff --git a/test/artifacts/json5-tests/numbers/zero-octal.txt b/test/artifacts/json5-tests/numbers/zero-octal.txt new file mode 100644 index 0000000000..4daddb72ff --- /dev/null +++ b/test/artifacts/json5-tests/numbers/zero-octal.txt @@ -0,0 +1 @@ +00 diff --git a/test/artifacts/json5-tests/objects/duplicate-keys.json b/test/artifacts/json5-tests/objects/duplicate-keys.json new file mode 100644 index 0000000000..bb0e4cc3d3 --- /dev/null +++ b/test/artifacts/json5-tests/objects/duplicate-keys.json @@ -0,0 +1,4 @@ +{ + "a": true, + "a": false +} diff --git a/test/artifacts/json5-tests/objects/empty-object.json b/test/artifacts/json5-tests/objects/empty-object.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/test/artifacts/json5-tests/objects/empty-object.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.errorSpec b/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.errorSpec new file mode 100644 index 0000000000..e44dc850d8 --- /dev/null +++ b/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.errorSpec @@ -0,0 +1,6 @@ +{ + at: 7, + lineNumber: 2, + columnNumber: 5, + message: "Bad identifier as unquoted key" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.txt b/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.txt new file mode 100644 index 0000000000..aebcac2cde --- /dev/null +++ b/test/artifacts/json5-tests/objects/illegal-unquoted-key-number.txt @@ -0,0 +1,3 @@ +{ + 10twenty: "ten twenty" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.errorSpec b/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.errorSpec new file mode 100644 index 0000000000..95ba468319 --- /dev/null +++ b/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.errorSpec @@ -0,0 +1,6 @@ +{ + at: 12, + lineNumber: 2, + columnNumber: 10, + message: "Expected ':' instead of '-'" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.txt b/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.txt new file mode 100644 index 0000000000..4cb2bd5c0e --- /dev/null +++ b/test/artifacts/json5-tests/objects/illegal-unquoted-key-symbol.txt @@ -0,0 +1,3 @@ +{ + multi-word: "multi-word" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/leading-comma-object.errorSpec b/test/artifacts/json5-tests/objects/leading-comma-object.errorSpec new file mode 100644 index 0000000000..e44dc850d8 --- /dev/null +++ b/test/artifacts/json5-tests/objects/leading-comma-object.errorSpec @@ -0,0 +1,6 @@ +{ + at: 7, + lineNumber: 2, + columnNumber: 5, + message: "Bad identifier as unquoted key" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/leading-comma-object.txt b/test/artifacts/json5-tests/objects/leading-comma-object.txt new file mode 100644 index 0000000000..bfb3c51fa4 --- /dev/null +++ b/test/artifacts/json5-tests/objects/leading-comma-object.txt @@ -0,0 +1,3 @@ +{ + ,"foo": "bar" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/lone-trailing-comma-object.txt b/test/artifacts/json5-tests/objects/lone-trailing-comma-object.txt new file mode 100644 index 0000000000..3f3f9f796b --- /dev/null +++ b/test/artifacts/json5-tests/objects/lone-trailing-comma-object.txt @@ -0,0 +1,3 @@ +{ + , +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/no-comma-object.txt b/test/artifacts/json5-tests/objects/no-comma-object.txt new file mode 100644 index 0000000000..c0738750db --- /dev/null +++ b/test/artifacts/json5-tests/objects/no-comma-object.txt @@ -0,0 +1,4 @@ +{ + "foo": "bar" + "hello": "world" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/reserved-unquoted-key.json5 b/test/artifacts/json5-tests/objects/reserved-unquoted-key.json5 new file mode 100644 index 0000000000..4b80a63b4c --- /dev/null +++ b/test/artifacts/json5-tests/objects/reserved-unquoted-key.json5 @@ -0,0 +1,3 @@ +{ + while: true +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/single-quoted-key.json5 b/test/artifacts/json5-tests/objects/single-quoted-key.json5 new file mode 100644 index 0000000000..842ca19c6a --- /dev/null +++ b/test/artifacts/json5-tests/objects/single-quoted-key.json5 @@ -0,0 +1,3 @@ +{ + 'hello': "world" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/trailing-comma-object.json5 b/test/artifacts/json5-tests/objects/trailing-comma-object.json5 new file mode 100644 index 0000000000..ab61ba76e1 --- /dev/null +++ b/test/artifacts/json5-tests/objects/trailing-comma-object.json5 @@ -0,0 +1,3 @@ +{ + "foo": "bar", +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/objects/unquoted-keys.json5 b/test/artifacts/json5-tests/objects/unquoted-keys.json5 new file mode 100644 index 0000000000..0c06f3fc76 --- /dev/null +++ b/test/artifacts/json5-tests/objects/unquoted-keys.json5 @@ -0,0 +1,8 @@ +{ + hello: "world", + _: "underscore", + $: "dollar sign", + one1: "numerals", + _$_: "multiple symbols", + $_$hello123world_$_: "mixed" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/escaped-single-quoted-string.json5 b/test/artifacts/json5-tests/strings/escaped-single-quoted-string.json5 new file mode 100644 index 0000000000..1c799101b7 --- /dev/null +++ b/test/artifacts/json5-tests/strings/escaped-single-quoted-string.json5 @@ -0,0 +1 @@ +'I can\'t wait' \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/multi-line-string.json5 b/test/artifacts/json5-tests/strings/multi-line-string.json5 new file mode 100644 index 0000000000..964dc2decb --- /dev/null +++ b/test/artifacts/json5-tests/strings/multi-line-string.json5 @@ -0,0 +1,2 @@ +'hello\ + world' \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/no-comma-array.errorSpec b/test/artifacts/json5-tests/strings/no-comma-array.errorSpec new file mode 100644 index 0000000000..98355610e5 --- /dev/null +++ b/test/artifacts/json5-tests/strings/no-comma-array.errorSpec @@ -0,0 +1,6 @@ +{ + at: 16, + lineNumber: 3, + columNumber: 5, + message: "Expected ']' instead of 'f'" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/single-quoted-string.json5 b/test/artifacts/json5-tests/strings/single-quoted-string.json5 new file mode 100644 index 0000000000..5dadd333cc --- /dev/null +++ b/test/artifacts/json5-tests/strings/single-quoted-string.json5 @@ -0,0 +1 @@ +'hello world' \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/unescaped-multi-line-string.errorSpec b/test/artifacts/json5-tests/strings/unescaped-multi-line-string.errorSpec new file mode 100644 index 0000000000..a85f1ad185 --- /dev/null +++ b/test/artifacts/json5-tests/strings/unescaped-multi-line-string.errorSpec @@ -0,0 +1,6 @@ +{ + at: 5, + lineNumber: 2, + columnNumber: 0, + message: "Bad string" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/strings/unescaped-multi-line-string.txt b/test/artifacts/json5-tests/strings/unescaped-multi-line-string.txt new file mode 100644 index 0000000000..7325139a82 --- /dev/null +++ b/test/artifacts/json5-tests/strings/unescaped-multi-line-string.txt @@ -0,0 +1,2 @@ +"foo +bar" diff --git a/test/artifacts/json5-tests/todo/unicode-escaped-unquoted-key.json5 b/test/artifacts/json5-tests/todo/unicode-escaped-unquoted-key.json5 new file mode 100644 index 0000000000..56c3457113 --- /dev/null +++ b/test/artifacts/json5-tests/todo/unicode-escaped-unquoted-key.json5 @@ -0,0 +1,3 @@ +{ + sig\u03A3ma: "the sum of all things" +} \ No newline at end of file diff --git a/test/artifacts/json5-tests/todo/unicode-unquoted-key.json5 b/test/artifacts/json5-tests/todo/unicode-unquoted-key.json5 new file mode 100644 index 0000000000..98382e6997 --- /dev/null +++ b/test/artifacts/json5-tests/todo/unicode-unquoted-key.json5 @@ -0,0 +1,3 @@ +{ + ümlåût: "that's not really an ümlaüt, but this is" +} \ No newline at end of file diff --git a/test/functions/IsJson.cfc b/test/functions/IsJson.cfc index 2ca5aa6763..6599176c71 100644 --- a/test/functions/IsJson.cfc +++ b/test/functions/IsJson.cfc @@ -108,4 +108,45 @@ component extends="org.lucee.cfml.test.LuceeTestCase" { {a:1} ')); } + + // uses files from https://github.com/json5/json5-tests + private function testSuite (){ + var json5TestDir = expandPath( getDirectoryFromPath( getCurrentTemplatePath() ) & "../artifacts/json5-tests" ); + var json5Tests = directoryList( path=json5TestDir, recurse=true, listinfo="path", type="file" ); + var canJson5 = ( len( getFunctionData( "isJson" ).arguments ) == 2 ); + + expect( ArrayLen( json5Tests ) ).toBeGT( 0 ); + systemOutput( "", true); + systemOutput( "running json5 testsuite with #ArrayLen( json5Tests )# tests", true); + + loop array=json5Tests item="local.test"{ + var fileType = listLast( test, "." ); + var expectedResult=""; + switch( fileType ) { + case "json": + expectedResult = true; + break; + case "json5": + expectedResult = canJson5; + break; + case "txt": + expectedResult = false; + break; + case "js": + expectedResult = false; + break; + case "errorspec": + expectedResult = true; + break; + default: + expectedResult = false; + } + // due to false positives, this function is private / disabled LDEV-5017 + if ( isJson( fileRead( test ) ) neq expectedResult ) { + systemOutput( "expected: " & expectedResult & " isJson:" & isJson( fileRead( test ) ) & " " & test, true); + } + //TBD add second argument, version for json5 support + //expect( isJson( fileRead( test ) ) ).toBe( expectedResult, test ); + } + } }