@@ -2259,6 +2259,51 @@ TEST_F(LLVMCodeBuilderTest, GetListItem)
22592259 ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
22602260}
22612261
2262+ TEST_F (LLVMCodeBuilderTest, GetListSize)
2263+ {
2264+ EngineMock engine;
2265+ Stage stage;
2266+ Sprite sprite;
2267+ sprite.setEngine (&engine);
2268+ EXPECT_CALL (engine, stage ()).WillRepeatedly (Return (&stage));
2269+
2270+ auto globalList = std::make_shared<List>(" " , " " );
2271+ stage.addList (globalList);
2272+
2273+ auto localList = std::make_shared<List>(" " , " " );
2274+ sprite.addList (localList);
2275+
2276+ globalList->append (1 );
2277+ globalList->append (2 );
2278+ globalList->append (3 );
2279+
2280+ localList->append (" Lorem" );
2281+ localList->append (" ipsum" );
2282+ localList->append (" dolor" );
2283+ localList->append (" sit" );
2284+
2285+ createBuilder (&sprite, true );
2286+
2287+ m_builder->addListSize (globalList.get ());
2288+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2289+
2290+ m_builder->addListSize (localList.get ());
2291+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String });
2292+
2293+ static const std::string expected =
2294+ " 3\n "
2295+ " 4\n " ;
2296+
2297+ auto code = m_builder->finalize ();
2298+ auto ctx = code->createExecutionContext (&sprite);
2299+ testing::internal::CaptureStdout ();
2300+ code->run (ctx.get ());
2301+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
2302+
2303+ ASSERT_EQ (globalList->toString (), " 123" );
2304+ ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
2305+ }
2306+
22622307TEST_F (LLVMCodeBuilderTest, Yield)
22632308{
22642309 auto build = [this ]() {
0 commit comments