Expressions #7
@@ -1,7 +1,6 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "../bytecode/bytecodeprototype.hh"
|
||||
#include "../common/bytearray.hh"
|
||||
#include "../bytecode/bytecode.hh"
|
||||
#include "../assembler/assembler.hh"
|
||||
#include "code.hh"
|
||||
@@ -93,6 +92,24 @@ TEST(VM, BasicCode)
|
||||
ASSERT_EQ(result, 5);
|
||||
}
|
||||
|
||||
TEST(VM, StackOperations)
|
||||
{
|
||||
auto run = [](std::string oper) {
|
||||
return VM().load_bytecode(as::Assembler(std::format(R"(
|
||||
.const
|
||||
0: 3.14
|
||||
1: "Hello world"
|
||||
.func 0
|
||||
{}
|
||||
ret
|
||||
)", oper)).assemble()).call(0);
|
||||
};
|
||||
|
||||
ASSERT_EQ(run("pushi 5000").to_integer(-1), 5000);
|
||||
ASSERT_EQ(run("pushi -5000").to_integer(-1), -5000);
|
||||
ASSERT_FLOAT_EQ(run("pushc 0").to_float(-1), 3.14f);
|
||||
}
|
||||
|
||||
TEST(VM, IntegerIntegerOperations)
|
||||
{
|
||||
auto test_op = [](int32_t op1, int32_t op2, std::string oper) {
|
||||
|
||||
Reference in New Issue
Block a user