This commit is contained in:
Andre Wagner
2026-05-01 16:39:49 -05:00
parent bebaed1998
commit 0bc40cc562
9 changed files with 147 additions and 18 deletions

View File

@@ -3,6 +3,7 @@
#include "../bytecode/bytecodeprototype.hh"
#include "../common/bytearray.hh"
#include "../bytecode/bytecode.hh"
#include "../assembler/assembler.hh"
#include "code.hh"
#include "stack.hh"
#include "vm.hh"
@@ -92,6 +93,28 @@ TEST(VM, BasicCode)
ASSERT_EQ(result, 5);
}
TEST(VM, SumIntegers)
{
ASSERT_EQ(VM().load_bytecode(as::Assembler(R"(
.func 0
pushi 2
pushi 3
sum
ret
)").assemble()).call(0).to_integer(-1), 5);
}
TEST(VM, SubtractIntegers)
{
ASSERT_EQ(VM().load_bytecode(as::Assembler(R"(
.func 0
pushi 2
pushi 3
sub
ret
)").assemble()).call(0).to_integer(-1), -1);
}
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);