script: unify interactive compiler entry points

This commit is contained in:
西风逍遥游 committed 2026-08-25 15:59:26 +08:00
1 parent fdd3fbe227
commit b5100b6dbd
7 files changed
+88 -14

No files matched your search

+15
View File
@@ -4,6 +4,7 @@
#include "zeroerr/assert.h"
#include "zeroerr/unittest.h"
#include <cstring>
#include <filesystem>
#include <fstream>
#include <iterator>
@@ -201,3 +202,17 @@ TEST_CASE("scriptCompiler.servesLanguageToolingQueries") {
CHECK(hover->markdown.find("physics.newWorld") != std::string::npos);
CHECK(runtime.scriptCompiler().diagnostics("game:/tooling.nut").empty());
}
TEST_CASE("scriptCompiler.rawVmBridgeRecordsToolingMetadata") {
Runtime runtime(512, ssq::Libs::ALL);
const char* source = "local replValue: int = 7\n";
const SQInteger top = sq_gettop(runtime.handle());
const SQRESULT result = script::ScriptCompiler::compileBuffer(
runtime.handle(), source, static_cast<SQInteger>(std::strlen(source)), "console_repl.nut", SQTrue);
CHECK(SQ_SUCCEEDED(result));
sq_settop(runtime.handle(), top);
const script::ScriptMetadata* metadata = runtime.scriptCompiler().metadata("console_repl.nut");
CHECK(metadata != nullptr);
CHECK_EQ(metadata->symbols.size(), size_t(1));
CHECK_EQ(metadata->symbols[0].name, std::string("replValue"));
}