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

@@ -10,9 +10,9 @@ unittest
{
string input = "aba";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
input = "abb";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
}
@@ -10,13 +10,13 @@ unittest
{
string input = "a";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == false);
assert(parser.parse() == Testparser.Parser.P_UNEXPECTED_TOKEN);
input = "a b";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
input = "bb";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
}
+1 -1
View File
@@ -10,6 +10,6 @@ unittest
{
string input = `identifier_123`;
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass1");
}
+2 -2
View File
@@ -10,11 +10,11 @@ unittest
{
string input = `abc "a string" def`;
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass1");
input = `abc "abc def" def`;
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass2");
}
+2 -2
View File
@@ -10,11 +10,11 @@ unittest
{
string input = `x`;
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(parser.result == 1u);
input = `fabulous`;
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(parser.result == 8u);
}
+1 -1
View File
@@ -10,5 +10,5 @@ unittest
{
string input = "ab";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
}
+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"]);
+3 -3
View File
@@ -10,16 +10,16 @@ unittest
{
string input = "a";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(parser.result == 1u);
input = "";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(parser.result == 0u);
input = "aaaaaaaaaaaaaaaa";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
assert(parser.result == 16u);
}
+2 -2
View File
@@ -10,11 +10,11 @@ unittest
{
string input = "abcdef";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass1");
input = "defabcdef";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass2");
}
+1 -1
View File
@@ -10,5 +10,5 @@ unittest
{
string input = "defghidef";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
}
+2 -2
View File
@@ -10,11 +10,11 @@ unittest
{
string input = "abcdef";
auto parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass1");
input = "abcabcdef";
parser = new Testparser.Parser(input);
assert(parser.parse() == true);
assert(parser.parse() == Testparser.Parser.P_SUCCESS);
writeln("pass2");
}