Skip to content

Commit

Permalink
test: Extend tests for OperandStack
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Sep 16, 2020
1 parent f021126 commit 83db9f5
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions test/unittests/stack_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ TEST(operand_stack, small_with_locals)
EXPECT_EQ(stack.local(2).i64, 0xc2);
EXPECT_EQ(stack.local(3).i64, 0xc3);
EXPECT_EQ(stack.local(4).i64, 0xc4);

EXPECT_EQ(stack.pop().i64, 0xff);
EXPECT_EQ(stack.local(0).i64, 0xc0);
EXPECT_EQ(stack.local(1).i64, 0xc1);
EXPECT_EQ(stack.local(2).i64, 0xc2);
EXPECT_EQ(stack.local(3).i64, 0xc3);
EXPECT_EQ(stack.local(4).i64, 0xc4);
}

TEST(operand_stack, large)
Expand Down Expand Up @@ -241,9 +248,8 @@ TEST(operand_stack, large_with_locals)
stack.push(i);

EXPECT_EQ(stack.size(), max_height);
for (int expected = max_height - 1; expected >= 0; --expected)
EXPECT_EQ(stack.pop().i64, expected);
EXPECT_EQ(stack.size(), 0);
for (unsigned i = 0; i < max_height; ++i)
EXPECT_EQ(stack[i].i64, max_height - i - 1);

EXPECT_EQ(stack.local(0).i64, 0xa1);
EXPECT_EQ(stack.local(1).i64, 0xa2);
Expand All @@ -255,6 +261,13 @@ TEST(operand_stack, large_with_locals)
stack.local(i) = fizzy::Value{i};
for (unsigned i = 0; i < num_args + num_locals; ++i)
EXPECT_EQ(stack.local(i).i64, i);

for (int expected = max_height - 1; expected >= 0; --expected)
EXPECT_EQ(stack.pop().i64, expected);
EXPECT_EQ(stack.size(), 0);

for (unsigned i = 0; i < num_args + num_locals; ++i)
EXPECT_EQ(stack.local(i).i64, i);
}


Expand Down

0 comments on commit 83db9f5

Please sign in to comment.