File tree Expand file tree Collapse file tree 1 file changed +30
-16
lines changed Expand file tree Collapse file tree 1 file changed +30
-16
lines changed Original file line number Diff line number Diff line change 2424#include " gtest/gtest.h"
2525
2626#include < algorithm>
27+ #include < thread>
2728#include < utility>
2829
2930using ::testing::StartsWith;
@@ -368,22 +369,35 @@ TEST(InterpreterTest, MultipleInterpreter) {
368369#if CLANG_VERSION_MAJOR < 20 && defined(EMSCRIPTEN)
369370 GTEST_SKIP () << " Test fails for Emscipten LLVM 20 builds" ;
370371#endif
371- auto * I = Cpp::CreateInterpreter ();
372- EXPECT_TRUE (I);
373- Cpp::Declare (R"(
374- void f() {}
375- )" );
376- Cpp::TCppScope_t f = Cpp::GetNamed (" f" );
377-
372+ auto * I1 = Cpp::CreateInterpreter ();
378373 auto * I2 = Cpp::CreateInterpreter ();
374+ auto * I3 = Cpp::CreateInterpreter ();
375+ auto * I4 = Cpp::CreateInterpreter ();
376+ EXPECT_TRUE (I1);
379377 EXPECT_TRUE (I2);
380- Cpp::Declare (R"(
381- void ff() {}
382- )" );
383- Cpp::TCppScope_t ff = Cpp::GetNamed (" ff" );
384-
385- auto f_callable = Cpp::MakeFunctionCallable (f);
386- EXPECT_EQ (f_callable.getKind (), Cpp::JitCall::Kind::kGenericCall );
387- auto ff_callable = Cpp::MakeFunctionCallable (ff);
388- EXPECT_EQ (ff_callable.getKind (), Cpp::JitCall::Kind::kGenericCall );
378+ EXPECT_TRUE (I3);
379+ EXPECT_TRUE (I4);
380+
381+ auto F = [](Cpp::TInterp_t I) {
382+ Cpp::Declare (R"(
383+ void f() {}
384+ class MyKlass {};
385+ )" ,
386+ false , I);
387+ Cpp::TCppScope_t f = Cpp::GetNamed (" f" , Cpp::GetGlobalScope (I));
388+ EXPECT_TRUE (f);
389+ auto f_callable = Cpp::MakeFunctionCallable (f);
390+ EXPECT_EQ (f_callable.getKind (), Cpp::JitCall::Kind::kGenericCall );
391+ Cpp::TCppType_t f_type = Cpp::GetType (" MyKlass" , I);
392+ EXPECT_EQ (Cpp::GetTypeAsString (f_type), " MyKlass" );
393+ };
394+
395+ std::thread t1 (F, I1);
396+ std::thread t2 (F, I2);
397+ std::thread t3 (F, I3);
398+ std::thread t4 (F, I4);
399+ t1.join ();
400+ t2.join ();
401+ t3.join ();
402+ t4.join ();
389403}
You can’t perform that action at this time.
0 commit comments