aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-18 08:11:39 +0000
committer_ov4 <ov4@ov4.org>2026-10-18 08:11:39 +0000
commitcd3c09a5c2566d674680193042baf6474b6d0976 (patch)
tree50276c3de1ee4262eccbddb4240bf4267c04a15f /tests
parent30fced09675acfd2b9ab6db6be8359a70d3f0402 (diff)
feat(driver): load the embedded C++ runtime into the JIT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/i/extern-cc-runtime/case.json1
-rw-r--r--tests/i/extern-cc-runtime/expected.txt2
-rw-r--r--tests/i/extern-cc-runtime/program.cps9
-rw-r--r--tests/i/extern-cc-runtime/runtime.cc13
4 files changed, 25 insertions, 0 deletions
diff --git a/tests/i/extern-cc-runtime/case.json b/tests/i/extern-cc-runtime/case.json
new file mode 100644
index 0000000..604feef
--- /dev/null
+++ b/tests/i/extern-cc-runtime/case.json
@@ -0,0 +1 @@
+{"objects":[{"source":"runtime.cc","output":"runtime.o"}]}
diff --git a/tests/i/extern-cc-runtime/expected.txt b/tests/i/extern-cc-runtime/expected.txt
new file mode 100644
index 0000000..3e5a8c6
--- /dev/null
+++ b/tests/i/extern-cc-runtime/expected.txt
@@ -0,0 +1,2 @@
+4099
+caught C++
diff --git a/tests/i/extern-cc-runtime/program.cps b/tests/i/extern-cc-runtime/program.cps
new file mode 100644
index 0000000..74d0386
--- /dev/null
+++ b/tests/i/extern-cc-runtime/program.cps
@@ -0,0 +1,9 @@
+INCLUDE_OBJ "runtime.o"
+EXTERN "C" EXTERN_FUNCTION string_length() RETURNS C_INT
+EXTERN "C" EXTERN_PROCEDURE string_throw()
+OUTPUT (INTEGER)string_length()
+TRY
+ CALL string_throw()
+CATCH
+ OUTPUT "caught C++"
+ENDTRY
diff --git a/tests/i/extern-cc-runtime/runtime.cc b/tests/i/extern-cc-runtime/runtime.cc
new file mode 100644
index 0000000..fd57538
--- /dev/null
+++ b/tests/i/extern-cc-runtime/runtime.cc
@@ -0,0 +1,13 @@
+#include <string>
+#include <stdexcept>
+extern "C" int string_length() {
+ std::string text(4096, 'x');
+ text += std::to_string(123);
+ return static_cast<int>(text.size());
+}
+extern "C" void string_throw() {
+ try { throw std::invalid_argument("string failure"); }
+ catch (const std::exception &e) {
+ if (std::string(e.what()) == "string failure") throw;
+ }
+}