mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2026-07-31 00:37:02 +08:00
Address review: add tests for get_scripting_objects()
Requested by @lefticus in PR #640 review. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
28973e5fbe
commit
4786a6ce26
@ -431,6 +431,25 @@ TEST_CASE("Get function objects from public API") {
|
||||
CHECK(chai.eval<int>("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<int>(objects["x"]) == 42);
|
||||
CHECK(chaiscript::boxed_cast<std::string>(objects["name"]) == "hello");
|
||||
}
|
||||
|
||||
//// Short comparisons
|
||||
|
||||
class Short_Comparison_Test {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user