-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: support for compiled jsons ending with an container and not a DO…
…NE (#56) ## Added support for closing container without done command As shown by [Jerry](https://discordapp.com/users/jerrytron) adds inky, an empty container at the end of the story. Which resulted in an unexpected EOF. Now there is a check iff we leave the top-level container and are at the end of the story file, the story ends. ## Add test for different compiled JSON Ensures compatibility for different ink compilers (bonus: use link for inkcpp_test resource file should now also support Windows)
- Loading branch information
Showing
7 changed files
with
367 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "catch.hpp" | ||
// #include "../inkcpp_cl/test.cpp" | ||
|
||
#include <story.h> | ||
#include <globals.h> | ||
#include <runner.h> | ||
#include <compiler.h> | ||
|
||
using namespace ink::runtime; | ||
|
||
static constexpr const char* OUTPUT_PART_1 = "Once upon a time...\n"; | ||
static constexpr const char* OUTPUT_PART_2 = "There were two choices.\nThey lived happily ever after.\n"; | ||
static constexpr size_t CHOICE = 0; | ||
|
||
SCENARIO("run inklecate 1.1.1 story") | ||
{ | ||
auto compiler = GENERATE("inklecate", "inky"); | ||
GIVEN(compiler) | ||
{ | ||
auto input_file = std::string("ink/simple-1.1.1-") + compiler + ".json"; | ||
ink::compiler::run(input_file.c_str(), "simple.bin"); | ||
auto ink = story::from_file("simple.bin"); | ||
runner thread = ink->new_runner(); | ||
|
||
THEN("Expect normal output") { | ||
REQUIRE(thread->getall() == OUTPUT_PART_1); | ||
REQUIRE(thread->has_choices()); | ||
REQUIRE(thread->num_choices() == 2); | ||
thread->choose(CHOICE); | ||
REQUIRE(thread->getall() == OUTPUT_PART_2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
{ | ||
"inkVersion": 21, | ||
"root": [ | ||
[ | ||
{ | ||
"->": "start" | ||
}, | ||
[ | ||
"done", | ||
{ | ||
"#n": "g-0" | ||
} | ||
], | ||
null | ||
], | ||
"done", | ||
{ | ||
"start": [ | ||
[ | ||
"^Once upon a time...", | ||
"\n", | ||
[ | ||
"ev", | ||
{ | ||
"^->": "start.0.2.$r1" | ||
}, | ||
{ | ||
"temp=": "$r" | ||
}, | ||
"str", | ||
{ | ||
"->": ".^.s" | ||
}, | ||
[ | ||
{ | ||
"#n": "$r1" | ||
} | ||
], | ||
"/str", | ||
"/ev", | ||
{ | ||
"*": ".^.^.c-0", | ||
"flg": 18 | ||
}, | ||
{ | ||
"s": [ | ||
"^There were two choices.", | ||
{ | ||
"->": "$r", | ||
"var": true | ||
}, | ||
null | ||
] | ||
} | ||
], | ||
[ | ||
"ev", | ||
{ | ||
"^->": "start.0.3.$r1" | ||
}, | ||
{ | ||
"temp=": "$r" | ||
}, | ||
"str", | ||
{ | ||
"->": ".^.s" | ||
}, | ||
[ | ||
{ | ||
"#n": "$r1" | ||
} | ||
], | ||
"/str", | ||
"/ev", | ||
{ | ||
"*": ".^.^.c-1", | ||
"flg": 18 | ||
}, | ||
{ | ||
"s": [ | ||
"^There were four lines of content.", | ||
{ | ||
"->": "$r", | ||
"var": true | ||
}, | ||
null | ||
] | ||
} | ||
], | ||
{ | ||
"c-0": [ | ||
"ev", | ||
{ | ||
"^->": "start.0.c-0.$r2" | ||
}, | ||
"/ev", | ||
{ | ||
"temp=": "$r" | ||
}, | ||
{ | ||
"->": ".^.^.2.s" | ||
}, | ||
[ | ||
{ | ||
"#n": "$r2" | ||
} | ||
], | ||
"\n", | ||
{ | ||
"->": ".^.^.g-0" | ||
}, | ||
{ | ||
"#f": 5 | ||
} | ||
], | ||
"c-1": [ | ||
"ev", | ||
{ | ||
"^->": "start.0.c-1.$r2" | ||
}, | ||
"/ev", | ||
{ | ||
"temp=": "$r" | ||
}, | ||
{ | ||
"->": ".^.^.3.s" | ||
}, | ||
[ | ||
{ | ||
"#n": "$r2" | ||
} | ||
], | ||
"\n", | ||
{ | ||
"->": ".^.^.g-0" | ||
}, | ||
{ | ||
"#f": 5 | ||
} | ||
], | ||
"g-0": [ | ||
"^They lived happily ever after.", | ||
"\n", | ||
"end", | ||
null | ||
] | ||
} | ||
], | ||
null | ||
] | ||
} | ||
], | ||
"listDefs": {} | ||
} |
Oops, something went wrong.