From 4786a6ce2645c6d13404557aeefbf0637c33939f Mon Sep 17 00:00:00 2001 From: leftibot Date: Fri, 10 Apr 2026 22:25:16 -0600 Subject: [PATCH] Address review: add tests for get_scripting_objects() Requested by @lefticus in PR #640 review. Co-Authored-By: Claude Opus 4.6 (1M context) --- unittests/compiled_tests.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/unittests/compiled_tests.cpp b/unittests/compiled_tests.cpp index 750c4c47..5307022f 100644 --- a/unittests/compiled_tests.cpp +++ b/unittests/compiled_tests.cpp @@ -431,6 +431,25 @@ TEST_CASE("Get function objects from public API") { CHECK(chai.eval("myfun()") == 2); } +TEST_CASE("Get scripting objects from public API") { + chaiscript::ChaiScript_Basic chai(create_chaiscript_stdlib(), create_chaiscript_parser()); + + // Define some variables in script + chai.eval("var x = 42"); + chai.eval("var name = \"hello\""); + + // get_scripting_objects should be accessible from the public API + auto objects = chai.get_scripting_objects(); + + // Our scripting variables should be in the map + CHECK(objects.count("x") == 1); + CHECK(objects.count("name") == 1); + + // Verify the values are correct + CHECK(chaiscript::boxed_cast(objects["x"]) == 42); + CHECK(chaiscript::boxed_cast(objects["name"]) == "hello"); +} + //// Short comparisons class Short_Comparison_Test {