@@ -1801,6 +1801,54 @@ TEST_F(LLVMCodeBuilderTest, ListReplace)
18011801 ASSERT_EQ (localList->toString (), " 3 ipsum true hello world" );
18021802}
18031803
1804+ TEST_F (LLVMCodeBuilderTest, GetListContents)
1805+ {
1806+ EngineMock engine;
1807+ Stage stage;
1808+ Sprite sprite;
1809+ sprite.setEngine (&engine);
1810+ EXPECT_CALL (engine, stage ()).WillRepeatedly (Return (&stage));
1811+
1812+ std::unordered_map<List *, std::string> strings;
1813+
1814+ auto globalList = std::make_shared<List>(" " , " " );
1815+ stage.addList (globalList);
1816+
1817+ auto localList = std::make_shared<List>(" " , " " );
1818+ sprite.addList (localList);
1819+
1820+ globalList->append (1 );
1821+ globalList->append (2 );
1822+ globalList->append (3 );
1823+
1824+ localList->append (" Lorem" );
1825+ localList->append (" ipsum" );
1826+ localList->append (" dolor" );
1827+ localList->append (" sit" );
1828+ strings[localList.get ()] = localList->toString ();
1829+
1830+ createBuilder (&sprite, true );
1831+
1832+ CompilerValue *v = m_builder->addListContents (globalList.get ());
1833+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
1834+
1835+ v = m_builder->addListContents (localList.get ());
1836+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
1837+
1838+ static const std::string expected =
1839+ " 123\n "
1840+ " Lorem ipsum dolor sit\n " ;
1841+
1842+ auto code = m_builder->finalize ();
1843+ auto ctx = code->createExecutionContext (&sprite);
1844+ testing::internal::CaptureStdout ();
1845+ code->run (ctx.get ());
1846+ ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
1847+
1848+ ASSERT_EQ (globalList->toString (), " 123" );
1849+ ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
1850+ }
1851+
18041852TEST_F (LLVMCodeBuilderTest, GetListItem)
18051853{
18061854 EngineMock engine;
0 commit comments