Skip to content

Commit 1719c4b

Browse files
committed
Add test for #317
1 parent 344636b commit 1719c4b

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/virtual_machine/virtual_machine_test.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,33 @@ TEST(VirtualMachineTest, OP_FOREVER_LOOP)
254254
TEST(VirtualMachineTest, OP_REPEAT_LOOP)
255255
{
256256
static unsigned int bytecode[] = { OP_START, OP_CONST, 0, OP_REPEAT_LOOP, OP_CONST, 1, OP_PRINT, OP_LOOP_END, OP_HALT };
257-
static Value constValues[] = { 3, "test" };
257+
static Value constValues1[] = { 3, "test" };
258+
static Value constValues2[] = { 4.5, "test" };
259+
static Value constValues3[] = { 4.2, "test" };
258260

259261
EngineMock engineMock;
260262
VirtualMachine vm(nullptr, &engineMock, nullptr);
261263
vm.setBytecode(bytecode);
262-
vm.setConstValues(constValues);
264+
vm.setConstValues(constValues1);
263265
testing::internal::CaptureStdout();
264266
vm.run();
265267
ASSERT_EQ(testing::internal::GetCapturedStdout(), "test\ntest\ntest\n");
266268
ASSERT_EQ(vm.registerCount(), 0);
269+
270+
// For #317
271+
vm.setConstValues(constValues2);
272+
testing::internal::CaptureStdout();
273+
vm.reset();
274+
vm.run();
275+
ASSERT_EQ(testing::internal::GetCapturedStdout(), "test\ntest\ntest\ntest\ntest\n");
276+
ASSERT_EQ(vm.registerCount(), 0);
277+
278+
vm.setConstValues(constValues3);
279+
testing::internal::CaptureStdout();
280+
vm.reset();
281+
vm.run();
282+
ASSERT_EQ(testing::internal::GetCapturedStdout(), "test\ntest\ntest\ntest\n");
283+
ASSERT_EQ(vm.registerCount(), 0);
267284
}
268285

269286
TEST(VirtualMachineTest, OP_REPEAT_LOOP_INDEX)

0 commit comments

Comments
 (0)