@@ -1913,9 +1913,21 @@ TEST_F(LLVMCodeBuilderTest, RemoveFromList)
1913
1913
CompilerValue *v = m_builder->addConstValue (1 );
1914
1914
m_builder->createListRemove (globalList.get (), v);
1915
1915
1916
+ v = m_builder->addConstValue (-1 );
1917
+ m_builder->createListRemove (globalList.get (), v);
1918
+
1919
+ v = m_builder->addConstValue (3 );
1920
+ m_builder->createListRemove (globalList.get (), v);
1921
+
1916
1922
v = m_builder->addConstValue (3 );
1917
1923
m_builder->createListRemove (localList.get (), v);
1918
1924
1925
+ v = m_builder->addConstValue (-1 );
1926
+ m_builder->createListRemove (localList.get (), v);
1927
+
1928
+ v = m_builder->addConstValue (4 );
1929
+ m_builder->createListRemove (localList.get (), v);
1930
+
1919
1931
auto code = m_builder->finalize ();
1920
1932
Script script (&sprite, nullptr , nullptr );
1921
1933
script.setCode (code);
@@ -2040,6 +2052,18 @@ TEST_F(LLVMCodeBuilderTest, InsertToList)
2040
2052
v2 = m_builder->addConstValue (" hello world" );
2041
2053
m_builder->createListInsert (localList.get (), v1, v2);
2042
2054
2055
+ v1 = m_builder->addConstValue (3 );
2056
+ v2 = m_builder->addConstValue (" test" );
2057
+ m_builder->createListInsert (localList.get (), v1, v2);
2058
+
2059
+ v1 = m_builder->addConstValue (-1 );
2060
+ v2 = m_builder->addConstValue (123 );
2061
+ m_builder->createListInsert (localList.get (), v1, v2);
2062
+
2063
+ v1 = m_builder->addConstValue (6 );
2064
+ v2 = m_builder->addConstValue (123 );
2065
+ m_builder->createListInsert (localList.get (), v1, v2);
2066
+
2043
2067
auto code = m_builder->finalize ();
2044
2068
Script script (&sprite, nullptr , nullptr );
2045
2069
script.setCode (code);
@@ -2049,7 +2073,7 @@ TEST_F(LLVMCodeBuilderTest, InsertToList)
2049
2073
code->run (ctx.get ());
2050
2074
2051
2075
ASSERT_EQ (globalList->toString (), " 1 2 1 test 3" );
2052
- ASSERT_EQ (localList->toString (), " false hello world true" );
2076
+ ASSERT_EQ (localList->toString (), " false hello world true test " );
2053
2077
}
2054
2078
2055
2079
TEST_F (LLVMCodeBuilderTest, ListReplace)
@@ -2099,6 +2123,14 @@ TEST_F(LLVMCodeBuilderTest, ListReplace)
2099
2123
v2 = m_builder->addConstValue (" hello world" );
2100
2124
m_builder->createListReplace (localList.get (), v1, v2);
2101
2125
2126
+ v1 = m_builder->addConstValue (-1 );
2127
+ v2 = m_builder->addConstValue (123 );
2128
+ m_builder->createListReplace (localList.get (), v1, v2);
2129
+
2130
+ v1 = m_builder->addConstValue (5 );
2131
+ v2 = m_builder->addConstValue (123 );
2132
+ m_builder->createListReplace (localList.get (), v1, v2);
2133
+
2102
2134
auto code = m_builder->finalize ();
2103
2135
Script script (&sprite, nullptr , nullptr );
2104
2136
script.setCode (code);
@@ -2169,26 +2201,36 @@ TEST_F(LLVMCodeBuilderTest, GetListItem)
2169
2201
sprite.setEngine (&m_engine);
2170
2202
EXPECT_CALL (m_engine, stage ()).WillRepeatedly (Return (&stage));
2171
2203
2172
- std::unordered_map<List *, std::string> strings;
2173
-
2174
2204
auto globalList = std::make_shared<List>(" " , " " );
2175
2205
stage.addList (globalList);
2176
2206
2177
- auto localList = std::make_shared<List>(" " , " " );
2178
- sprite.addList (localList);
2207
+ auto localList1 = std::make_shared<List>(" " , " " );
2208
+ sprite.addList (localList1);
2209
+
2210
+ auto localList2 = std::make_shared<List>(" " , " " );
2211
+ sprite.addList (localList2);
2212
+
2213
+ auto localList3 = std::make_shared<List>(" " , " " );
2214
+ sprite.addList (localList3);
2179
2215
2180
2216
globalList->append (1 );
2181
2217
globalList->append (2 );
2182
2218
globalList->append (3 );
2183
2219
2184
- localList->append (" Lorem" );
2185
- localList->append (" ipsum" );
2186
- localList->append (" dolor" );
2187
- localList->append (" sit" );
2188
- strings[localList.get ()] = localList->toString ();
2220
+ localList1->append (" Lorem" );
2221
+ localList1->append (" ipsum" );
2222
+ localList1->append (" dolor" );
2223
+ localList1->append (" sit" );
2224
+
2225
+ localList2->append (-564.121 );
2226
+ localList2->append (4257.4 );
2227
+
2228
+ localList3->append (true );
2229
+ localList3->append (false );
2189
2230
2190
2231
createBuilder (&sprite, true );
2191
2232
2233
+ // Global
2192
2234
CompilerValue *v = m_builder->addConstValue (2 );
2193
2235
v = m_builder->addListItem (globalList.get (), v);
2194
2236
m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
@@ -2201,24 +2243,67 @@ TEST_F(LLVMCodeBuilderTest, GetListItem)
2201
2243
v = m_builder->addListItem (globalList.get (), v);
2202
2244
m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2203
2245
2246
+ v = m_builder->addConstValue (-1 );
2247
+ v = m_builder->addListItem (globalList.get (), v);
2248
+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2249
+
2250
+ v = m_builder->addConstValue (3 );
2251
+ v = m_builder->addListItem (globalList.get (), v);
2252
+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2253
+
2254
+ // Local 1
2204
2255
v = m_builder->addConstValue (0 );
2205
- v = m_builder->addListItem (localList .get (), v);
2256
+ v = m_builder->addListItem (localList1 .get (), v);
2206
2257
m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2207
2258
2208
2259
v = m_builder->addConstValue (2 );
2209
- v = m_builder->addListItem (localList .get (), v);
2260
+ v = m_builder->addListItem (localList1 .get (), v);
2210
2261
m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2211
2262
2212
2263
v = m_builder->addConstValue (3 );
2213
- v = m_builder->addListItem (localList.get (), v);
2264
+ v = m_builder->addListItem (localList1.get (), v);
2265
+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2266
+
2267
+ v = m_builder->addConstValue (-1 );
2268
+ v = m_builder->addListItem (localList1.get (), v);
2214
2269
m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2215
2270
2271
+ v = m_builder->addConstValue (4 );
2272
+ v = m_builder->addListItem (localList1.get (), v);
2273
+ m_builder->addFunctionCall (" test_print_string" , Compiler::StaticType::Void, { Compiler::StaticType::String }, { v });
2274
+
2275
+ // Local 2
2276
+ v = m_builder->addConstValue (-1 );
2277
+ v = m_builder->addListItem (localList2.get (), v);
2278
+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { v });
2279
+
2280
+ v = m_builder->addConstValue (2 );
2281
+ v = m_builder->addListItem (localList2.get (), v);
2282
+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { v });
2283
+
2284
+ // Local 3
2285
+ v = m_builder->addConstValue (-1 );
2286
+ v = m_builder->addListItem (localList3.get (), v);
2287
+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { v });
2288
+
2289
+ v = m_builder->addConstValue (2 );
2290
+ v = m_builder->addListItem (localList3.get (), v);
2291
+ m_builder->addFunctionCall (" test_print_number" , Compiler::StaticType::Void, { Compiler::StaticType::Number }, { v });
2292
+
2216
2293
static const std::string expected =
2217
2294
" 3\n "
2218
2295
" 1\n "
2296
+ " 0\n "
2297
+ " 0\n "
2219
2298
" Lorem\n "
2220
2299
" dolor\n "
2221
- " sit\n " ;
2300
+ " sit\n "
2301
+ " 0\n "
2302
+ " 0\n "
2303
+ " 0\n "
2304
+ " 0\n "
2305
+ " 0\n "
2306
+ " 0\n " ;
2222
2307
2223
2308
auto code = m_builder->finalize ();
2224
2309
Script script (&sprite, nullptr , nullptr );
@@ -2231,7 +2316,9 @@ TEST_F(LLVMCodeBuilderTest, GetListItem)
2231
2316
ASSERT_EQ (testing::internal::GetCapturedStdout (), expected);
2232
2317
2233
2318
ASSERT_EQ (globalList->toString (), " 1 test 3" );
2234
- ASSERT_EQ (localList->toString (), " Lorem ipsum dolor sit" );
2319
+ ASSERT_EQ (localList1->toString (), " Lorem ipsum dolor sit" );
2320
+ ASSERT_EQ (localList2->toString (), " -564.121 4257.4" );
2321
+ ASSERT_EQ (localList3->toString (), " true false" );
2235
2322
}
2236
2323
2237
2324
TEST_F (LLVMCodeBuilderTest, GetListSize)
0 commit comments