Expressions #7
3
TODO.md
3
TODO.md
@@ -32,6 +32,9 @@ After some additional development:
|
||||
- [x] Assembler
|
||||
- [ ] VM execution
|
||||
- [ ] Stack operations (nil, integer, float, string, function)
|
||||
- [ ] Integer
|
||||
- [ ] Float
|
||||
- [ ] String
|
||||
- [ ] Expressions
|
||||
- [ ] Local/global variables
|
||||
- [ ] Functions
|
||||
|
||||
@@ -95,24 +95,18 @@ TEST(VM, BasicCode)
|
||||
|
||||
TEST(VM, SumIntegers)
|
||||
{
|
||||
ASSERT_EQ(VM().load_bytecode(as::Assembler(R"(
|
||||
auto test_op = [](int32_t op1, int32_t op2, std::string oper) {
|
||||
return VM().load_bytecode(as::Assembler(std::format(R"(
|
||||
.func 0
|
||||
pushi 2
|
||||
pushi 3
|
||||
sum
|
||||
pushi {}
|
||||
pushi {}
|
||||
{}
|
||||
ret
|
||||
)").assemble()).call(0).to_integer(-1), 5);
|
||||
}
|
||||
)", op1, op2, oper)).assemble()).call(0).to_integer(-1);
|
||||
};
|
||||
|
||||
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);
|
||||
ASSERT_EQ(test_op(2, 3, "sum"), 5);
|
||||
ASSERT_EQ(test_op(2, 3, "sub"), -1);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
||||
Reference in New Issue
Block a user