Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write test WDL++ files and JSON parsers to test out parsing of JSON files for WDL purposes #485

Closed
noahklowden opened this issue May 4, 2020 · 8 comments · Fixed by #599
Assignees
Labels
Milestone

Comments

@noahklowden
Copy link
Contributor

In order to understand how to integrate the WDL++ system using JSON, we will be writing test parsers and test files.

These test files should be written in the tests.

@noahklowden noahklowden added this to the 2020/Sprint 2 milestone May 4, 2020
@noahklowden noahklowden changed the title Write test WDL++ files to test out parsing of JSON files for WDL purposes Write test WDL++ files and JSON parers to test out parsing of JSON files for WDL purposes May 10, 2020
@noahklowden noahklowden changed the title Write test WDL++ files and JSON parers to test out parsing of JSON files for WDL purposes Write test WDL++ files and JSON parsers to test out parsing of JSON files for WDL purposes May 10, 2020
@noahklowden
Copy link
Contributor Author

Created a branch for working on the issue: json_parse_test. This is where all work for testing the JSON parsing will go.

@noahklowden
Copy link
Contributor Author

noahklowden commented May 11, 2020

The branch work is now within chiventure/src/wdl/sandbox.

There is now a file parser.c used for testing, a Makefile for compiling parser.c, and a .json file used for tests.

parser.c currently on utilizes a basic main function. Ideally the goal is to move into more individual functions for parsing rooms, items, and the game object respectively.

The Makefile looks for the json-c library, which is required to be installed to use the tests.

The current JSON file is just the original connected_rooms.wdl file converted to JSON format using a YAML converter .

@noahklowden
Copy link
Contributor Author

Added a print function that will print out the first test. The code is able to now access the "intro" part of the game object.

Next step is to start moving the actual JSON object creation into their own files so the main function isn't super bulky. Then add more tests for the rooms and items.

@noahklowden
Copy link
Contributor Author

Parsing now occurs in its own function separate 'parse()' from the main function that can return the actual top level JSON object. This is a start, but it still isn't near enough for a full test of parsing.

@noahklowden
Copy link
Contributor Author

Started rewrite code to convert from JSON object to game_t object. Hypothetically, if the tests work, the libobj code wouldn't even be necessary for the purposes of converting from WDL to game object.

I can't get the Makefile to work, though, which is preventing me from testing.

@noahklowden
Copy link
Contributor Author

Closing this issue in order to move on to the new sprint. The test files are all located in the branch json_parse_test. We were able to achieve parsing the JSON information from JSON string to a JSON object. From these the tests, we can conclude that JSON is most definitely easier to parse from than YAML.

While I was unable to test the integration with other parts of the Chiventure code as I could not get the integration in the Makefile to function properly, the code for the integration, while imperfect, should hopefully serve as somewhat of a model for how we might be able to integrate future attempts at constructing. From writing the code, it does seem we might, if we choose, be able to skip libobj entirely and could convert from JSON objects straight to game objects.

@MaxineK36
Copy link
Contributor

Issue Score: ✔️+

Comments:
Great job with this issue! The updates are helpful and well-written, as is the summary.
However, this should have resulted in a pull request, and so it should have been left open. Make sure to look out for that in future issues so that nothing gets lost!

@noahklowden
Copy link
Contributor Author

The issue with the Makefile was fixed and the code was completed in order to be able to print out proof that the parse functioned. It should now properly serve as a model for how we might be able to convert a JSON file into a game object.

The code was pulled into dev in #599. As this branch is still being used by @dtbukowski in #529, the branch shall not be deleted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants