@@ -2395,6 +2395,97 @@ TEST_F(LLVMCodeBuilderTest, GetListItemIndex)
23952395 ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
23962396}
23972397
2398+ TEST_F (LLVMCodeBuilderTest, ListContainsItem)
2399+ {
2400+ EngineMock engine;
2401+ Stage stage;
2402+ Sprite sprite;
2403+ sprite.setEngine (&engine);
2404+ EXPECT_CALL (engine, stage ()).WillRepeatedly (Return (&stage));
2405+
2406+ auto globalList = std::make_shared<List>(" " , " " );
2407+ stage.addList (globalList);
2408+
2409+ auto localList = std::make_shared<List>(" " , " " );
2410+ sprite.addList (localList);
2411+
2412+ globalList->append (1 );
2413+ globalList->append (2 );
2414+ globalList->append (3 );
2415+
2416+ localList->append (" Lorem" );
2417+ localList->append (" ipsum" );
2418+ localList->append (" dolor" );
2419+ localList->append (" sit" );
2420+
2421+ createBuilder (&sprite, true );
2422+
2423+ m_builder->addConstValue (2 );
2424+ m_builder->addListContains (globalList.get ());
2425+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2426+
2427+ m_builder->addConstValue (1 );
2428+ m_builder->addListContains (globalList.get ());
2429+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2430+
2431+ m_builder->addConstValue (0 );
2432+ m_builder->addListContains (globalList.get ());
2433+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2434+
2435+ m_builder->addConstValue (1 );
2436+ m_builder->addConstValue (" test" );
2437+ m_builder->createListReplace (globalList.get ());
2438+
2439+ m_builder->addConstValue (2 );
2440+ m_builder->addListContains (globalList.get ());
2441+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2442+
2443+ m_builder->addConstValue (1 );
2444+ m_builder->addListContains (globalList.get ());
2445+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2446+
2447+ m_builder->addConstValue (" test" );
2448+ m_builder->addListContains (globalList.get ());
2449+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2450+
2451+ m_builder->addConstValue (" abc" );
2452+ m_builder->addListContains (globalList.get ());
2453+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2454+
2455+ m_builder->addConstValue (" doLor" );
2456+ m_builder->addListContains (localList.get ());
2457+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2458+
2459+ m_builder->addConstValue (true );
2460+ m_builder->addListContains (localList.get ());
2461+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2462+
2463+ m_builder->addConstValue (" site" );
2464+ m_builder->addListContains (localList.get ());
2465+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2466+
2467+ static const std::string expected =
2468+ " true\n "
2469+ " true\n "
2470+ " false\n "
2471+ " false\n "
2472+ " true\n "
2473+ " true\n "
2474+ " false\n "
2475+ " true\n "
2476+ " false\n "
2477+ " true\n " ;
2478+
2479+ auto code = m_builder->finalize ();
2480+ auto ctx = code->createExecutionContext (&sprite);
2481+ testing::internal::CaptureStdout ();
2482+ code->run (ctx.get ());
2483+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
2484+
2485+ ASSERT_EQ (globalList->toString (), " 1 test 3" );
2486+ ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
2487+ }
2488+
23982489TEST_F (LLVMCodeBuilderTest, Yield)
23992490{
24002491 auto build = [this ]() {
0 commit comments