diff --git a/vendor/hxjsonast/.gitignore b/vendor/hxjsonast/.gitignore deleted file mode 100644 index 5fde2af..0000000 --- a/vendor/hxjsonast/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/bin/* -!/bin/js -/bin/js/* -!/bin/js/index.html -/release.zip -/.unittest \ No newline at end of file diff --git a/vendor/hxjsonast/.travis.yml b/vendor/hxjsonast/.travis.yml deleted file mode 100644 index 5b127e7..0000000 --- a/vendor/hxjsonast/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -sudo: required -dist: trusty - -language: haxe - -os: - - linux - # - osx - -haxe: - - 3.2.1 - - 3.4.2 - - development - -matrix: - allow_failures: - - haxe: 3.2.1 - -install: - - haxelib install dox - - haxelib install travix - - haxelib run travix install - -script: - - if ! [ "$TRAVIS_HAXE_VERSION" == "3.2.1" ]; then haxelib run travix lua; fi - - haxelib run travix interp - - haxelib run travix neko - # - haxelib run travix js - - haxelib run travix node - - haxelib run travix php - - haxelib run travix python - - haxelib run travix java - - haxelib run travix cs - - haxelib run travix cpp - - haxelib run travix flash -D exit - - haxe doc.hxml - - bash doc-deploy.sh diff --git a/vendor/hxjsonast/.vscode/launch.json b/vendor/hxjsonast/.vscode/launch.json deleted file mode 100644 index b1684a4..0000000 --- a/vendor/hxjsonast/.vscode/launch.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "name": "Debug", - "type": "haxe-eval", - "request": "launch" - } - ] -} \ No newline at end of file diff --git a/vendor/hxjsonast/.vscode/tasks.json b/vendor/hxjsonast/.vscode/tasks.json deleted file mode 100644 index f040836..0000000 --- a/vendor/hxjsonast/.vscode/tasks.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "haxe", - "args": "active configuration", - "problemMatcher": [ - "$haxe-absolute", - "$haxe", - "$haxe-error", - "$haxe-trace" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} diff --git a/vendor/hxjsonast/Release.hx b/vendor/hxjsonast/Release.hx deleted file mode 100644 index 2079d45..0000000 --- a/vendor/hxjsonast/Release.hx +++ /dev/null @@ -1,60 +0,0 @@ -import haxe.crypto.Crc32; -import haxe.zip.Entry; -import haxe.zip.Writer; -import haxe.zip.Tools; - -import sys.io.File; -import sys.FileSystem; - -class Release { - static var outPath = "release.zip"; - static var files = ["haxelib.json", "src", "LICENSE", "README.md"]; - - static function makeZip() { - var entries = new List(); - - function add(path:String, target:String) { - if (!FileSystem.exists(path)) - throw 'Invalid path: $path'; - - if (FileSystem.isDirectory(path)) { - for (item in FileSystem.readDirectory(path)) - add(path + "/" + item, target + "/" + item); - } else { - trace("Adding " + target); - var bytes = File.getBytes(path); - var entry:Entry = { - fileName: target, - fileSize: bytes.length, - fileTime: FileSystem.stat(path).mtime, - compressed: false, - dataSize: 0, - data: bytes, - crc32: Crc32.make(bytes), - } - Tools.compress(entry, 9); - entries.add(entry); - } - - } - - for (file in files) - add(file, file); - - trace("Saving to " + outPath); - var out = File.write(outPath, true); - var writer = new Writer(out); - writer.write(entries); - out.close(); - } - - static function submitZip() { - trace("Submitting " + outPath); - Sys.command("haxelib", ["submit", outPath]); - } - - static function main() { - makeZip(); - submitZip(); - } -} diff --git a/vendor/hxjsonast/bin/js/index.html b/vendor/hxjsonast/bin/js/index.html deleted file mode 100644 index f03c46b..0000000 --- a/vendor/hxjsonast/bin/js/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/vendor/hxjsonast/doc-deploy.sh b/vendor/hxjsonast/doc-deploy.sh deleted file mode 100644 index 0f43356..0000000 --- a/vendor/hxjsonast/doc-deploy.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -set -e # exit with nonzero exit code if anything fails - -if ! [ "$TRAVIS_HAXE_VERSION" == "development" ]; then - echo "Skipping pushing to GitHub pages - that is only done for Haxe development."; - exit 0; -elif [ -z "$GHP_BOT_TOKEN" ]; then - echo "Skipping pushing to GitHub pages - missing GHP_BOT_TOKEN (probably in a PR build)."; - exit 0; -elif [ "$TRAVIS_BRANCH" != "master" ]; then - echo "Skipping pushing to GitHub pages - not master branch."; - exit 0; -else - echo "Pushing GitHub pages" -fi - -# go to the out directory and create a *new* Git repo -cd bin/doc -git init - -# inside this git repo we'll pretend to be a new user -git config user.name "Travis CI" -git config user.email "nadako@gmail.com" - -# The first and only commit to this new Git repo contains all the -# files present with the commit message "Deploy to GitHub Pages". -git add . -git commit -m "Deploy to GitHub Pages from ${TRAVIS_COMMIT}" - -# Force push from the current repo's master branch to the remote -# repo's gh-pages branch. (All previous history on the gh-pages branch -# will be lost, since we are overwriting it.) We redirect any output to -# /dev/null to hide any sensitive credential data that might otherwise be exposed. -git push --force --quiet "https://${GHP_BOT_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git" master:gh-pages > /dev/null 2>&1 && echo done diff --git a/vendor/hxjsonast/doc.hxml b/vendor/hxjsonast/doc.hxml deleted file mode 100644 index d7c77f1..0000000 --- a/vendor/hxjsonast/doc.hxml +++ /dev/null @@ -1,9 +0,0 @@ --cp src ---macro include("", true, null, ["src"]) --D doc-gen --js out.js ---no-output --xml bin/doc/js.xml - ---next --cmd haxelib run dox -i bin/doc -o bin/doc -in "^hxjsonast*" --title "hxjsonast - API documentation" -D source-path https://github.com/nadako/hxjsonast/blob/master/src/ -D website "https://github.com/nadako/hxjsonast" diff --git a/vendor/hxjsonast/haxelib.json b/vendor/hxjsonast/haxelib.json deleted file mode 100644 index f52ea2b..0000000 --- a/vendor/hxjsonast/haxelib.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "hxjsonast", - "description": "Type-safe position-aware JSON parsing & printing", - "license": "MIT", - "tags": ["cross", "json", "parser"], - "classPath": "src", - "contributors": ["nadako"], - "releasenote": "initial release", - "version": "1.0.1", - "url": "https://github.com/nadako/hxjsonast/", - "dependencies": {} -} diff --git a/vendor/hxjsonast/src/hxjsonast/Parser.hx b/vendor/hxjsonast/src/hxjsonast/Parser.hx index c1e7f04..c8f14c3 100644 --- a/vendor/hxjsonast/src/hxjsonast/Parser.hx +++ b/vendor/hxjsonast/src/hxjsonast/Parser.hx @@ -198,7 +198,7 @@ class Parser { } start = pos; } - #if (neko || php || cpp) + #if (neko || (!haxe4 && (php || cpp))) // ensure utf8 chars are not cut else if (c >= 0x80) { pos++; diff --git a/vendor/hxjsonast/test.hxml b/vendor/hxjsonast/test.hxml deleted file mode 100644 index 3702ba1..0000000 --- a/vendor/hxjsonast/test.hxml +++ /dev/null @@ -1,3 +0,0 @@ --cp src -tests.hxml ---interp diff --git a/vendor/hxjsonast/test/TestBase.hx b/vendor/hxjsonast/test/TestBase.hx deleted file mode 100644 index 2194a24..0000000 --- a/vendor/hxjsonast/test/TestBase.hx +++ /dev/null @@ -1,7 +0,0 @@ -#if (macro || haxe_ver < "3.4.0") -class TestBase { - public function new() {} -} -#else -typedef TestBase = utest.Test; -#end diff --git a/vendor/hxjsonast/test/TestMain.hx b/vendor/hxjsonast/test/TestMain.hx deleted file mode 100644 index 2687bc6..0000000 --- a/vendor/hxjsonast/test/TestMain.hx +++ /dev/null @@ -1,13 +0,0 @@ -import utest.Runner; -import utest.ui.Report; - -class TestMain { - static function main() { - var runner = new Runner(); - runner.addCase(new TestParser()); - runner.addCase(new TestPrinter()); - runner.addCase(new TestTools()); - Report.create(runner); - runner.run(); - } -} diff --git a/vendor/hxjsonast/test/TestParser.hx b/vendor/hxjsonast/test/TestParser.hx deleted file mode 100644 index 7533635..0000000 --- a/vendor/hxjsonast/test/TestParser.hx +++ /dev/null @@ -1,120 +0,0 @@ -import utest.Assert.*; -import hxjsonast.*; -import hxjsonast.Json; -import TestUtils.*; - -class TestParser extends TestBase { - public function test_string() { - check('""', mk(JString(""), mkPos(file, 0, 2))); - - check('"hello"', mk(JString("hello"), mkPos(file, 0, 7))); - check('"\\\"hi\\\\"', mk(JString("\"hi\\"), mkPos(file, 0, 8))); - check('{} ', mk(JObject([]), mkPos(file, 0, 2))); - - check('"\\/"', mk(JString("/"), mkPos(file, 0, 4))); - check('"\\b"', mk(JString(String.fromCharCode(8)), mkPos(file, 0, 4))); - check('"\\f"', mk(JString(String.fromCharCode(12)), mkPos(file, 0, 4))); - check('"\\n"', mk(JString("\n"), mkPos(file, 0, 4))); - check('"\\t"', mk(JString("\t"), mkPos(file, 0, 4))); - check('"\\u1234"', mk(JString("\u1234"), mkPos(file, 0, 8))); - - checkError('"adad', "Unclosed string", 0, 5); - checkError('"\\m"', "Invalid escape sequence \\m", 1, 3); - checkError('{"""a": 1}', "Invalid character: \"", 3, 4); - checkError('{}a', "Invalid character: a", 2, 3); - } - - public function test_number() { - for (s in ["123", "1.5", "1e1", "1e-1", "1e+1", "1.5e1", "1.5e-1", "1.5e+1"]) { - function c(s:String) { - inline function p(s:String, file:String):Position return mkPos(file, 0, s.length); - check(s, mk(JNumber(s), p(s, file))); - } - c(s); - c('-$s'); - s = s.toUpperCase(); // for uppercase E in scientific float - c(s); - c('-$s'); - } - - // TODO: more tests - checkError("1-", "Invalid number: 1-", 0, 2); - checkError(" 00", "Invalid number: 00", 1, 3); - checkError("1.a", "Invalid number: 1.a", 0, 3); - checkError("1e1.5", "Invalid number: 1e1.", 0, 4); - } - - public function test_literals() { - check("true", mk(JBool(true), mkPos(file, 0, 4))); - check("false", mk(JBool(false), mkPos(file, 0, 5))); - check("null", mk(JNull, mkPos(file, 0, 4))); - - checkError("a", "Invalid character: a", 0, 1); - checkError("ta", "Invalid character: t", 0, 1); - checkError("tra", "Invalid character: t", 0, 1); - checkError("trua", "Invalid character: t", 0, 1); - // checkError("truea", "Invalid character: t", 0, 1); - checkError("fa", "Invalid character: f", 0, 1); - checkError("fala", "Invalid character: f", 0, 1); - checkError("falsa", "Invalid character: f", 0, 1); - // checkError("falsea", "Invalid character: f", 0, 1); - checkError("na", "Invalid character: n", 0, 1); - checkError("nua", "Invalid character: n", 0, 1); - checkError("nula", "Invalid character: n", 0, 1); - // checkError("nulla", "Invalid character: n", 0, 1); - } - - public function test_object() { - check("{}", mk(JObject([]), mkPos(file, 0, 2))); - - check('{ "hello" : 123,\n "world": false }', mk( - JObject([ - new JObjectField("hello", mkPos(file, 2, 9), mk(JNumber("123"), mkPos(file, 12, 15))), - new JObjectField("world", mkPos(file, 18, 25), mk(JBool(false), mkPos(file, 27, 32))), - ]), - mkPos(file, 0, 34) - )); - - checkError('{"a": 1, "a": 1}', "Duplicate field name \"a\"", 9, 12); - - checkError('{"a" }', "Invalid character: }", 5, 6); - checkError('{"a": 1,}', "Invalid character: }", 8, 9); - checkError('{:', "Invalid character: :", 1, 2); - checkError('{3', "Invalid character: 3", 1, 2); - } - - public function test_array() { - check("[]", mk(JArray([]), mkPos(file, 0, 2))); - - check(" [ 1, false\n, \"hi\" ]", mk( - JArray([ - mk(JNumber("1"), mkPos(file, 3, 4)), - mk(JBool(false), mkPos(file, 6, 11)), - mk(JString("hi"), mkPos(file, 14, 18)), - ]), - mkPos(file, 1, 20) - )); - - checkError('[1,]', "Invalid character: ]", 3, 4); - checkError('[,', "Invalid character: ,", 1, 2); - checkError('[1 2', "Invalid character: 2", 3, 4); - } - - static macro function check(source, expr) { - return macro @:pos(haxe.macro.Context.currentPos()) { - var file = "some.json"; - same(($expr : Json), Parser.parse($source, file)); - }; - } - - static function checkError(source:String, message:String, min:Int, max:Int, ?posInfos:haxe.PosInfos) { - try { - trace(Parser.parse(source, "")); - } catch (error:Error) { - equals(message, error.message, posInfos); - same(new Position("", min, max), error.pos, posInfos); - return; - } - fail("Parse Error is not raised", posInfos); - } -} diff --git a/vendor/hxjsonast/test/TestPrinter.hx b/vendor/hxjsonast/test/TestPrinter.hx deleted file mode 100644 index 488b2da..0000000 --- a/vendor/hxjsonast/test/TestPrinter.hx +++ /dev/null @@ -1,45 +0,0 @@ -import utest.Assert.*; -import hxjsonast.Printer; -import hxjsonast.Json; -import TestUtils.*; - -class TestPrinter extends TestBase { - public function test_print() { - check(mk(JNull), "null"); - check(mk(JBool(true)), "true"); - check(mk(JBool(false)), "false"); - check(mk(JNumber("123")), "123"); - check(mk(JString("hello")), "\"hello\""); - check(mk(JObject([])), "{}"); - check(mk(JArray([])), "[]"); - check(mk(JObject([ - f("hello", JNumber("16")), - f("world", JBool(false)), - ])), '{"hello":16,"world":false}'); - check(mk(JArray([ - mk(JBool(true)), - mk(JNull), - mk(JObject([])) - ])), '[true,null,{}]'); - } - - public function test_print_pretty() { - check(mk(JObject([ - f("hello", JNumber("16")), - f("world", JBool(false)), - ])), '{\n\t"hello": 16,\n\t"world": false\n}', "\t"); - check(mk(JArray([ - mk(JBool(true)), - mk(JNull), - mk(JObject([ - f("what", JArray([ - mk(JString("hi")) - ])) - ])) - ])), '[\n\ttrue,\n\tnull,\n\t{\n\t\t"what": [\n\t\t\t"hi"\n\t\t]\n\t}\n]', "\t"); - } - - static inline function check(json:Json, result:String, ?space:String) { - equals(result, Printer.print(json, space)); - } -} diff --git a/vendor/hxjsonast/test/TestTools.hx b/vendor/hxjsonast/test/TestTools.hx deleted file mode 100644 index 29297a2..0000000 --- a/vendor/hxjsonast/test/TestTools.hx +++ /dev/null @@ -1,20 +0,0 @@ -import utest.Assert.*; -import hxjsonast.Tools; -import TestUtils.*; - -class TestTools extends TestBase { - public function test_getValue() { - same({ - hello: 11, - world: ([false, "hi", 1.5, null] : Array<#if (haxe_ver < 3.3) Dynamic #else Any #end>) - }, Tools.getValue(mk(JObject([ - f('hello', JNumber("11")), - f('world', JArray([ - mk(JBool(false)), - mk(JString("hi")), - mk(JNumber("1.5")), - mk(JNull), - ])), - ])))); - } -} diff --git a/vendor/hxjsonast/test/TestUtils.hx b/vendor/hxjsonast/test/TestUtils.hx deleted file mode 100644 index 37eb6bf..0000000 --- a/vendor/hxjsonast/test/TestUtils.hx +++ /dev/null @@ -1,18 +0,0 @@ -import hxjsonast.Json; -import hxjsonast.Position; - -class TestUtils { - public static var nullPos = mkPos("", 0, 0); // positions are unused in printer - - public static inline function mkPos(file, min, max) { - return new Position(file, min, max); - } - - public static inline function mk(value:JsonValue, ?pos:Position):Json { - return new Json(value, pos == null ? nullPos : pos); - } - - public static inline function f(name:String, value:JsonValue):JObjectField { - return new JObjectField(name, nullPos, mk(value)); - } -} diff --git a/vendor/hxjsonast/tests.hxml b/vendor/hxjsonast/tests.hxml deleted file mode 100644 index b521839..0000000 --- a/vendor/hxjsonast/tests.hxml +++ /dev/null @@ -1,3 +0,0 @@ --cp test --main TestMain --lib utest diff --git a/vendor/json2object/.gitignore b/vendor/json2object/.gitignore deleted file mode 100644 index 4b783a2..0000000 --- a/vendor/json2object/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -dump/ -testout/ -.unittest diff --git a/vendor/json2object/.travis.yml b/vendor/json2object/.travis.yml deleted file mode 100644 index 8b68831..0000000 --- a/vendor/json2object/.travis.yml +++ /dev/null @@ -1,112 +0,0 @@ -language: haxe - -os: - - linux - # - osx - -haxe: - #- 3.4.1 - #- 3.4.7 - #- 4.2.0 - - development - -dist: trusty - -# thanks to Andy Li! https://github.com/andyli/HaxeCI -addons: - # This is the preferred way to install apt packages. - # However, it only allow some but not all packages. - # Alternatively, we can use `sudo apt-get install ...` in the `install:` section. - # http://docs.travis-ci.com/user/apt/#Adding-APT-Packages - apt: - packages: - - cmake - - ninja-build - # C++ (for rebuilding hxcpp) - - gcc-multilib - - g++-multilib - # Python - - python3 - # C# - - mono-devel - - mono-mcs - # Lua - - libpcre3-dev - # HL - - libpng-dev - - libjpeg-turbo8-dev - - libturbojpeg - - zlib1g-dev - - libvorbis-dev - -install: - # os-specific config - - if [ "${TRAVIS_OS_NAME}" = "linux" ]; then - phpenv global 7.0; - elif [ "${TRAVIS_OS_NAME}" = "osx" ]; then - brew update; - brew install mono; - brew upgrade python; - brew install php@7.2; - fi - # Haxe Lua dependencies - #- if [ "${TRAVIS_OS_NAME}" = "osx" ]; then - # brew install pcre; - # export PATH=$PATH:/Users/travis/Library/Python/2.7/bin; - # fi - #- pip install --user hererocks - #- export PATH=$PATH:$HOME/lua_env/bin/ - #- hererocks $HOME/lua_env/ -l5.2 -rlatest -i - #- lua -v - #- luarocks - #- export LUA_SERVER=https://luarocks.org/dev - #- luarocks install lrexlib-pcre 2.8.0-1 $LUA_SERVER - #- luarocks install luv 1.22.0-1 $LUA_SERVER - #- luarocks install luasocket 3.0rc1-2 $LUA_SERVER - #- luarocks install luautf8 0.1.1-1 $LUA_SERVER - # HL - - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then - brew install ninja; - fi - - if [ "${TRAVIS_HAXE_VERSION}" = "development" ]; then - export HL_DIR=$HOME/hashlink; - git clone https://github.com/HaxeFoundation/hashlink.git $HL_DIR; - export HL_BUILD=$HOME/hashlink_build; - mkdir $HL_BUILD; - fi - - if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "${TRAVIS_HAXE_VERSION}" = "development" ]; then - brew bundle --file=$HL_DIR/Brewfile; - fi - - if [ "${TRAVIS_HAXE_VERSION}" = "development" ]; then - cmake -GNinja -DBUILD_TESTING=OFF -DWITH_BULLET=OFF -DWITH_DIRECTX=OFF -DWITH_FMT=ON -DWITH_OPENAL=OFF -DWITH_SDL=OFF -DWITH_SQLITE=OFF -DWITH_SSL=OFF -DWITH_UI=OFF -DWITH_UV=OFF -DWITH_VIDEO=OFF -B$HL_BUILD -H$HL_DIR; - cmake --build $HL_BUILD; - export PATH=$PATH:$HL_BUILD/bin/; - hl --version; - else - export PATH=$PATH:$HOME; - ln -s /bin/echo $HOME/hl; - fi - # Install haxelibs - - if [ "${TRAVIS_HAXE_VERSION}" = "development" ]; then - haxelib git utest https://github.com/haxe-utest/utest.git; - git clone https://github.com/HaxeFoundation/hxcpp.git; - haxelib dev hxcpp hxcpp; - pushd $(haxelib path hxcpp | head -1); - pushd tools/hxcpp; haxe compile.hxml; popd; - pushd project; neko build.n; haxe compile-cppia.hxml; popd; - popd; - else - haxelib install utest; - haxelib install hxcpp; - fi - - haxelib install hxjava - - haxelib install hxcs - - haxelib install hxjsonast # dep for json2object - - haxelib list - -script: - - haxe tests/build/build_all.hxml - - if [ "${TRAVIS_HAXE_VERSION}" = "4.2.0" ] || [ "${TRAVIS_HAXE_VERSION}" = "development" ]; then - haxe tests/build/build_jvm.hxml; - haxe tests/build/build_cppia.hxml; - fi diff --git a/vendor/json2object/README.md b/vendor/json2object/README.md index 2920356..8b0591e 100644 --- a/vendor/json2object/README.md +++ b/vendor/json2object/README.md @@ -1,6 +1,6 @@ # json2object - Type safe Haxe/JSON (de)serializer -[![Build Status](https://travis-ci.org/elnabo/json2object.svg?branch=master)](https://travis-ci.org/elnabo/json2object) +[![CI status](https://github.com/elnabo/json2object/actions/workflows/main.yaml/badge.svg)](https://github.com/elnabo/json2object/actions/workflows/main.yaml) This library uses macro and a typed position aware JSON parsing (hxjsonast : ) to create json parser and writer from and to every supported type. diff --git a/vendor/json2object/haxelib.json b/vendor/json2object/haxelib.json index d913373..e0122a3 100644 --- a/vendor/json2object/haxelib.json +++ b/vendor/json2object/haxelib.json @@ -4,8 +4,8 @@ "license": "MIT", "tags": ["json", "cross", "macro"], "description": "Type safe Haxe/JSON (de)serializer", - "version": "3.9.0", - "releasenote": "Support for Haxe 4.2", + "version": "3.11.0", + "releasenote": "Prevent compilation server cache issues", "contributors": ["elnabo", "_ibilon"], "classPath": "src", "dependencies": { diff --git a/vendor/json2object/patched_utest/utest/utils/AsyncUtils.hx b/vendor/json2object/patched_utest/utest/utils/AsyncUtils.hx deleted file mode 100644 index 804e8c9..0000000 --- a/vendor/json2object/patched_utest/utest/utils/AsyncUtils.hx +++ /dev/null @@ -1,10 +0,0 @@ -package utest.utils; - -/** -Shadow version to avoid issue with variable named async which is a keyword on python 3.5+ but not escaped in haxe 3. -**/ -class AsyncUtils { - static public inline function orResolved(_async:Null):Async { - return _async == null ? Async.getResolved() : _async; - } -} diff --git a/vendor/json2object/src/json2object/reader/DataBuilder.hx b/vendor/json2object/src/json2object/reader/DataBuilder.hx index 7fa970e..7860aac 100644 --- a/vendor/json2object/src/json2object/reader/DataBuilder.hx +++ b/vendor/json2object/src/json2object/reader/DataBuilder.hx @@ -40,9 +40,10 @@ typedef ParserInfo = {packs:Array, clsName:String} class DataBuilder { + @:persistent private static var counter = 0; private static var parsers = new Map(); - private static var callPosition:Null = null; + private static var callPosition:Null = null; private static var jcustom = ":jcustomparse"; private static function notNull(type:Type):Type { @@ -162,6 +163,30 @@ class DataBuilder { changeFunction("loadJsonNull", parser, macro {value = null;}); } + public static function makeListParser(parser:TypeDefinition, subType:Type, baseParser:BaseType) { + var cls = { name:baseParser.name, pack:baseParser.pack, params:[TPType(subType.toComplexType())]}; + var list = {name:"List", pack:[#if (haxe_ver >= 4)"haxe", "ds"#end], params:[TPType(subType.toComplexType())]}; + + var e = macro value = { + var parser = new $cls(errors, putils, THROW); + var res = new $list(); + for (j in a) { + try { + res.add(parser.loadJson(j, variable)); + } + catch (e:json2object.Error.InternalError) { + if (e != ParsingThrow) { + throw e; + } + } + } + res; + } + + changeFunction("loadJsonArray", parser, e); + changeFunction("loadJsonNull", parser, macro {value = null;}); + } + public static function makeCustomParser(parser:TypeDefinition, type:Type, t:ClassType){ var cexpr:Expr; try { @@ -371,7 +396,7 @@ class DataBuilder { } if (caseValue == null) { - caseValue = { expr: EConst(CString(${field.name})), pos: Context.currentPos()}; + caseValue = { expr: EConst(CString(field.name)), pos: Context.currentPos()}; } cases.push({ expr: assignation, guard: null, values: [caseValue] }); @@ -393,7 +418,7 @@ class DataBuilder { else { var e = switch(field.type) { case TAbstract(_.get() => t, _) if (t.name == "Any"): macro null; - case TDynamic(_): macro null; + case TLazy(_) | TDynamic(_): macro null; default: macro new $f_cls([], putils, NONE).loadJson({value:JNull, pos:{file:"",min:0, max:1}}); } baseValues.push({field:field.name, expr:e #if (haxe_ver >= 4) , quotes:Unquoted #end}); @@ -587,7 +612,7 @@ class DataBuilder { blockExpr.push(macro value = cast ${subExpr}); var lil_expr:Expr = {expr: EBlock(blockExpr), pos:Context.currentPos()}; - internObjectCases.push({ expr: lil_expr, guard: null, values: [{ expr: EConst(CString($v{n})), pos: Context.currentPos()}] }); + internObjectCases.push({ expr: lil_expr, guard: null, values: [{ expr: EConst(CString(n)), pos: Context.currentPos()}] }); default: @@ -726,16 +751,16 @@ class DataBuilder { switch (type) { case TAbstract(_.get()=>t, p): - var from = (t.from.length == 0) ? [{t:t.type, field:null}] : t.from; var i = 0; for(fromType in from) { - switch (fromType.t.followWithAbstracts()) { + var fromTypeT = fromType.t.applyTypeParameters(t.params, p); + switch (fromTypeT.followWithAbstracts()) { case TInst(_.get()=>st, sp): if (st.module == "String") { if (i == 0) { makeStringParser(parser); } else { - var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromType.t.toComplexType())]}; + var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromTypeT.toComplexType())]}; changeFunction("loadJsonString", parser, macro { @@ -761,7 +786,7 @@ class DataBuilder { makeArrayParser(parser,subType.followWithAbstracts(), baseParser); } else if (isBaseType(subType.followWithAbstracts())) { - var aParams = switch (fromType.t.followWithAbstracts()) { + var aParams = switch (fromTypeT.followWithAbstracts()) { case TInst(r,_): [TPType(TInst(r,[subType]).toComplexType())]; default:[]; } @@ -781,7 +806,7 @@ class DataBuilder { } else { if (i == 0) { - var t = fromType.t; + var t = fromTypeT; if (st.isPrivate) { var privateType = TypeUtils.copyType(st); t = Context.getType(privateType.name); @@ -819,12 +844,12 @@ class DataBuilder { } case TAbstract(_.get()=>st, sp): if (st.module == "StdTypes") { - var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromType.t.toComplexType())]}; + var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromTypeT.toComplexType())]}; switch (st.name) { case "Int": if (!hasFromFloat) { if (i == 0) { - makeIntParser(parser, fromType.t); + makeIntParser(parser, fromTypeT); } else { changeFunction("loadJsonNumber", @@ -839,7 +864,7 @@ class DataBuilder { } case "Float": if (i == 0) { - makeFloatParser(parser, fromType.t); + makeFloatParser(parser, fromTypeT); } else { changeFunction("loadJsonNumber", @@ -854,7 +879,7 @@ class DataBuilder { hasOneFrom = true; case "Bool": if (i == 0) { - makeBoolParser(parser, fromType.t); + makeBoolParser(parser, fromTypeT); } else { changeFunction("loadJsonBool", @@ -884,7 +909,7 @@ class DataBuilder { } case TAnonymous(_.get()=>st): if (i == 0) { - var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromType.t.toComplexType())]}; + var cls = {name:baseParser.name, pack:baseParser.pack, params:[TPType(fromTypeT.toComplexType())]}; changeFunction("loadJsonObject", parser, macro { value = cast new $cls(errors, putils, NONE).loadJson( {value:JObject(o), pos:putils.revert(pos)}, @@ -909,7 +934,6 @@ class DataBuilder { } public static function makeParser(c:BaseType, type:Type, ?base:Type=null) { - if (base == null) { base = type; } var parserMapName = base.toString(); @@ -986,6 +1010,8 @@ class DataBuilder { makeStringParser(parser); case "Array" if (p.length == 1 && p[0] != null): makeArrayParser(parser, p[0], c); + case "List" | "haxe.ds.List" if (p.length == 1 && p[0] != null): + makeListParser(parser, p[0], c); case _: switch (t.kind) { case KTypeParameter(_): @@ -1029,6 +1055,9 @@ class DataBuilder { if (t.meta.has(":enum")) { makeAbstractEnumParser(parser, type.applyTypeParameters(t.params, p), c); } + else if (t.meta.has(":coreType")) { + Context.fatalError("json2object: Parser of coreType ("+t.name+") are not generated", Context.currentPos()); + } else { makeAbstractParser(parser, type.applyTypeParameters(t.params, p), c); } diff --git a/vendor/json2object/src/json2object/utils/schema/DataBuilder.hx b/vendor/json2object/src/json2object/utils/schema/DataBuilder.hx index 3433486..f7b1541 100644 --- a/vendor/json2object/src/json2object/utils/schema/DataBuilder.hx +++ b/vendor/json2object/src/json2object/utils/schema/DataBuilder.hx @@ -318,7 +318,7 @@ class DataBuilder { switch (t.module) { case "String": return JTSimple("string"); - case "Array" if (p.length == 1 && p[0] != null): + case "Array" | "List" | "haxe.ds.List" if (p.length == 1 && p[0] != null): return JTArray(makeSchema(p[0], definitions)); default: makeObjectSchema(type, name, definitions); @@ -353,7 +353,7 @@ class DataBuilder { makeEnumSchema(type.applyTypeParameters(t.params, p), definitions); case TType(_.get()=>t, p): var _tmp = makeSchema(t.type.applyTypeParameters(t.params, p), definitions, name); - if (t.name != "Null") { + if (t.name != "Null" && t.name != "List") { if (t.doc != null) { define(name, describe(definitions.get(name), t.doc), definitions); } diff --git a/vendor/json2object/src/json2object/writer/DataBuilder.hx b/vendor/json2object/src/json2object/writer/DataBuilder.hx index 43a81c0..4016a79 100644 --- a/vendor/json2object/src/json2object/writer/DataBuilder.hx +++ b/vendor/json2object/src/json2object/writer/DataBuilder.hx @@ -35,7 +35,7 @@ using haxe.macro.ExprTools; using json2object.utils.TypeTools; class DataBuilder { - + @:persistent private static var counter = 0; private static var writers = new Map(); private static var jcustom = ":jcustomwrite"; @@ -210,11 +210,22 @@ class DataBuilder { } assignations.push(assignation); - skips.push( - field.meta.has(':optional') - ? macro $f_a == null - : macro false - ); + if (field.meta.has(':optional')) { + switch (field.type) { + case TAbstract(t, params): + if (t.toString() == "Null") { + // Null + skips.push(macro $f_a == null); + } else { + // Bool + skips.push(macro false); + } + default: + skips.push(macro $f_a == null); + } + } else { + skips.push(macro false); + } default: } @@ -409,7 +420,7 @@ class DataBuilder { switch(t.module) { case "String": makeStringWriter(); - case "Array": + case "Array" | "List" | "haxe.ds.List": if (p.length == 1 && p[0] != null) { makeArrayWriter(p[0], c); } @@ -456,6 +467,9 @@ class DataBuilder { if (t.meta.has(":enum")) { makeAbstractEnumWriter(type.applyTypeParameters(t.params, p)); } + else if (t.meta.has(":coreType")) { + Context.fatalError("json2object: Parser of coreType ("+t.name+") are not generated", Context.currentPos()); + } else { var ap = t.type.applyTypeParameters(t.params, p); return makeWriter(c, ap, ap); diff --git a/vendor/json2object/test.hxml b/vendor/json2object/test.hxml deleted file mode 100644 index 2665d54..0000000 --- a/vendor/json2object/test.hxml +++ /dev/null @@ -1 +0,0 @@ -tests/build/build_interp.hxml diff --git a/vendor/json2object/tests/AbstractTest.hx b/vendor/json2object/tests/AbstractTest.hx deleted file mode 100644 index f4e306d..0000000 --- a/vendor/json2object/tests/AbstractTest.hx +++ /dev/null @@ -1,311 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import utest.Assert; - -abstract Username (String) from String to String -{ - public function get_id () return this.toLowerCase(); -} - -@:forward(length) -abstract Rights (Array) to Array -{ -} - -@:forward(length) -abstract Templated (Array) to Array -{ -} - -typedef B = { - t : Templated> -} - - -typedef AbstractStruct = { - @:optional @:default([]) - var a:ReadonlyArray; -} - -@:forward(length, toString) -abstract ReadonlyArray(Array) from Array {} - -@:enum -abstract EnumAbstractInt(Int) { - var A = 1; - var B = 2; - var Z = 26; -} - -typedef EnumAbstractIntStruct = { - val:EnumAbstractInt -} - -@:enum -abstract EnumAbstractString(Null) { - var SA = "Z"; - var SB = "Y"; - var SZ = "A"; -} - -typedef EnumAbstractStringStruct = { - @optional var val:EnumAbstractString; -} - -@:enum -abstract TernaryValue(Null) { - var BA = true; - var BB = false; - var BC = null; -} - -typedef TernaryStruct = { - var val:TernaryValue; -} - -@:enum -abstract FloatValue(Float) { - var PI = 3.14; - var ZERO = 0.0; -} - -typedef FloatStruct = { - var val:FloatValue; -} - -abstract MultiFrom (String) from String to String -{ - inline function new(i:String) { - this = i; - } - - @:from - static public function fromInt(s:Int) { - return new MultiFrom(Std.string(s)); - } - -} - -abstract OnClass (OnClassData) -{ -} - -class OnClassData -{ - public var x:Int; -} - -class AbstractTest implements utest.ITest -{ - public function new () {} - - public function test1 () - { - var parser = new JsonParser<{ username:Username }>(); - var writer = new JsonWriter<{ username:Username }>(); - var data = parser.fromJson('{ "username": "Administrator" }', "test"); - Assert.equals("Administrator", data.username); - Assert.equals("administrator", data.username.get_id()); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test2 () - { - var parser = new JsonParser<{ rights:Rights }>(); - var writer = new JsonWriter<{ rights:Rights }>(); - var data = parser.fromJson('{ "rights": ["Full", "Write", "Read", "None"] }', "test"); - Assert.equals(4, data.rights.length); - Assert.equals("Write", data.rights[1]); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test3 () - { - var parser = new JsonParser<{ t:Templated }>(); - var writer = new JsonWriter<{ t:Templated }>(); - var data = parser.fromJson('{ "t": [2, 1, 0] }', "test"); - Assert.equals(3, data.t.length); - Assert.equals(0, data.t[2]); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test4 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "t": [[0,1], [1,0]] }', "test"); - Assert.equals(2, data.t.length); - Assert.equals(2, data.t[1].length); - Assert.equals(1, data.t[0][1]); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test5 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{}', 'test'); - Assert.equals(0, data.a.length); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"a":[1,1,2,3]}', 'test'); - Assert.same([1,1,2,3], data.a); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test6 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('"test"', 'test'); - Assert.equals("test", data); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - var data = parser.fromJson('555', 'test'); - Assert.equals("555", data); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test7 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"val":1}',''); - Assert.equals(A, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":26}',''); - Assert.equals(Z, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":16}',''); - Assert.equals(A, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":26.2}',''); - Assert.equals(A, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test8 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"val":"Z"}',''); - Assert.equals(SA, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":"A"}',''); - Assert.equals(SZ, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":"B"}',''); - Assert.equals(SA, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":26.2}',''); - Assert.equals(SA, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test9 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"val":true}',''); - Assert.equals(BA, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":null}',''); - Assert.equals(BC, data.val); - Assert.equals(0, parser.errors.length); - data = parser.fromJson('{"val":"B"}',''); - Assert.equals(BA, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test10 () - { - var parser = new json2object.JsonParser(); - var writer = new json2object.JsonWriter(); - var data = parser.fromJson('{"val":3.14}',''); - Assert.equals(PI, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":0.0}',''); - Assert.equals(ZERO, data.val); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"val":1}',''); - Assert.equals(PI, data.val); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test11 () - { - var parser = new json2object.JsonParser(); - parser.fromJson('{"x":1}', ""); - Assert.isTrue(true); // Just check that it compiles - } - - #if !(cs || java || hl) - public function test12 () - { - var parser = new json2object.JsonParser(); - var data = parser.fromJson('{"hello":"world"}', ""); - Assert.same(data.hello, "world"); - - //var writer = new json2object.JsonWriter(); - //Assert.same(data, parser.fromJson(writer.write(data), "")); - } - #end - - #if !lua - public function test13 () { - var schema = new json2object.utils.JsonSchemaWriter().schema; - var oracle = '{"$$schema": "http://json-schema.org/draft-07/schema#","$$ref": "#/definitions/tests.TernaryValue","definitions": {"tests.TernaryValue": {"anyOf": [{"const": true},{"const": false},{"const": null}]}}}'; - Assert.isTrue(JsonComparator.areSame(oracle, schema)); - } - #end -} diff --git a/vendor/json2object/tests/AliasTest.hx b/vendor/json2object/tests/AliasTest.hx deleted file mode 100644 index d453850..0000000 --- a/vendor/json2object/tests/AliasTest.hx +++ /dev/null @@ -1,84 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import utest.Assert; - -typedef Aliased = { - @:alias("public") var isPublic : Bool; -} - -typedef MultiAliased = { - @:alias("first") @:alias("public") var isPublic : Bool; -} - -class AliasedClass { - @:alias("public") public var isPublic : Bool; -} - -class MultiAliasedClass { - @:alias("first") @:alias("public") public var isPublic : Bool; -} - -class AliasTest implements utest.ITest -{ - public function new () {} - - public function test1 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "public": true }', "test"); - Assert.isTrue(data.isPublic); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test2 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "public": true }', "test"); - Assert.isTrue(data.isPublic); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test3 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "public": true }', "test"); - Assert.isTrue(data.isPublic); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test4 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "public": true }', "test"); - Assert.isTrue(data.isPublic); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } -} diff --git a/vendor/json2object/tests/ArrayTest.hx b/vendor/json2object/tests/ArrayTest.hx deleted file mode 100644 index 102db7e..0000000 --- a/vendor/json2object/tests/ArrayTest.hx +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -class ArrayTest implements utest.ITest { - public function new () {} - - public function test1 () { - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data = parser.fromJson('[0,1,4,3]', ""); - var oracle = [0,1,4,3]; - for (i in 0...data.length) { - Assert.equals(oracle[i], data[i]); - } - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('[0,1,4.4,3]', ""); - Assert.equals(1, parser.errors.length); - oracle = [0,1,3]; - for (i in 0...data.length) { - Assert.equals(oracle[i], data[i]); - } - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - #if !lua - public function test2 () { - var schema = new JsonSchemaWriter>().schema; - var oracle = '{"$$schema": "http://json-schema.org/draft-07/schema#","items": {"type": "integer"},"type": "array"}'; - Assert.isTrue(JsonComparator.areSame(oracle, schema)); - } - #end -} diff --git a/vendor/json2object/tests/CustomTest.hx b/vendor/json2object/tests/CustomTest.hx deleted file mode 100644 index 14c8822..0000000 --- a/vendor/json2object/tests/CustomTest.hx +++ /dev/null @@ -1,171 +0,0 @@ -/* - Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - - 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. - */ - -package tests; - -import hxjsonast.Printer; -import haxe.Json; -import json2object.JsonParser; -import json2object.JsonWriter; -import utest.Assert; - -class CustomNum { - @:jcustomwrite(tests.CustomTest.CustomNum.CustomWriteInt) - @:jcustomparse(tests.CustomTest.CustomNum.CustomParseInt) - public var value:Int; - - @:jcustomwrite(tests.CustomTest.CustomNum.CustomWriteString) - @:jcustomparse(tests.CustomTest.CustomNum.CustomParseString) - @:optional - @:default("0") - public var opt_value:String; - - public var control:Int; - - public static var _prefix = "The Number "; - - public static function CustomWriteInt(o:Int):String { - return '"$_prefix$o"'; - } - - public static function CustomWriteString(o:String):String { - return '$o'; - } - - public static function CustomParseInt(val:hxjsonast.Json, name:String):Int { - switch (val.value) { - case JString(s): - var str = StringTools.replace(s, _prefix, ""); - return Std.parseInt(str); - default: - throw 'Unexpected value for $name'; - } - } - - public static function CustomParseString(val:hxjsonast.Json, name:String):String { - switch (val.value) { - case JNumber(s): - return s; - default: - throw 'Unexpected value for $name'; - } - } -} - -@:jcustomparse(tests.CustomTest.WrappedDynamic.CustomParse) -@:jcustomwrite(tests.CustomTest.WrappedDynamic.CustomWrite) -class WrappedDynamic { - @:jignored - public var value:Dynamic; - - public function new() {} - - public static function CustomWrite(o:WrappedDynamic):String { - return '${Json.stringify(o.value)}'; - } - - public static function CustomParse(val:hxjsonast.Json, name:String):WrappedDynamic { - var str = Printer.print(val); - var w = new WrappedDynamic(); - w.value = Json.parse(str); - return w; - } -} - -class NestedTest { - public var num:CustomNum; - public var dyn:WrappedDynamic; - - public function new() {} -} - -class CustomTest implements utest.ITest { - public function new() {} - - public function test1() { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value": "The Number 42", "control":123}'); - Assert.equals(0, parser.errors.length); - Assert.equals(42, data.value); - Assert.equals("0", data.opt_value); - Assert.equals(123, data.control); - Assert.same(data, parser.fromJson(writer.write(data))); - } - - public function test2() { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"foo": 1, "bar":"two"}'); - Assert.equals(0, parser.errors.length); - Assert.equals(1, data.value.foo); - Assert.equals("two", data.value.bar); - Assert.same(data, parser.fromJson(writer.write(data))); - } - - public function test3() { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"dyn":{"foo": 1, "bar":"two"}, "num":{"value": "The Number 42", "control":123}}'); - Assert.equals(0, parser.errors.length); - Assert.equals(1, data.dyn.value.foo); - Assert.equals(42, data.num.value); - Assert.same(data, parser.fromJson(writer.write(data))); - } - - public function test4() { - var parser = new JsonParser(); - var data = parser.fromJson('{"value": 1, "control":123}'); - Assert.equals(2, parser.errors.length); - Assert.equals(0, data.value); - Assert.equals("0", data.opt_value); - Assert.equals(123, data.control); - } - - public function test5() { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value": "The Number 62", "opt_value": 71, "control": 12}'); - Assert.equals(0, parser.errors.length); - Assert.equals(62, data.value); - Assert.equals("71", data.opt_value); - Assert.equals(12, data.control); - Assert.same(data, parser.fromJson(writer.write(data))); - } - - public function test6() { - var parser = new JsonParser(); - var data = parser.fromJson('{"value": "The Number 62", "opt_value": "4564", "control": 12}'); - Assert.equals(1, parser.errors.length); - - switch (parser.errors[0]) { - case CustomFunctionException(e, _): - Assert.equals(e, "Unexpected value for opt_value"); - default: - Assert.isTrue(false); - } - - Assert.equals(62, data.value); - Assert.equals("0", data.opt_value); - Assert.equals(12, data.control); - } -} diff --git a/vendor/json2object/tests/EnumTest.hx b/vendor/json2object/tests/EnumTest.hx deleted file mode 100644 index b870bc4..0000000 --- a/vendor/json2object/tests/EnumTest.hx +++ /dev/null @@ -1,234 +0,0 @@ -/* -Copyright (c) 2017-2019 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.Error; -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -enum Color { - Green; - Red; - RGBA(r:Int, g:Int, b:Int, a:Float); - None(r:{a:Int}); -} - -enum WithParam { - First(a:T1); - Second(a:T2); - Both(a:T1, b:T2); -} - -typedef EnumStruct = { - var value : Color; -} - -typedef ArrayEnumStruct = { - var value : Array; -} - -typedef WithParamStruct = { - var value : WithParam; -} - -enum Enum1 { - EnumValue1(value:String); - EnumValue2(errors:String); - EnumValue3(putils:String); -} - -typedef WithDefault = { - @:default(Green) @:optional var value : Color; -} - -typedef WithDefaultOther = { - @:default(VAL1) @:optional var value : tests.OtherEnum.TestEnum; -} - -class EnumTest implements utest.ITest -{ - public function new () {} - - public function test1 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":"Red"}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.equals(Red, data.value); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":"RGBA"}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.isNull(data.value); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test2 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"Red":{}}}', "test.json"); - Assert.equals(Red, data.value); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"RGBA":{"r":25, "g":30, "b":255, "a":0.5}}}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(Type.enumEq(RGBA(25,30,255,0.5),data.value)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test3 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"Red":{"a":0.5}}}', "test.json"); - Assert.isNull(data.value); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test4 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"None":{"a":0.5}}}', "test.json"); - Assert.isNull(data.value); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test5 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"None":{"r":{"a":25}}}}', "test.json"); - Assert.equals(0, parser.errors.length); - switch (data.value) { - case None(r): - Assert.equals(25, r.a); - default: - Assert.equals(None({a:25}), data.value); - } - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test6 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":["Red", "Green", "Yellow", {"Red":{}}, {"RGBA":{"r":1, "g":1, "b":0}}, {"RGBA":{"r":1, "g":1, "b":0, "a":0.2}}]}', ""); - Assert.equals(4, data.value.length); - Assert.equals(-1, data.value.indexOf(null)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - public function test7 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"First":{"a":"a"}}}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(Type.enumEq(First("a"),data.value)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"Second":{"a":1}}}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(Type.enumEq(Second(1),data.value)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"Both":{"a":"a","b":1}}}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(Type.enumEq(Both("a",1),data.value)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"Both":{"b":1,"a":"a"}}}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(Type.enumEq(Both("a",1),data.value)); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"Second":{"b":1}}}', "test.json"); - Assert.same(InvalidEnumConstructor("Second", "WithParam", {file:"test.json", lines:[{number:1, start:10, end:28}], min:10, max:28}), parser.errors[0]); - Assert.same(UninitializedVariable("value", {file:"test.json", lines:[{number:1, start:29, end:29}], min:29, max:29}), parser.errors[1]); - Assert.equals(2, parser.errors.length); - } - - public function test8 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"value":{"First":{"a":1}}}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.isNull(data.value); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - - data = parser.fromJson('{"value":{"Second":{"b":"1"}}}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.isNull(data.value); - Assert.same(data, parser.fromJson(writer.write(data),"test")); - } - - /** Issue 32 */ - public function test9 () - { - var writer = new JsonWriter(); - var json:String = writer.write(EnumValue1("test")); - Assert.equals(json,'{"EnumValue1": {"value": "test"}}'); - - var parser = new JsonParser(); - parser.fromJson(json, ''); - Assert.same(parser.errors, []); - Assert.same(parser.value, EnumValue1("test")); - - var parser = new JsonParser(); - parser.fromJson('{"EnumValue2": {"errors": "test"}}', ''); - Assert.same(parser.errors, []); - Assert.same(parser.value, EnumValue2("test")); - - var parser = new JsonParser(); - parser.fromJson('{"EnumValue3": {"putils": "test"}}', ''); - Assert.same(parser.errors, []); - Assert.same(parser.value, EnumValue3("test")); - } - - /** Issue 34 **/ - public function test10 () - { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.same(data.value, Color.Green); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.same(data.value, tests.OtherEnum.TestEnum.VAL1); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } -} diff --git a/vendor/json2object/tests/FinalTest.hx b/vendor/json2object/tests/FinalTest.hx deleted file mode 100644 index 9e9d3b6..0000000 --- a/vendor/json2object/tests/FinalTest.hx +++ /dev/null @@ -1,53 +0,0 @@ -/* -Copyright (c) 2017-2019 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.Error; -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -typedef Data = { - final foo:String; - final bar:{ - final foobar:String; - } -} - -class FinalTest implements utest.ITest -{ - public function new () {} - - public function test1 () - { - var parser = new JsonParser(); - var writer = new JsonParser(); - var schema = new JsonSchemaWriter(); - - var data = parser.fromJson('{}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.equals(null, data.foo); - Assert.equals(null, data.bar); - } -} diff --git a/vendor/json2object/tests/GetSetTest.hx b/vendor/json2object/tests/GetSetTest.hx deleted file mode 100644 index e4fd56f..0000000 --- a/vendor/json2object/tests/GetSetTest.hx +++ /dev/null @@ -1,116 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.Error; -import json2object.JsonParser; -import json2object.JsonWriter; -import utest.Assert; - -class GetSetTest implements utest.ITest { - - var h : Int = 1; - public var i(get,set) : Int; - function get_i () : Int { - return h * 2; - } - function set_i (v:Int) : Int { - return h = v; - } - - @:isVar var j (get, set) : Float; - function get_j () : Float { - return j * 50; - } - function set_j (j:Float) : Float { - return this.j = j; - } - - var k (get, set) : Int; - function get_k () : Int { - return Std.int(j); - } - function set_k (v:Int) : Int { - j = v; - return v; - } - - var l (default, default) : Int = 1; - var m (default, never) : Int = 2; - var n (default, null) : Int = 3; - var o (default, set) : Int; - function set_o (v:Int) { - return this.o = v * 2; - } - - var q (null, default) : Int = 5; - var s (null, null) : Int = 7; - var t (get, null) : Int = 8; - function get_t () :Int { return 1; } - - var u (null, never) : Int; - var v (null, set) : Int; - function set_v (v:Int) : Int { - return this.v = v; - } - - public function new () {} - - public function test1 () { - var gst = new GetSetTest(); - gst.j = Math.PI; - gst.o = 2; - Reflect.setField(gst, "u", 2); - gst.v = 9; - - var json = '{"h":1,"j":3.14159265358979,"l":1,"m":2,"n":3,"o":4,"q":5,"s":7,"t":8,"u":2,"v":9}'; - - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson(json, "test"); - Assert.same(gst, data); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test2 () { - var gst = new GetSetTest(); - gst.k = 4; - gst.l = 3; - Reflect.setField(gst, "m", 4); - gst.n = 5; - gst.o = 2; - Reflect.setField(gst, "u", 23); - gst.v = 9; - - var json = '{"j":4.0, "h":1, "k":3, "l":3, "m":4, "n":5, "o":4, "q":5, "s":7, "t":8, "u":23, "v":9}'; - - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson(json, "test"); - Assert.same(gst, data); - Assert.same(UnknownVariable("k", {file:"test", lines:[{number:1, start:18, end:21}], min:18, max:21}), parser.errors[0]); - Assert.equals(1, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } -} diff --git a/vendor/json2object/tests/InheritanceTest.hx b/vendor/json2object/tests/InheritanceTest.hx deleted file mode 100644 index b1bb586..0000000 --- a/vendor/json2object/tests/InheritanceTest.hx +++ /dev/null @@ -1,88 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -class Parent { - public var a : Int; -} - -class Child extends Parent { - public var b : String; -} - -class OtherChild extends Parent { - public var b : Bool; -} - -class InheritanceTest implements utest.ITest { - public function new () {} - - public function test1 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"a": 7}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.equals(7, data.a); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test2 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"a": 7, "b": "hello"}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.equals(7, data.a); - Assert.equals("hello", data.b); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test3 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"a": 7, "b": true}', "test.json"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(data.b); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test4 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"a": 7, "b": true}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test5 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"a": 7, "b": "hello"}', "test.json"); - Assert.equals(2, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } -} diff --git a/vendor/json2object/tests/JsonComparator.hx b/vendor/json2object/tests/JsonComparator.hx deleted file mode 100644 index 07a4f10..0000000 --- a/vendor/json2object/tests/JsonComparator.hx +++ /dev/null @@ -1,143 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -using StringTools; - -class JsonComparator { - - static function splitArray(arr:String) : Array { - var result = []; - arr = arr.substr(1); - var length = arr.length; - - var inObjDepth = 0; - var inArrayDepth = 0; - - var i = 0; - while (i < length) { - var next = i; - while (next < length) { - var c = arr.charAt(next); - switch (c) { - case '[': inArrayDepth++; - case ']': inArrayDepth--; - case '{': inObjDepth++; - case '}': inObjDepth--; - case ',' if (inObjDepth == 0 && inArrayDepth == 0): break; - } - next++; - } - result.push(arr.substring(i, next)); - i = next + 1; - } - return result; - } - - static function splitObject (obj:String) : Map { - var result = new Map(); - obj = obj.substr(1); - var length = obj.length; - var key = ''; - - var inObjDepth = 0; - var inArrayDepth = 0; - - var valueStart = 0; - - var i = 0; - while (i < length) { - var next = obj.indexOf(':', i); - key = obj.substr(i, next).trim(); - - next++; - var valueStart = next; - - while (next < length) { - var c = obj.charAt(next); - switch (c) { - case '[': inArrayDepth++; - case ']': inArrayDepth--; - case '{': inObjDepth++; - case '}': inObjDepth--; - case ',' if (inObjDepth == 0 && inArrayDepth == 0): break; - } - next++; - } - result.set(key, obj.substring(valueStart, next)); - i = next + 1; - } - return result; - } - - public static function areSame (a:String, b:String) : Bool { - if (a == b) { - return true; - } - - var length = a.length; - if (b.length != length) { - return false; - } - - var firstA = a.charAt(0); - var firstB = b.charAt(0); - - if (firstA == '{' && firstB == '{') { - var propsA = splitObject(a); - var propsB = splitObject(a); - - for (key in propsA.keys()) { - if (!propsB.exists(key)) { - return false; - } - if (!areSame(propsA.get(key), propsB.get(key))) { - return false; - } - } - - return true; - } - - if (firstA == '[' && firstB == '[') { - var valuesA = splitArray(a); - var valuesB = splitArray(b); - - for (s1 in valuesA) { - var found = false; - for (s2 in valuesB) { - if (areSame(s1, s2)) { - found = true; - break; - } - } - if (!found) { - return false; - } - } - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/vendor/json2object/tests/Main.hx b/vendor/json2object/tests/Main.hx deleted file mode 100644 index 37444bf..0000000 --- a/vendor/json2object/tests/Main.hx +++ /dev/null @@ -1,83 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -class Main -{ - public static function main () - { - printTarget(); - - var allOk = true; - var r = new utest.Runner(); - - r.addCase(new AbstractTest()); - r.addCase(new AliasTest()); - r.addCase(new ArrayTest()); - r.addCase(new CustomTest()); - r.addCase(new EnumTest()); - #if haxe4 - r.addCase(new FinalTest()); - #end - r.addCase(new GetSetTest()); - r.addCase(new InheritanceTest()); - r.addCase(new MapTest()); - r.addCase(new ObjectTest()); - r.addCase(new StructureTest()); - r.addCase(new UIntTest()); - - utest.ui.Report.create(r, NeverShowSuccessResults, AlwaysShowHeader); - r.run(); - } - - static function printTarget() - { - #if (cpp && !cppia) - trace("cpp"); - #elseif cppia - trace("cppia"); - #elseif cs - trace("cs"); - #elseif flash - trace("flash"); - #elseif hl - trace("hl"); - #elseif interp - trace("interp"); - #elseif java - trace("java"); - #elseif js - trace("js"); - #elseif lua - trace("lua"); - #elseif neko - trace("neko"); - #elseif php - trace("php"); - #elseif python - trace("python"); - #else - trace("unknown"); - #end - } -} diff --git a/vendor/json2object/tests/MapTest.hx b/vendor/json2object/tests/MapTest.hx deleted file mode 100644 index fd74843..0000000 --- a/vendor/json2object/tests/MapTest.hx +++ /dev/null @@ -1,94 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -typedef MapStruct = { - var i : Int; -} - -class MapTest implements utest.ITest { - public function new () {} - - public function test1 () { // Str -> Str - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data = parser.fromJson('{ "key1": "value1", "key2": "value2" }', "test"); - Assert.equals("value1", data.get("key1")); - Assert.equals("value2", data.get("key2")); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test2 () { // Int -> Str - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data = parser.fromJson('{ "1": "value1", "2": "value2" }', "test"); - Assert.equals("value1", data.get(1)); - Assert.equals("value2", data.get(2)); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test3 () { // Str -> Object/Struct - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data = parser.fromJson('{ "key1": null, "key2": {"i":9}, "key3":{"i":0} }', "test"); - Assert.isNull(data.get("key1")); - Assert.equals(9, data.get("key2").i); - Assert.equals(0, data.get("key3").i); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test4 () { // Str -> Map - var parser = new JsonParser>>(); - var writer = new JsonWriter>>(); - var data = parser.fromJson('{ "key1": {}, "key2": {"i":"9"}, "key3":{"a":"0"} }', "test"); - Assert.same(new Map(), data.get("key1")); - Assert.equals("9", data.get("key2").get("i")); - Assert.equals("0", data.get("key3").get("a")); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test5 () { // Str -> Array - var parser = new JsonParser>>(); - var writer = new JsonWriter>>(); - var data = parser.fromJson('{ "key1": [], "key2": ["i","9"], "key3":["a"] }', "test"); - Assert.same([], data.get("key1")); - Assert.same(["i","9"], data.get("key2")); - Assert.same(["a"], data.get("key3")); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - #if !lua - public function test6 () { // Schema writer - var schema = new JsonSchemaWriter>().schema; - - var oracle = '{"$$schema": "http://json-schema.org/draft-07/schema#","$$ref": "#/definitions/Map","definitions": {"Map": {"patternProperties": {"/^[-+]?\\d+([Ee][+-]?\\d+)?$/": {"type": "boolean"}},"type": "object"}}}'; - - Assert.isTrue(JsonComparator.areSame(oracle, schema)); - } - #end -} diff --git a/vendor/json2object/tests/ObjectTest.hx b/vendor/json2object/tests/ObjectTest.hx deleted file mode 100644 index 16c7642..0000000 --- a/vendor/json2object/tests/ObjectTest.hx +++ /dev/null @@ -1,138 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -enum A { - First; - Second; -} - -typedef ObjectStruct = { - var i : Int; -} - -class ObjectTestData { - - @:jignored - var a:A; - #if (haxe_ver>=4) - @:default(0)final b : Int = 0; - #else - var b(default, never):Int = 0; - #end - - @:optional - public var objTest:ObjectTestData; - - @:default(true) public var base:Bool; - public var map:Map>; - public var struct:ObjectStruct; - var array:Array; - - public var array_array:Array>; - public var array_map:Array>; - public var array_obj:Array>; - - public var foo(default, null) : Int; -} - -class ObjectTest implements utest.ITest { - public function new () {} - - public function test1 () { // Optional/Jignored + missing - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data:ObjectTestData = parser.fromJson('{ "base": true, "array": [0,2], "map":{"key":{"base":false, "array":[1], "map":{"t":null}, "struct":{"i": 9}}}, "struct":{"i":1}, "foo": 25 }', "test"); - - Assert.isTrue(data.base); - Assert.same([0,2], @:privateAccess data.array); - Assert.isFalse(data.map.get("key").base); - Assert.same([1], @:privateAccess data.map.get("key").array); - Assert.isNull(data.map.get("key").map.get("t")); - Assert.equals(1, data.struct.i); - Assert.equals(25, data.foo); - - for (error in parser.errors) { - switch (error) { - case UninitializedVariable(v, pos): - Assert.same({file:"test", lines:[{start:pos.min, end:pos.min, number:1}], min:pos.min, max:pos.min}, pos); - switch (pos.min) { - case 110: - Assert.isTrue(["array_array", "array_map", "array_obj", "b", "foo"].lastIndexOf(v) != -1); - case 142: - Assert.isTrue(["array_array", "array_map", "array_obj", "b"].lastIndexOf(v) != -1); - default: - Assert.isTrue(false); - } - default: - Assert.isTrue(false); - } - } - Assert.equals(9, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test2 () { // Optional - var parser = new JsonParser>(); - var writer = new JsonWriter>(); - var data = parser.fromJson('{ "objTest":{"b": 2, "base":true, "array":[], "map":{}, "struct":{"i":10}, "array_array":null, "array_map":null, "array_obj":null, "foo":45}, "array": null, "map":{"key":null}, "struct":{"i":2}, "array_array":[[0,1], [4, -1]], "array_map":[{"a":1}, null], "array_obj":[{"base":true, "array":[], "map":{}, "struct":{"i":10}, "array_array":null, "array_map":null, "array_obj":null, "foo":46}], "foo": 63 }', "test"); - Assert.isTrue(data.base); - Assert.isNull(@:privateAccess data.array); - Assert.isNull(data.map.get("key")); - Assert.equals(2, data.struct.i); - Assert.isTrue(data.objTest.base); - Assert.same([], @:privateAccess data.objTest.array); - Assert.same(new Map>(), data.objTest.map); - Assert.equals(63, data.foo); - #if (haxe_ver>=4) - @:privateAccess { - Assert.equals(2, data.objTest.b); - } - #end - - for (error in parser.errors) { - switch (error) { - case UninitializedVariable(v, pos): - Assert.same({file:"test", lines:[{start:pos.min, end:pos.min, number:1}], min:pos.min, max:pos.min}, pos); - switch (pos.min) { - case 390: - Assert.equals("b", v); - case 404: - Assert.isTrue(v == "b" || v == "base"); - default: - Assert.isTrue(false); - } - default: - Assert.isTrue(false); - } - } - - Assert.equals(3, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } -} diff --git a/vendor/json2object/tests/OtherAbstract.hx b/vendor/json2object/tests/OtherAbstract.hx deleted file mode 100644 index d3a662f..0000000 --- a/vendor/json2object/tests/OtherAbstract.hx +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -@:forward -abstract OtherAbstract (OtherAbstractData) -{ -} - -private class OtherAbstractData -{ - public var hello : String; -} diff --git a/vendor/json2object/tests/OtherEnum.hx b/vendor/json2object/tests/OtherEnum.hx deleted file mode 100644 index 33a62e1..0000000 --- a/vendor/json2object/tests/OtherEnum.hx +++ /dev/null @@ -1,31 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -@:enum -abstract TestEnum (String) -{ - var VAL1 = "value1"; - var VAL2 = "value2"; - var VAL3 = "value3"; -} diff --git a/vendor/json2object/tests/StructureTest.hx b/vendor/json2object/tests/StructureTest.hx deleted file mode 100644 index c2650b8..0000000 --- a/vendor/json2object/tests/StructureTest.hx +++ /dev/null @@ -1,232 +0,0 @@ -/* -Copyright (c) 2017-2018 Guillaume Desquesnes, Valentin Lemière - -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. -*/ - -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import json2object.utils.JsonSchemaWriter; -import utest.Assert; - -typedef Struct = { - @:default(true) - var a : Bool; - var b : Int; -} - -typedef DefaultStruct = { - @:optional - //~ @:default({a:true, b:0}) - @:default(auto) - var d : Struct; - @:optional - @:default(new Map()) - var map:Map; - @:optional - var s:String; -} - -typedef ReadonlyStruct = { - var foo(default,null):Int; -} - -typedef SimpleDefault = { - @:default({a:"foo", b:3}) - var foo(default,null):{a:String, b:Int}; - @:default("test") - var auto:String; - @:default(auto) - var bool:Bool; -} - -typedef OuterStruct = { - @:optional var outer:InnerStruct; -} - -typedef InnerStruct = { - @:optional var inner:Int; -} - -typedef ArrayStruct = { - var array:Array; -} - -typedef MapIIStruct = { - var map:Map; -} - -typedef Issue19 = { - @:default(auto) var s:Issue19Inner; -} - -typedef Issue19Inner = { - @:optional @:default(0) var a:Int; - @:optional var b:Int; - @:optional @:default(0) var c:Int; - var d:Issue19Inner; - @:optional @:default(auto) var e:Struct; - @:default(auto) var f:StructA; -} - -class StructA { - @:default(1) public var a:Int; -} - -typedef StructB = { - @:optional @:default(0) var a:Int; - var b:Bool; - @:optional @:default(0) var c:String; -} - -class StructureTest implements utest.ITest { - public function new () {} - - public function test1 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{}', "test"); - Assert.equals(0, parser.errors.length); - Assert.isTrue(data.d.a); - Assert.equals(0, data.d.b); - Assert.same(new Map(), data.map); - Assert.isNull(data.s); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - - data = parser.fromJson('{"d":{"a":false, "b":1}, "map":{"key1":55, "key2": 46, "key3":43}, "s":"sup"}', "test"); - Assert.equals(0, parser.errors.length); - Assert.isFalse(data.d.a); - Assert.equals(1, data.d.b); - Assert.equals(46, data.map["key2"]); - Assert.equals("sup", data.s); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test2 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "a": true, "b": 12 }', "test"); - Assert.isTrue(data.a); - Assert.equals(12, data.b); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test3 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{ "a": 12, "b": 12 }', "test"); - Assert.isTrue(data.a); - Assert.equals(2, parser.errors.length); // IncorrectType + UninitializedVariable - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test4 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"foo":1}', ""); - Assert.equals(1, data.foo); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test5 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"foo":1.2}', ""); - Assert.equals(parser.errors.length, 2); - Assert.equals(0, data.foo); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test6 () { - var parser = new JsonParser<{ var foo(default,null):Int; }>(); - var writer = new JsonWriter<{ var foo(default,null):Int; }>(); - var data = parser.fromJson('{"foo":12}', ""); - Assert.equals(12, data.foo); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test7 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"outer": {}}', ""); - // @:optionnal transform Int into Null - Assert.isNull(data.outer.inner); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test8 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"array": [1,2,3.2]}', ""); - Assert.equals(1, parser.errors.length); - Assert.same([1,2], data.array); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test9 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"map": {"1":2, "3.1": 4, "5":6, "7":8.2}}', ""); - Assert.equals(2, parser.errors.length); - Assert.equals(2, data.map.get(1)); - Assert.equals(6, data.map.get(5)); - Assert.isFalse(data.map.exists(7)); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test10 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{}', ""); - Assert.equals(1, parser.errors.length); - Assert.equals(0, data.s.a); - Assert.isNull(data.s.b); - Assert.equals(0, data.s.c); - Assert.isNull(data.s.d); - Assert.isTrue(data.s.e.a); - Assert.equals(0, data.s.e.b); - Assert.equals(1, data.s.f.a); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - public function test11 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('{"s":{"a":1, "b":2, "c":3, "d":null, "e":{"a":false,"b":1}, "f":{"a":2}}}', ""); - Assert.equals(0, parser.errors.length); - Assert.equals(1, data.s.a); - Assert.equals(2, data.s.b); - Assert.equals(3, data.s.c); - Assert.isNull(data.s.d); - Assert.isFalse(data.s.e.a); - Assert.equals(1, data.s.e.b); - Assert.equals(2, data.s.f.a); - Assert.same(data, parser.fromJson(writer.write(data), "test")); - } - - #if !lua - public function test12 () { - var schema = new JsonSchemaWriter().schema; - var oracle = '{"definitions": {"{ b : Int, a : String }": {"additionalProperties": false,"properties": {"b": {"type": "integer"},"a": {"type": "string"}},"required": ["a","b"],"type": "object"},"tests.SimpleDefault": {"additionalProperties": false,"properties": {"foo": {"$$ref": "#/definitions/{ b : Int, a :String }"},"auto": {"default": "test", "type": "string"},"bool":{"default": false, "type": "boolean"}},"required": ["auto","bool","foo"],"type": "object"}},"$$ref": "#/definitions/tests.SimpleDefault","$$schema": "http://json-schema.org/draft-07/schema#"}'; - Assert.isTrue(JsonComparator.areSame(oracle, schema)); - } - #end -} diff --git a/vendor/json2object/tests/UIntTest.hx b/vendor/json2object/tests/UIntTest.hx deleted file mode 100644 index 0ee193c..0000000 --- a/vendor/json2object/tests/UIntTest.hx +++ /dev/null @@ -1,25 +0,0 @@ -package tests; - -import json2object.JsonParser; -import json2object.JsonWriter; -import utest.Assert; - -class UIntTest implements utest.ITest { - public function new () {} - - public function test1 () { - var parser = new JsonParser(); - var writer = new JsonWriter(); - var data = parser.fromJson('2147483648'); - Assert.equals(0, parser.errors.length); - Assert.same(data, parser.fromJson(writer.write(data))); - } - - public function test2 () { - var parser = new JsonParser(); - var data = parser.fromJson('2147483648.54'); - var orcale:UInt = 0; - Assert.equals(1, parser.errors.length); - Assert.same(orcale, data); - } -} \ No newline at end of file