@@ -1356,8 +1356,8 @@ TEST_F(SensingBlocksTest, Of)
1356
1356
1357
1357
compiler.init ();
1358
1358
1359
- EXPECT_CALL (m_engineMock, findTarget (" Sprite2" )).Times ( 9 ). WillRepeatedly (Return (6 ));
1360
- EXPECT_CALL (m_engineMock, findTarget (" _stage_" )).Times ( 5 ). WillRepeatedly (Return (0 ));
1359
+ EXPECT_CALL (m_engineMock, findTarget (" Sprite2" )).WillRepeatedly (Return (6 ));
1360
+ EXPECT_CALL (m_engineMock, findTarget (" _stage_" )).WillRepeatedly (Return (0 ));
1361
1361
1362
1362
EXPECT_CALL (m_engineMock, functionIndex (&SensingBlocks::xPositionOfSpriteByIndex)).WillOnce (Return (0 ));
1363
1363
compiler.setBlock (block1);
@@ -1444,21 +1444,25 @@ TEST_F(SensingBlocksTest, Of)
1444
1444
auto v2 = std::make_shared<Variable>(" var2" , " some variable" );
1445
1445
stage.addVariable (v1);
1446
1446
stage.addVariable (v2);
1447
+ EXPECT_CALL (m_engineMock, functionIndex (&SensingBlocks::variableOfTargetByIndex)).WillOnce (Return (19 ));
1447
1448
EXPECT_CALL (m_engineMock, targetAt (0 )).WillOnce (Return (&stage));
1448
1449
compiler.setBlock (block21);
1449
1450
SensingBlocks::compileOf (&compiler);
1450
1451
1452
+ EXPECT_CALL (m_engineMock, functionIndex (&SensingBlocks::variableOfTargetByIndex)).WillOnce (Return (19 ));
1451
1453
EXPECT_CALL (m_engineMock, targetAt (0 )).WillOnce (Return (&stage));
1452
1454
compiler.setBlock (block22);
1453
1455
SensingBlocks::compileOf (&compiler);
1454
1456
1455
1457
Sprite sprite;
1456
1458
auto v3 = std::make_shared<Variable>(" var3" , " some variable" );
1457
1459
sprite.addVariable (v3);
1460
+ EXPECT_CALL (m_engineMock, functionIndex (&SensingBlocks::variableOfTargetByIndex)).WillOnce (Return (19 ));
1458
1461
EXPECT_CALL (m_engineMock, targetAt (6 )).WillOnce (Return (&sprite));
1459
1462
compiler.setBlock (block23);
1460
1463
SensingBlocks::compileOf (&compiler);
1461
1464
1465
+ EXPECT_CALL (m_engineMock, functionIndex (&SensingBlocks::variableOfTargetByIndex)).WillOnce (Return (19 ));
1462
1466
EXPECT_CALL (m_engineMock, targetAt (6 )).WillOnce (Return (&sprite));
1463
1467
compiler.setBlock (block24);
1464
1468
SensingBlocks::compileOf (&compiler);
@@ -1547,21 +1551,37 @@ TEST_F(SensingBlocksTest, Of)
1547
1551
vm::OP_NULL,
1548
1552
vm::OP_EXEC,
1549
1553
17 ,
1550
- vm::OP_READ_VAR,
1551
- 0 ,
1554
+ vm::OP_CONST,
1555
+ 10 ,
1556
+ vm::OP_CONST,
1557
+ 11 ,
1558
+ vm::OP_EXEC,
1559
+ 19 ,
1552
1560
vm::OP_NULL,
1553
- vm::OP_READ_VAR,
1554
- 1 ,
1561
+ vm::OP_CONST,
1562
+ 12 ,
1563
+ vm::OP_EXEC,
1564
+ 19 ,
1565
+ vm::OP_CONST,
1566
+ 13 ,
1567
+ vm::OP_CONST,
1568
+ 14 ,
1569
+ vm::OP_EXEC,
1570
+ 19 ,
1555
1571
vm::OP_NULL,
1556
1572
vm::OP_CONST,
1557
- 10 ,
1573
+ 15 ,
1574
+ vm::OP_EXEC,
1575
+ 19 ,
1576
+ vm::OP_CONST,
1577
+ 16 ,
1558
1578
vm::OP_NULL,
1559
1579
vm::OP_EXEC,
1560
1580
18 ,
1561
1581
vm::OP_NULL,
1562
1582
vm::OP_HALT }));
1563
- ASSERT_EQ (compiler.constValues (), std::vector<Value>({ 6 , 6 , 6 , 6 , 6 , 6 , 6 , 0 , 0 , 0 , " some variable" }));
1564
- ASSERT_EQ (compiler.variables (), std::vector<Variable *>({ v2. get (), v3. get () } ));
1583
+ ASSERT_EQ (compiler.constValues (), std::vector<Value>({ 6 , 6 , 6 , 6 , 6 , 6 , 6 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 6 , 6 , " some variable" }));
1584
+ ASSERT_TRUE (compiler.variables (). empty ( ));
1565
1585
}
1566
1586
1567
1587
TEST_F (SensingBlocksTest, XPositionOfSprite)
0 commit comments