Patrick Kelley 8fd444092b initial
2025-05-07 15:35:15 -04:00

58 lines
1.2 KiB
Plaintext

# @TEST-GROUP: no-jit
# @TEST-EXEC: ${HILTIC} -g -P "" -o Foo.h %INPUT
# @TEST-EXEC: ${HILTIC} -g -c -D compiler -o foo.cc %INPUT
# @TEST-EXEC: ${HILTIC} -g -l -D compiler -o linker.cc foo.cc
# @TEST-EXEC: cxx-compile -c -o foo.o foo.cc
# @TEST-EXEC: cxx-compile -c -o linker.o linker.cc
# @TEST-EXEC: cxx-compile -c -o driver.o driver.cc
# @TEST-EXEC: cxx-link -o a.out foo.o linker.o driver.o
# @TEST-EXEC: ./a.out >output
# @TEST-EXEC: btest-diff output
module Foo {
import hilti;
function extern string test(string x) {
hilti::print("HILTI - 1 - argument: ", False);
hilti::print(x);
yield;
hilti::print("HILTI - 2");
yield;
hilti::print("HILTI - 3");
yield;
hilti::print("HILTI - Done");
return "test-result";
}
}
@TEST-START-FILE driver.cc
#include <hilti/rt/libhilti.h>
#include "Foo.h"
extern "C" int HILTI_EXPORT hilti_main() { // Point of entry for JIT
auto r = hlt::Foo::test("argument");
while ( ! r ) {
std::cout << "suspended, resuming" << std::endl;
r.resume();
}
std::cout << "Done, result: " << r.get<std::string>() << std::endl;
return 0;
}
int main(int argc, char** argv) {
hilti::rt::init();
hilti_main();
hilti::rt::done();
return 0;
}
@TEST-END-FILE