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