@@ -2134,6 +2134,62 @@ TEST_F(LLVMCodeBuilderTest, InsertToList)
21342134 ASSERT_EQ (localList->toString (), " false hello world true" );
21352135}
21362136
2137+ TEST_F (LLVMCodeBuilderTest, ListReplace)
2138+ {
2139+ EngineMock engine;
2140+ Stage stage;
2141+ Sprite sprite;
2142+ sprite.setEngine (&engine);
2143+ EXPECT_CALL (engine, stage ()).WillRepeatedly (Return (&stage));
2144+
2145+ std::unordered_map<List *, std::string> strings;
2146+
2147+ auto globalList = std::make_shared<List>(" " , " " );
2148+ stage.addList (globalList);
2149+
2150+ auto localList = std::make_shared<List>(" " , " " );
2151+ sprite.addList (localList);
2152+
2153+ globalList->append (1 );
2154+ globalList->append (2 );
2155+ globalList->append (3 );
2156+
2157+ localList->append (" Lorem" );
2158+ localList->append (" ipsum" );
2159+ localList->append (" dolor" );
2160+ localList->append (" sit" );
2161+ strings[localList.get ()] = localList->toString ();
2162+
2163+ createBuilder (&sprite, true );
2164+
2165+ m_builder->addConstValue (2 );
2166+ m_builder->addConstValue (1 );
2167+ m_builder->createListReplace (globalList.get ());
2168+
2169+ m_builder->addConstValue (1 );
2170+ m_builder->addConstValue (" test" );
2171+ m_builder->createListReplace (globalList.get ());
2172+
2173+ m_builder->addConstValue (0 );
2174+ m_builder->addConstValue (3 );
2175+ m_builder->createListReplace (localList.get ());
2176+
2177+ m_builder->addConstValue (2 );
2178+ m_builder->addConstValue (true );
2179+ m_builder->createListReplace (localList.get ());
2180+
2181+ m_builder->addConstValue (3 );
2182+ m_builder->addConstValue (" hello world" );
2183+ m_builder->createListReplace (localList.get ());
2184+
2185+ auto code = m_builder->finalize ();
2186+ auto ctx = code->createExecutionContext (&sprite);
2187+ code->run (ctx.get ());
2188+
2189+ ASSERT_EQ (globalList->toString (), " 1 test 1" );
2190+ ASSERT_EQ (localList->toString (), " 3 ipsum true hello world" );
2191+ }
2192+
21372193TEST_F (LLVMCodeBuilderTest, Yield)
21382194{
21392195 auto build = [this ]() {
0 commit comments