Return integer result code from Parser.parse()

This commit is contained in:
josh committed 2023-07-08 08:52:21 -04:00
1 parent c88338698a
commit 0232b204c6
12 files changed
+46 -29

No files matched your search

+7 -7
View File
@@ -11,33 +11,33 @@ unittest
{
string input = ``;
auto parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
input = `{}`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONObject)parser.result);
input = `[]`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONArray)parser.result);
input = `-45.6`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONNumber)parser.result);
assert((cast(JSONNumber)parser.result).value == -45.6);
input = `2E-2`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONNumber)parser.result);
assert((cast(JSONNumber)parser.result).value == 0.02);
input = `{"hi":true}`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONObject)parser.result);
JSONObject o = cast(JSONObject)parser.result;
assert(o.value["hi"]);
@@ -45,7 +45,7 @@ unittest
input = `{"ff": false, "nn": null}`;
parser = new Testparser.Parser(input);
assert(parser.parse());
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(cast(JSONObject)parser.result);
o = cast(JSONObject)parser.result;
assert(o.value["ff"]);