@@ -3568,3 +3568,72 @@ TEST_F(LLVMCodeBuilderTest, LoopLists)
35683568 code->run (ctx.get ());
35693569 ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
35703570}
3571+
3572+ TEST_F (LLVMCodeBuilderTest, StopNoWarp)
3573+ {
3574+ Sprite sprite;
3575+ createBuilder (&sprite, false );
3576+
3577+ m_builder->beginLoopCondition ();
3578+ CompilerValue *v = m_builder->addConstValue (true );
3579+ m_builder->beginWhileLoop (v);
3580+ m_builder->createStop ();
3581+ m_builder->endLoop ();
3582+
3583+ m_builder->addTargetFunctionCall (" test_function_no_args" , Compiler::StaticType::Void, {}, {});
3584+
3585+ std::string expected = " " ;
3586+
3587+ auto code = m_builder->finalize ();
3588+ Script script (&sprite, nullptr , nullptr );
3589+ script.setCode (code);
3590+ Thread thread (&sprite, nullptr , &script);
3591+ auto ctx = code->createExecutionContext (&thread);
3592+ testing::internal::CaptureStdout ();
3593+ code->run (ctx.get ());
3594+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
3595+ }
3596+
3597+ TEST_F (LLVMCodeBuilderTest, StopWarp)
3598+ {
3599+ Sprite sprite;
3600+ createBuilder (&sprite, true );
3601+
3602+ CompilerValue *v = m_builder->addConstValue (true );
3603+ m_builder->beginIfStatement (v);
3604+ m_builder->createStop ();
3605+ m_builder->endIf ();
3606+
3607+ m_builder->addTargetFunctionCall (" test_function_no_args" , Compiler::StaticType::Void, {}, {});
3608+
3609+ std::string expected = " " ;
3610+
3611+ auto code = m_builder->finalize ();
3612+ Script script (&sprite, nullptr , nullptr );
3613+ script.setCode (code);
3614+ Thread thread (&sprite, nullptr , &script);
3615+ auto ctx = code->createExecutionContext (&thread);
3616+ testing::internal::CaptureStdout ();
3617+ code->run (ctx.get ());
3618+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
3619+ }
3620+
3621+ TEST_F (LLVMCodeBuilderTest, StopAndReturn)
3622+ {
3623+ Sprite sprite;
3624+ createBuilder (&sprite, true );
3625+
3626+ m_builder->addTargetFunctionCall (" test_function_no_args" , Compiler::StaticType::Void, {}, {});
3627+ m_builder->createStop ();
3628+
3629+ std::string expected = " no_args\n " ;
3630+
3631+ auto code = m_builder->finalize ();
3632+ Script script (&sprite, nullptr , nullptr );
3633+ script.setCode (code);
3634+ Thread thread (&sprite, nullptr , &script);
3635+ auto ctx = code->createExecutionContext (&thread);
3636+ testing::internal::CaptureStdout ();
3637+ code->run (ctx.get ());
3638+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
3639+ }
0 commit comments