inkcpp_rb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +84 -0
- data/LICENSE +7 -0
- data/README.md +3 -0
- data/Rakefile +16 -0
- data/bin/console +15 -0
- data/bin/setup +10 -0
- data/bin/tapioca +29 -0
- data/ext/inkcpp_rb/extconf.rb +19 -0
- data/ext/inkcpp_rb/inkcpp/.clang-format +99 -0
- data/ext/inkcpp_rb/inkcpp/.github/FUNDING.yml +1 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/build.yml +344 -0
- data/ext/inkcpp_rb/inkcpp/.github/workflows/release.yml +49 -0
- data/ext/inkcpp_rb/inkcpp/.gitignore +25 -0
- data/ext/inkcpp_rb/inkcpp/.gitmodules +9 -0
- data/ext/inkcpp_rb/inkcpp/CMakeLists.txt +170 -0
- data/ext/inkcpp_rb/inkcpp/CODE_OF_CONDUCT.md +76 -0
- data/ext/inkcpp_rb/inkcpp/CONTRIBUTING.md +55 -0
- data/ext/inkcpp_rb/inkcpp/Config.cmake.in +2 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/CMakeLists.txt +13 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.c +38 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/main.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example/test.ink.json +1 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/cmake_example.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/InkCPP_DEMO.zip +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/CreateThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/HandleChoice.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ListElementOf.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalRuntime.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/MinimalThread.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/ObseverChange.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/TagListGetValue.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Documentation/unreal/imgs/YieldResume.png +0 -0
- data/ext/inkcpp_rb/inkcpp/Doxyfile +2825 -0
- data/ext/inkcpp_rb/inkcpp/LICENSE.txt +22 -0
- data/ext/inkcpp_rb/inkcpp/Minimal.runsettings +8 -0
- data/ext/inkcpp_rb/inkcpp/README.md +192 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/CMakeLists.txt +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/array.h +481 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/avl_array.h +833 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/casting.h +93 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/choice.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.cpp +124 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/collections/restorable.h +406 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.cpp +52 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/container_operations.h +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/executioner.h +179 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functional.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.cpp +54 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/functions.h +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.cpp +289 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/globals_impl.h +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/header.cpp +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/choice.h +106 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/functional.h +327 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/globals.h +196 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/list.h +187 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/runner.h +291 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/snapshot.h +61 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story.h +219 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/story_ptr.h +233 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/traits.h +270 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/include/types.h +169 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.cpp +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_impl.h +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.cpp +276 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_operations.h +356 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.cpp +841 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/list_table.h +450 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/numeric_operations.h +529 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operation_bases.h +164 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/operations.h +100 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.cpp +528 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/output.h +153 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/platform.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/random.h +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.cpp +1396 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/runner_impl.h +336 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/simple_restorable_stack.h +335 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.cpp +182 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_impl.h +91 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/snapshot_interface.h +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.cpp +618 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/stack.h +243 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.cpp +361 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_impl.h +92 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/story_ptr.cpp +75 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.cpp +125 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_operations.h +67 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.cpp +149 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_table.h +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/string_utils.h +207 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/system.cpp +39 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/tuple.hpp +151 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.cpp +279 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp/value.h +666 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/CMakeLists.txt +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/include/inkcpp.h +393 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp.cpp +344 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/inkcpp_c.pc.in +10 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/ExternalFunction.c +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Globals.c +98 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Lists.c +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Observer.c +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_c/tests/Snapshot.c +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/CMakeLists.txt +49 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/inkcpp_cl.cpp +215 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.cpp +209 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_cl/test.h +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/CMakeLists.txt +37 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.cpp +446 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_emitter.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.cpp +166 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/binary_stream.h +79 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/command.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/compiler.cpp +96 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.cpp +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/emitter.h +104 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compilation_results.h +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/include/compiler.h +44 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json.hpp +24596 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.cpp +411 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/json_compiler.h +62 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/list_data.h +70 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.cpp +107 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_compiler/reporter.h +55 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/CMakeLists.txt +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/example.py +78 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/src/module.cpp +317 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/conftest.py +53 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_ExternalFunctions.py +35 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Globals.py +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Lists.py +43 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Observer.py +27 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/tests/test_Snapshot.py +57 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_py/unreal_example.ink +71 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Array.cpp +115 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/CMakeLists.txt +117 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Callstack.cpp +392 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/EmptyStringForDivert.cpp +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ExternalFunctionsExecuteProperly.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/FallbackFunction.cpp +77 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Globals.cpp +73 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/InkyJson.cpp +34 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LabelCondition.cpp +60 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Lists.cpp +144 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/LookaheadSafe.cpp +46 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Main.cpp +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/MoveTo.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NewLines.cpp +76 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/NoEarlyTags.cpp +33 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Observer.cpp +245 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Pointer.cpp +191 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Restorable.cpp +294 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/SpaceAfterBracketChoice.cpp +45 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Stack.cpp +224 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Tags.cpp +131 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ThirdTierChoiceAfterBrackets.cpp +38 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/UTF8.cpp +56 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/Value.cpp +210 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/catch.hpp +17970 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/AHF.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ChoiceBracketStory.ink +7 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/EmptyStringForDivert.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ExternalFunctionsExecuteProperly.ink +11 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/FallBack.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/GlobalStory.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LabelConditionStory.ink +5 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LinesStory.ink +42 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListLogicStory.ink +40 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ListStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/LookaheadSafe.ink +14 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/MoveTo.ink +36 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/NoEarlyTags.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ObserverStory.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/SimpleStoryFlow.ink +65 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TagsStory.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/TheIntercept.ink +1686 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/ThirdTierChoiceAfterBracketsStory.ink +13 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF-8-demo.txt +212 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/UTF8Story.ink +218 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inklecate.json +154 -0
- data/ext/inkcpp_rb/inkcpp/inkcpp_test/ink/simple-1.1.1-inky.json +160 -0
- data/ext/inkcpp_rb/inkcpp/notes/ArchitectureNotes.md +54 -0
- data/ext/inkcpp_rb/inkcpp/notes/ListNotes.md +69 -0
- data/ext/inkcpp_rb/inkcpp/notes/OperationNotes.md +35 -0
- data/ext/inkcpp_rb/inkcpp/notes/TagsNotes.md +24 -0
- data/ext/inkcpp_rb/inkcpp/notes/WhitespaceNotes.md +28 -0
- data/ext/inkcpp_rb/inkcpp/proofing/README.md +3 -0
- data/ext/inkcpp_rb/inkcpp/proofing/inkcpp_runtime_driver +12 -0
- data/ext/inkcpp_rb/inkcpp/pyproject.toml +63 -0
- data/ext/inkcpp_rb/inkcpp/setup.py +166 -0
- data/ext/inkcpp_rb/inkcpp/shared/CMakeLists.txt +14 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/command.h +172 -0
- data/ext/inkcpp_rb/inkcpp/shared/private/header.h +46 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/config.h +53 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/system.h +307 -0
- data/ext/inkcpp_rb/inkcpp/shared/public/version.h +14 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestAllSequenceTypes.ink +59 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestArithmetic.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicStringLiterals.ink +8 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBasicTunnel.ink +10 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestBlanksInInlineSequences.ink +51 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCallStackEvaluation.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceCount.ink +15 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceDivertsToDone.ink +6 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestChoiceWithBracketsOnly.ink +9 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestCompareDivertTargets.ink +26 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestComplexTunnels.ink +22 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestConditionalChoiceInWeave.ink +19 -0
- data/ext/inkcpp_rb/inkcpp/tests/TestTunnelOnwardsAfterTunnel.ink +17 -0
- data/ext/inkcpp_rb/inkcpp/unreal/CMakeLists.txt +51 -0
- data/ext/inkcpp_rb/inkcpp/unreal/UE_example.ink +92 -0
- data/ext/inkcpp_rb/inkcpp/unreal/blueprint_filter.js +377 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Resources/Icon128.png +0 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkAsset.cpp +47 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkChoice.cpp +40 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkList.cpp +86 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkRuntime.cpp +265 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkThread.cpp +239 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/InkVar.cpp +143 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/TagList.cpp +95 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Private/inkcpp.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkAsset.h +50 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkChoice.h +58 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkDelegates.h +139 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkList.h +102 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkRuntime.h +177 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkSnapshot.h +30 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkThread.h +215 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/InkVar.h +245 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/TagList.h +77 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/Public/inkcpp.h +217 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp/inkcpp.Build.cs +62 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.cpp +237 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/InkAssetFactory.h +43 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inkcpp_editor.cpp +13 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Private/inklecate_cmd.cpp.in +24 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/Public/inkcpp_editor.h +9 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/Source/inkcpp_editor/inkcpp_editor.Build.cs +61 -0
- data/ext/inkcpp_rb/inkcpp/unreal/inkcpp/inkcpp.uplugin +44 -0
- data/ext/inkcpp_rb/inkcpp/unreal/render.css +1 -0
- data/ext/inkcpp_rb/inkcpp_rb.cpp +321 -0
- data/inkcpp_rb.gemspec +54 -0
- data/rbi/inkcpp_rb.rbi +211 -0
- data/sorbet/config +4 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
- data/sorbet/rbi/gems/minitest@5.25.4.rbi +1547 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/prism@1.3.0.rbi +40040 -0
- data/sorbet/rbi/gems/rake-compiler@1.2.8.rbi +9 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3033 -0
- data/sorbet/rbi/gems/rbi@0.2.2.rbi +4527 -0
- data/sorbet/rbi/gems/rice@4.3.3.rbi +44 -0
- data/sorbet/rbi/gems/spoom@1.5.0.rbi +4932 -0
- data/sorbet/rbi/gems/tapioca@0.16.7.rbi +3611 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18379 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +400 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include "../inkcpp/simple_restorable_stack.h"
|
4
|
+
|
5
|
+
using ink::runtime::internal::simple_restorable_stack;
|
6
|
+
|
7
|
+
template<typename T, ink::size_t N>
|
8
|
+
using fixed_restorable_stack = ink::runtime::internal::managed_restorable_stack<T,false,N>;
|
9
|
+
|
10
|
+
template<typename T, int SIZE>
|
11
|
+
void stack_matches(const simple_restorable_stack<T>& stack, T (&expected)[SIZE])
|
12
|
+
{
|
13
|
+
// Iterate stack and check that it matches the expected array
|
14
|
+
int count = 0;
|
15
|
+
const int* iter = nullptr;
|
16
|
+
while (stack.iter(iter)) {
|
17
|
+
REQUIRE(count < SIZE);
|
18
|
+
REQUIRE(*iter == expected[SIZE - count - 1]);
|
19
|
+
count++;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
SCENARIO("simple_restorable_stack can be pushed and popped", "[stack]") {
|
24
|
+
|
25
|
+
GIVEN("An empty stack") {
|
26
|
+
fixed_restorable_stack<int, 10> stack(~0);
|
27
|
+
|
28
|
+
WHEN("items are added") {
|
29
|
+
stack.push(1);
|
30
|
+
stack.push(2);
|
31
|
+
stack.push(3);
|
32
|
+
|
33
|
+
THEN("the size has increased") {
|
34
|
+
REQUIRE(!stack.empty());
|
35
|
+
REQUIRE(stack.size() == 3);
|
36
|
+
}
|
37
|
+
|
38
|
+
THEN("the correct item is at the top") {
|
39
|
+
REQUIRE(stack.top() == 3);
|
40
|
+
}
|
41
|
+
|
42
|
+
THEN("we can iterate the stack") {
|
43
|
+
int expected[] = { 1, 2, 3 };
|
44
|
+
stack_matches(stack, expected);
|
45
|
+
}
|
46
|
+
|
47
|
+
WHEN("they are popped") {
|
48
|
+
int pop = stack.pop();
|
49
|
+
|
50
|
+
THEN("the correct item is popped") {
|
51
|
+
REQUIRE(pop == 3);
|
52
|
+
}
|
53
|
+
|
54
|
+
THEN("there are fewer items") {
|
55
|
+
REQUIRE(stack.size() == 2);
|
56
|
+
}
|
57
|
+
|
58
|
+
THEN("there is a new item on top") {
|
59
|
+
REQUIRE(stack.top() == 2);
|
60
|
+
}
|
61
|
+
|
62
|
+
THEN("we can still iterate") {
|
63
|
+
int expected[] = { 1, 2 };
|
64
|
+
stack_matches(stack, expected);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
SCENARIO("simple_restorable_stack supports save/restore", "[stack]") {
|
72
|
+
GIVEN("a stack with a few items that has been saved") {
|
73
|
+
fixed_restorable_stack<int, 20> stack(~0);
|
74
|
+
|
75
|
+
stack.push(1);
|
76
|
+
stack.push(2);
|
77
|
+
stack.push(3);
|
78
|
+
stack.save();
|
79
|
+
|
80
|
+
auto check_restore = [&stack]() {
|
81
|
+
WHEN("we restore the stack") {
|
82
|
+
stack.restore();
|
83
|
+
|
84
|
+
THEN("we should be back to having 4 items") {
|
85
|
+
REQUIRE(stack.size() == 3);
|
86
|
+
}
|
87
|
+
|
88
|
+
THEN("they should match exactly the original items") {
|
89
|
+
int expected[] = { 1, 2, 3 };
|
90
|
+
stack_matches(stack, expected);
|
91
|
+
}
|
92
|
+
}
|
93
|
+
};
|
94
|
+
|
95
|
+
WHEN("new items are pushed") {
|
96
|
+
stack.push(4);
|
97
|
+
|
98
|
+
THEN("the pushed item is on top") {
|
99
|
+
REQUIRE(stack.top() == 4);
|
100
|
+
}
|
101
|
+
THEN("the size has increased") {
|
102
|
+
REQUIRE(stack.size() == 4);
|
103
|
+
}
|
104
|
+
|
105
|
+
WHEN("the state is restored") {
|
106
|
+
stack.restore();
|
107
|
+
|
108
|
+
THEN("the original item is back on top") {
|
109
|
+
REQUIRE(stack.size() == 3);
|
110
|
+
REQUIRE(stack.top() == 3);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
WHEN("the state is finalized") {
|
115
|
+
stack.forget();
|
116
|
+
|
117
|
+
THEN("the new item is still on top") {
|
118
|
+
REQUIRE(stack.size() == 4);
|
119
|
+
REQUIRE(stack.top() == 4);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
WHEN("items are popped") {
|
125
|
+
stack.pop(); stack.pop();
|
126
|
+
|
127
|
+
THEN("the stack has shrunk") {
|
128
|
+
REQUIRE(stack.size() == 1);
|
129
|
+
REQUIRE(stack.top() == 1);
|
130
|
+
}
|
131
|
+
|
132
|
+
WHEN("more items are pushed") {
|
133
|
+
stack.push(90);
|
134
|
+
stack.push(91);
|
135
|
+
|
136
|
+
THEN("the stack has the correct size") {
|
137
|
+
REQUIRE(stack.size() == 3);
|
138
|
+
REQUIRE(stack.top() == 91);
|
139
|
+
}
|
140
|
+
|
141
|
+
THEN("iteration only covers items that ought to be in the stack") {
|
142
|
+
int expected[] = { 1, 90, 91 };
|
143
|
+
stack_matches(stack, expected);
|
144
|
+
}
|
145
|
+
|
146
|
+
THEN("we can pop all items from the stack") {
|
147
|
+
REQUIRE(stack.pop() == 91);
|
148
|
+
REQUIRE(stack.pop() == 90);
|
149
|
+
REQUIRE(stack.pop() == 1);
|
150
|
+
REQUIRE(stack.empty());
|
151
|
+
|
152
|
+
// Check that the stack can restore
|
153
|
+
check_restore();
|
154
|
+
|
155
|
+
THEN("we can add more items to the stack")
|
156
|
+
{
|
157
|
+
// Push more items
|
158
|
+
stack.push(100);
|
159
|
+
stack.push(101);
|
160
|
+
int expected[] = { 100, 101 };
|
161
|
+
stack_matches(stack, expected);
|
162
|
+
|
163
|
+
// Check that we can still restore
|
164
|
+
check_restore();
|
165
|
+
}
|
166
|
+
}
|
167
|
+
|
168
|
+
// Check that the stack can restore
|
169
|
+
check_restore();
|
170
|
+
|
171
|
+
THEN("we can finalize the stack") {
|
172
|
+
stack.forget();
|
173
|
+
|
174
|
+
int expected[] = { 1, 90, 91 };
|
175
|
+
stack_matches(stack, expected);
|
176
|
+
}
|
177
|
+
|
178
|
+
WHEN("we pop them back off") {
|
179
|
+
stack.pop(); stack.pop();
|
180
|
+
|
181
|
+
THEN("the correct entry is on top") {
|
182
|
+
REQUIRE(stack.top() == 1);
|
183
|
+
REQUIRE(stack.size() == 1);
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
GIVEN("a stack with one entry that has been saved")
|
191
|
+
{
|
192
|
+
fixed_restorable_stack<int, 10> stack(~0);
|
193
|
+
stack.push(0);
|
194
|
+
stack.save();
|
195
|
+
|
196
|
+
WHEN("an item is popped, pushed, and popped again")
|
197
|
+
{
|
198
|
+
stack.pop();
|
199
|
+
stack.push(1);
|
200
|
+
stack.pop();
|
201
|
+
|
202
|
+
THEN("the stack should be considered 'empty'")
|
203
|
+
{
|
204
|
+
REQUIRE(stack.size() == 0);
|
205
|
+
REQUIRE(stack.empty());
|
206
|
+
}
|
207
|
+
}
|
208
|
+
|
209
|
+
WHEN("an item is popped and pushed and then we forget()")
|
210
|
+
{
|
211
|
+
stack.pop();
|
212
|
+
stack.push(1);
|
213
|
+
stack.pop();
|
214
|
+
stack.forget();
|
215
|
+
|
216
|
+
THEN("the stack should be empty")
|
217
|
+
{
|
218
|
+
REQUIRE(stack.size() == 0);
|
219
|
+
REQUIRE(stack.empty());
|
220
|
+
}
|
221
|
+
|
222
|
+
}
|
223
|
+
}
|
224
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <story.h>
|
4
|
+
#include <globals.h>
|
5
|
+
#include <runner.h>
|
6
|
+
#include <compiler.h>
|
7
|
+
#include <choice.h>
|
8
|
+
|
9
|
+
using namespace ink::runtime;
|
10
|
+
|
11
|
+
SCENARIO("tags", "[tags]")
|
12
|
+
{
|
13
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "AHF.bin");
|
14
|
+
runner thread = ink->new_runner();
|
15
|
+
thread->move_to(ink::hash_string("test_knot"));
|
16
|
+
while(thread->can_continue()) {
|
17
|
+
auto line = thread->getline();
|
18
|
+
}
|
19
|
+
REQUIRE(thread->can_continue() == false);
|
20
|
+
}
|
21
|
+
|
22
|
+
SCENARIO("run story with tags", "[tags]")
|
23
|
+
{
|
24
|
+
GIVEN("a story with tags")
|
25
|
+
{
|
26
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "TagsStory.bin");
|
27
|
+
runner thread = ink->new_runner();
|
28
|
+
WHEN("start thread")
|
29
|
+
{
|
30
|
+
THEN("No tags")
|
31
|
+
{
|
32
|
+
REQUIRE(thread->has_tags() == false);
|
33
|
+
}
|
34
|
+
WHEN("approach first line")
|
35
|
+
{
|
36
|
+
std::string line = thread->getall();
|
37
|
+
THEN("print no tags")
|
38
|
+
{
|
39
|
+
REQUIRE(line == "Hello\n");
|
40
|
+
}
|
41
|
+
THEN("collect all previous Tags (global, knot, line) in correct order")
|
42
|
+
{
|
43
|
+
REQUIRE(thread->has_tags() == true);
|
44
|
+
REQUIRE(thread->num_tags() == 4);
|
45
|
+
REQUIRE(std::string(thread->get_tag(0)) == "global_tag");
|
46
|
+
REQUIRE(std::string(thread->get_tag(1)) == "knot_tag_start");
|
47
|
+
REQUIRE(std::string(thread->get_tag(2)) == "second_knot_tag_start");
|
48
|
+
REQUIRE(std::string(thread->get_tag(3)) == "output_tag_h");
|
49
|
+
}
|
50
|
+
WHEN("print choices")
|
51
|
+
{
|
52
|
+
auto itr = thread->begin();
|
53
|
+
std::string choices[2] = {
|
54
|
+
itr[0].text(),
|
55
|
+
itr[1].text()
|
56
|
+
};
|
57
|
+
THEN("choices won't print tags, tags are still the same, but they can contain tags")
|
58
|
+
{
|
59
|
+
REQUIRE(choices[0] == "a");
|
60
|
+
REQUIRE(choices[1] == "b");
|
61
|
+
REQUIRE(thread->has_tags());
|
62
|
+
REQUIRE(thread->num_tags() == 4);
|
63
|
+
REQUIRE(std::string(thread->get_tag(0)) == "global_tag");
|
64
|
+
REQUIRE(std::string(thread->get_tag(1)) == "knot_tag_start");
|
65
|
+
REQUIRE(std::string(thread->get_tag(2)) == "second_knot_tag_start");
|
66
|
+
REQUIRE(std::string(thread->get_tag(3)) == "output_tag_h");
|
67
|
+
|
68
|
+
REQUIRE_FALSE(itr[0].has_tags());
|
69
|
+
REQUIRE(itr[0].num_tags() == 0);
|
70
|
+
REQUIRE(itr[1].has_tags());
|
71
|
+
|
72
|
+
REQUIRE(itr[1].num_tags() == 2);
|
73
|
+
REQUIRE(std::string(itr[1].get_tag(0)) == "choice_tag_b");
|
74
|
+
REQUIRE(std::string(itr[1].get_tag(1)) == "choice_tag_b_2");
|
75
|
+
}
|
76
|
+
WHEN("choose divert")
|
77
|
+
{
|
78
|
+
thread->choose(1);
|
79
|
+
THEN("choosing won't add tags!")
|
80
|
+
{
|
81
|
+
REQUIRE_FALSE(thread->has_tags());
|
82
|
+
REQUIRE(thread->num_tags() == 0);
|
83
|
+
}
|
84
|
+
WHEN("proceed")
|
85
|
+
{
|
86
|
+
std::string line = thread->getall();
|
87
|
+
THEN("new knot tag and now line tag, also choice tag. AND dont print tag in choice")
|
88
|
+
{
|
89
|
+
REQUIRE(line == "Knot2\n");
|
90
|
+
REQUIRE(thread->has_tags());
|
91
|
+
REQUIRE(thread->num_tags() == 2);
|
92
|
+
REQUIRE(std::string(thread->get_tag(0)) == "knot_tag_2");
|
93
|
+
REQUIRE(std::string(thread->get_tag(1)) == "output_tag_k");
|
94
|
+
|
95
|
+
auto itr = thread->begin();
|
96
|
+
REQUIRE(std::string(itr[0].text()) == "e");
|
97
|
+
REQUIRE(std::string(itr[1].text()) == "f with detail");
|
98
|
+
REQUIRE(std::string(itr[2].text()) == "g");
|
99
|
+
|
100
|
+
REQUIRE_FALSE(itr[0].has_tags());
|
101
|
+
REQUIRE(itr[0].num_tags() == 0);
|
102
|
+
REQUIRE(itr[1].has_tags());
|
103
|
+
REQUIRE(itr[1].num_tags() == 4);
|
104
|
+
REQUIRE(std::string(itr[1].get_tag(0)) == "shared_tag");
|
105
|
+
REQUIRE(std::string(itr[1].get_tag(1)) == "shared_tag_2");
|
106
|
+
REQUIRE(std::string(itr[1].get_tag(2)) == "choice_tag");
|
107
|
+
REQUIRE(std::string(itr[1].get_tag(3)) == "choice_tag_2");
|
108
|
+
REQUIRE(itr[2].has_tags());
|
109
|
+
REQUIRE(itr[2].num_tags() == 1);
|
110
|
+
}
|
111
|
+
WHEN("choose choice with tag, and proceed to end")
|
112
|
+
{
|
113
|
+
thread->choose(1);
|
114
|
+
auto line = thread->getall();
|
115
|
+
|
116
|
+
REQUIRE(line == "f and content\nout");
|
117
|
+
REQUIRE(thread->has_tags());
|
118
|
+
REQUIRE(thread->num_tags() == 5);
|
119
|
+
REQUIRE(std::string(thread->get_tag(0)) == "shared_tag");
|
120
|
+
REQUIRE(std::string(thread->get_tag(1)) == "shared_tag_2");
|
121
|
+
REQUIRE(std::string(thread->get_tag(2)) == "content_tag");
|
122
|
+
REQUIRE(std::string(thread->get_tag(3)) == "content_tag_2");
|
123
|
+
REQUIRE(std::string(thread->get_tag(4)) == "close_tag");
|
124
|
+
}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <story.h>
|
4
|
+
#include <globals.h>
|
5
|
+
#include <runner.h>
|
6
|
+
#include <compiler.h>
|
7
|
+
|
8
|
+
using namespace ink::runtime;
|
9
|
+
|
10
|
+
SCENARIO(
|
11
|
+
"a story with a bracketed choice as a second choice, and then a third choice, chooses properly",
|
12
|
+
"[choices]"
|
13
|
+
)
|
14
|
+
{
|
15
|
+
GIVEN("a story with brackets and nested choices")
|
16
|
+
{
|
17
|
+
auto ink = story::from_file(INK_TEST_RESOURCE_DIR "ThirdTierChoiceAfterBracketsStory.bin");
|
18
|
+
runner thread = ink->new_runner();
|
19
|
+
|
20
|
+
WHEN("start thread")
|
21
|
+
{
|
22
|
+
THEN("thread doesn't error")
|
23
|
+
{
|
24
|
+
thread->getall();
|
25
|
+
REQUIRE(thread->has_choices());
|
26
|
+
thread->choose(0);
|
27
|
+
thread->getall();
|
28
|
+
REQUIRE(thread->has_choices());
|
29
|
+
thread->choose(0);
|
30
|
+
thread->getall();
|
31
|
+
REQUIRE(thread->has_choices());
|
32
|
+
thread->choose(0);
|
33
|
+
thread->getall();
|
34
|
+
REQUIRE(! thread->has_choices());
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <story.h>
|
4
|
+
#include <runner.h>
|
5
|
+
#include <compiler.h>
|
6
|
+
|
7
|
+
#include <sstream>
|
8
|
+
#include <fstream>
|
9
|
+
|
10
|
+
using namespace ink::runtime;
|
11
|
+
|
12
|
+
SCENARIO("a story supports UTF-8", "[utf-8]")
|
13
|
+
{
|
14
|
+
GIVEN("a story with UTF8 characters")
|
15
|
+
{
|
16
|
+
ink::compiler::run(INK_TEST_RESOURCE_DIR "UTF8Story.ink.json", "UTF8Story.bin");
|
17
|
+
auto ink = story::from_file("UTF8Story.bin");
|
18
|
+
runner thread = ink->new_runner();
|
19
|
+
|
20
|
+
std::ifstream demoFile("ink/UTF-8-demo.txt");
|
21
|
+
if (!demoFile.is_open()) {
|
22
|
+
throw std::runtime_error("cannot open UTF-8 demo file");
|
23
|
+
}
|
24
|
+
|
25
|
+
char byte;
|
26
|
+
std::stringstream demo;
|
27
|
+
std::stringstream current;
|
28
|
+
while (demoFile.get(byte)) {
|
29
|
+
if (byte == '\r') continue; // skip windows carriage-return newlines
|
30
|
+
else if (byte == '\n' || byte == 0) { // newline or null byte
|
31
|
+
std::string s = current.str();
|
32
|
+
if (s.empty()) continue;
|
33
|
+
demo << s << '\n';
|
34
|
+
current.str("");
|
35
|
+
}
|
36
|
+
else { // normal char
|
37
|
+
current << byte;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
std::string s = current.str();
|
41
|
+
if (!s.empty()) demo << s << '\n';
|
42
|
+
|
43
|
+
|
44
|
+
WHEN("consume lines") {
|
45
|
+
std::stringstream content;
|
46
|
+
while (thread->can_continue()) {
|
47
|
+
content << thread->getline();
|
48
|
+
}
|
49
|
+
THEN("lines match test file") {
|
50
|
+
std::string c = content.str();
|
51
|
+
std::string d = demo.str();
|
52
|
+
REQUIRE(c == d);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,210 @@
|
|
1
|
+
#include "catch.hpp"
|
2
|
+
|
3
|
+
#include <compiler.h>
|
4
|
+
#include <story.h>
|
5
|
+
|
6
|
+
#include "../inkcpp/string_table.h"
|
7
|
+
#include "../inkcpp/list_table.h"
|
8
|
+
#include "../inkcpp/random.h"
|
9
|
+
#include "../inkcpp/output.h"
|
10
|
+
#include "../inkcpp/executioner.h"
|
11
|
+
#include "../shared/private/command.h"
|
12
|
+
|
13
|
+
#include "../inkcpp/story_impl.h"
|
14
|
+
#include "../inkcpp/runner_impl.h"
|
15
|
+
#include "../inkcpp/globals_impl.h"
|
16
|
+
|
17
|
+
using ink::runtime::internal::value;
|
18
|
+
using ink::runtime::internal::value_type;
|
19
|
+
using ink::runtime::internal::string_table;
|
20
|
+
using ink::runtime::internal::list_table;
|
21
|
+
using ink::runtime::internal::prng;
|
22
|
+
using stream = ink::runtime::internal::stream<128>;
|
23
|
+
using ink::runtime::internal::executer;
|
24
|
+
using eval_stack = ink::runtime::internal::eval_stack<28, false>;
|
25
|
+
using ink::Command;
|
26
|
+
|
27
|
+
using ink::runtime::internal::story_impl;
|
28
|
+
using ink::runtime::internal::globals_impl;
|
29
|
+
using ink::runtime::globals;
|
30
|
+
using ink::runtime::runner;
|
31
|
+
|
32
|
+
void cp_str(char* dst, const char* src) {
|
33
|
+
while(*src) { *dst++ = *src++; }
|
34
|
+
*dst = 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
SCENARIO("compare concatenated values")
|
38
|
+
{
|
39
|
+
string_table str_table;
|
40
|
+
list_table lst_table{};
|
41
|
+
prng rng;
|
42
|
+
eval_stack stack;
|
43
|
+
story_impl story(INK_TEST_RESOURCE_DIR "ListStory.bin");
|
44
|
+
globals globs_ptr = story.new_globals();
|
45
|
+
runner run = story.new_runner(globs_ptr);
|
46
|
+
globals_impl& globs = *globs_ptr.cast<globals_impl>();
|
47
|
+
executer ops(rng, story, globs, globs.strings(), globs.lists(), *run);
|
48
|
+
|
49
|
+
GIVEN("just single strings")
|
50
|
+
{
|
51
|
+
const char str_1[] = "Hello World!";
|
52
|
+
const char str_1_again[] = "Hello World!";
|
53
|
+
const char str_2[] = "Bye World!";
|
54
|
+
WHEN("equal")
|
55
|
+
{
|
56
|
+
stack.push(value{}.set<value_type::string>(str_1));
|
57
|
+
stack.push(value{}.set<value_type::string>(str_1_again));
|
58
|
+
ops(Command::IS_EQUAL, stack);
|
59
|
+
value res = stack.pop();
|
60
|
+
THEN("== results in true")
|
61
|
+
{
|
62
|
+
REQUIRE(res.type() == value_type::boolean);
|
63
|
+
REQUIRE(res.get<value_type::boolean>() == true);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
WHEN("not equal")
|
67
|
+
{
|
68
|
+
stack.push(value{}.set<value_type::string>(str_1));
|
69
|
+
stack.push(value{}.set<value_type::string>(str_2));
|
70
|
+
ops(Command::IS_EQUAL, stack);
|
71
|
+
value res = stack.pop();
|
72
|
+
THEN("== results in false")
|
73
|
+
{
|
74
|
+
REQUIRE(res.type() == value_type::boolean);
|
75
|
+
REQUIRE(res.get<value_type::boolean>() == false);
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
GIVEN("string and numbers")
|
80
|
+
{
|
81
|
+
stream out{};
|
82
|
+
char* str_hello = str_table.create(6);
|
83
|
+
cp_str(str_hello, "hello");
|
84
|
+
char* str_5hello = str_table.create(7);
|
85
|
+
cp_str(str_5hello, "5hello");
|
86
|
+
char* str_4 = str_table.create(2);
|
87
|
+
cp_str(str_4, "4");
|
88
|
+
char* str_32_4 = str_table.create(33);
|
89
|
+
for (int i = 0; i < 32; ++i) { str_32_4[i] = '4'; }
|
90
|
+
str_32_4[32] = 0;
|
91
|
+
|
92
|
+
int int_4 = 4;
|
93
|
+
int int_45 = 45;
|
94
|
+
WHEN("concatenated string representation matches (2 fields)")
|
95
|
+
{
|
96
|
+
stack.push(value{}.set<value_type::int32>(int_4));
|
97
|
+
stack.push(value{}.set<value_type::string>(str_5hello));
|
98
|
+
ops(Command::ADD, stack);
|
99
|
+
stack.push(value{}.set<value_type::int32>(int_45));
|
100
|
+
stack.push(value{}.set<value_type::string>(str_hello));
|
101
|
+
ops(Command::ADD, stack);
|
102
|
+
ops(Command::IS_EQUAL, stack);
|
103
|
+
value res = stack.pop();
|
104
|
+
THEN("== returns true")
|
105
|
+
{
|
106
|
+
REQUIRE(res.type() == value_type::boolean);
|
107
|
+
REQUIRE(res.get<value_type::boolean>() == true);
|
108
|
+
}
|
109
|
+
}
|
110
|
+
WHEN("concatenated string representation match (many fields)")
|
111
|
+
{
|
112
|
+
stack.push(value{}.set<value_type::string>(str_4));
|
113
|
+
for (int i = 0; i < 31; ++i) {
|
114
|
+
stack.push(value{}.set<value_type::int32>(int_4));
|
115
|
+
ops(Command::ADD, stack);
|
116
|
+
}
|
117
|
+
stack.push(value{}.set<value_type::string>(str_32_4));
|
118
|
+
ops(Command::IS_EQUAL, stack);
|
119
|
+
value res = stack.pop();
|
120
|
+
THEN("== results true")
|
121
|
+
{
|
122
|
+
REQUIRE(res.type() == value_type::boolean);
|
123
|
+
REQUIRE(res.get<value_type::boolean>() == true);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
WHEN("concatenated string representation won't match")
|
127
|
+
{
|
128
|
+
stack.push(value{}.set<value_type::int32>(int_45));
|
129
|
+
stack.push(value{}.set<value_type::string>(str_5hello));
|
130
|
+
ops(Command::ADD, stack);
|
131
|
+
stack.push(value{}.set<value_type::int32>(int_4));
|
132
|
+
stack.push(value{}.set<value_type::string>(str_hello));
|
133
|
+
ops(Command::ADD, stack);
|
134
|
+
ops(Command::IS_EQUAL, stack);
|
135
|
+
value res = stack.pop();
|
136
|
+
THEN("== returns false")
|
137
|
+
{
|
138
|
+
REQUIRE(res.type() == value_type::boolean);
|
139
|
+
REQUIRE(res.get<value_type::boolean>() == false);
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
GIVEN("numbers")
|
144
|
+
{
|
145
|
+
int i5 = 5;
|
146
|
+
int i8 = 8;
|
147
|
+
float f5 = 5.f;
|
148
|
+
WHEN("numbers are same")
|
149
|
+
{
|
150
|
+
stack.push(value{}.set<value_type::int32>(i8));
|
151
|
+
stack.push(value{}.set<value_type::int32>(i8));
|
152
|
+
ops(Command::IS_EQUAL, stack);
|
153
|
+
value res1 = stack.pop();
|
154
|
+
stack.push(value{}.set<value_type::float32>(f5));
|
155
|
+
stack.push(value{}.set<value_type::float32>(f5));
|
156
|
+
ops(Command::IS_EQUAL, stack);
|
157
|
+
value res2 = stack.pop();
|
158
|
+
THEN("== returns true")
|
159
|
+
{
|
160
|
+
REQUIRE(res1.type() == value_type::boolean);
|
161
|
+
REQUIRE(res1.get<value_type::boolean>() == true);
|
162
|
+
REQUIRE(res2.type() == value_type::boolean);
|
163
|
+
REQUIRE(res2.get<value_type::boolean>() == true);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
WHEN("numbers equal, but different encoding")
|
167
|
+
{
|
168
|
+
stack.push(value{}.set<value_type::int32>(i5));
|
169
|
+
stack.push(value{}.set<value_type::float32>(f5));
|
170
|
+
ops(Command::IS_EQUAL, stack);
|
171
|
+
value res = stack.pop();
|
172
|
+
THEN("== returns true")
|
173
|
+
{
|
174
|
+
REQUIRE(res.type() == value_type::boolean);
|
175
|
+
REQUIRE(res.get<value_type::boolean>() == true);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
WHEN("numbers value and encoding differs")
|
179
|
+
{
|
180
|
+
stack.push(value{}.set<value_type::float32>(f5));
|
181
|
+
stack.push(value{}.set<value_type::int32>(i8));
|
182
|
+
ops(Command::IS_EQUAL, stack);
|
183
|
+
value res = stack.pop();
|
184
|
+
THEN("== returns false")
|
185
|
+
{
|
186
|
+
REQUIRE(res.type() == value_type::boolean);
|
187
|
+
REQUIRE(res.get<value_type::boolean>() == false);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
WHEN("calculate with float and int (5.,8)")
|
191
|
+
{
|
192
|
+
stack.push(value{}.set<value_type::float32>(f5));
|
193
|
+
stack.push(value{}.set<value_type::int32>(i8));
|
194
|
+
THEN("adding results 13.")
|
195
|
+
{
|
196
|
+
ops(Command::ADD, stack);
|
197
|
+
value res = stack.pop();
|
198
|
+
REQUIRE(res.type() == value_type::float32);
|
199
|
+
REQUIRE(res.get<value_type::float32>() == 13.f);
|
200
|
+
}
|
201
|
+
THEN("dividing results in 0.625")
|
202
|
+
{
|
203
|
+
ops(Command::DIVIDE, stack);
|
204
|
+
value res = stack.pop();
|
205
|
+
REQUIRE(res.type() == value_type::float32);
|
206
|
+
REQUIRE(res.get<value_type::float32>() == 0.625f);
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
}
|