@@ -1327,6 +1327,21 @@ unsigned int testFunction5(VirtualMachine *vm)
1327
1327
return 0 ;
1328
1328
}
1329
1329
1330
+ unsigned int testFunction6 (VirtualMachine *vm)
1331
+ {
1332
+ vm->addReturnValue (0 );
1333
+ vm->stop (true , false , false );
1334
+ return 1 ;
1335
+ }
1336
+
1337
+ unsigned int testFunction7 (VirtualMachine *vm)
1338
+ {
1339
+ vm->addReturnValue (0 );
1340
+ vm->stop (true , false , false );
1341
+ vm->reset ();
1342
+ return 1 ;
1343
+ }
1344
+
1330
1345
TEST (VirtualMachineTest, OP_EXEC)
1331
1346
{
1332
1347
static unsigned int bytecode[] = {
@@ -1518,18 +1533,41 @@ TEST(VirtualMachineTest, OP_WARP)
1518
1533
1519
1534
TEST (VirtualMachineTest, Reset)
1520
1535
{
1521
- static unsigned int bytecode[] = { OP_START, OP_NULL, OP_EXEC, 0 , OP_HALT };
1522
- static BlockFunc functions[] = { &testFunction3 };
1536
+ static unsigned int bytecode1[] = { OP_START, OP_NULL, OP_EXEC, 0 , OP_HALT };
1537
+ static unsigned int bytecode2[] = { OP_START, OP_NULL, OP_EXEC, 1 , OP_HALT };
1538
+ static BlockFunc functions[] = { &testFunction6, &testFunction7 };
1523
1539
1524
1540
VirtualMachine vm;
1525
- vm.setBytecode (bytecode );
1541
+ vm.setBytecode (bytecode1 );
1526
1542
vm.setFunctions (functions);
1543
+
1527
1544
vm.run ();
1528
1545
ASSERT_FALSE (vm.atEnd ());
1546
+ ASSERT_EQ (vm.registerCount (), 1 );
1529
1547
vm.reset ();
1548
+ ASSERT_EQ (vm.registerCount (), 0 );
1530
1549
ASSERT_FALSE (vm.atEnd ());
1531
1550
vm.run ();
1532
1551
ASSERT_FALSE (vm.atEnd ());
1533
1552
vm.run ();
1534
1553
ASSERT_TRUE (vm.atEnd ());
1554
+
1555
+ vm.reset ();
1556
+ ASSERT_FALSE (vm.atEnd ());
1557
+
1558
+ vm.setBytecode (bytecode2);
1559
+
1560
+ vm.run ();
1561
+ ASSERT_FALSE (vm.atEnd ());
1562
+ ASSERT_EQ (vm.registerCount (), 1 );
1563
+ vm.reset ();
1564
+ ASSERT_EQ (vm.registerCount (), 0 );
1565
+ ASSERT_FALSE (vm.atEnd ());
1566
+ vm.run ();
1567
+ ASSERT_FALSE (vm.atEnd ());
1568
+ vm.run ();
1569
+ ASSERT_TRUE (vm.atEnd ());
1570
+
1571
+ vm.reset ();
1572
+ ASSERT_FALSE (vm.atEnd ());
1535
1573
}
0 commit comments