mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-29 03:07:49 +01:00
simple gc
This commit is contained in:
@@ -91,7 +91,6 @@ TEST(VMTest, SimpleFunction) {
|
||||
}
|
||||
ssout.flush();
|
||||
EXPECT_EQ(ssout.str(), "3");
|
||||
|
||||
}
|
||||
|
||||
TEST(VMTest, RecursiveFunction) {
|
||||
@@ -171,7 +170,7 @@ TEST(VMTest, RecursiveFunction) {
|
||||
vm.push(fibcallfn, vm.makeCell<ConsCell>(vm.makeCell<IntCell>(1), vm.makeCell<IntCell>(1)));
|
||||
vm.push(fibcallfn, vm.makeCell<CommandCell>(CommandCell::CommandNum::LD));
|
||||
vm.push(fibcallfn, vm.makeCell<CommandCell>(CommandCell::CommandNum::CONS));
|
||||
vm.push(fibcallfn, vm.makeCell<IntCell>(20));
|
||||
vm.push(fibcallfn, vm.makeCell<IntCell>(10));
|
||||
vm.push(fibcallfn, vm.makeCell<CommandCell>(CommandCell::CommandNum::LDC));
|
||||
vm.push(fibcallfn, vm.makeCell<CommandCell>(CommandCell::CommandNum::NIL));
|
||||
|
||||
@@ -236,6 +235,5 @@ TEST(VMTest, RecursiveFunction) {
|
||||
vm.run();
|
||||
}
|
||||
ssout.flush();
|
||||
EXPECT_EQ(ssout.str(), "2358 6765");
|
||||
|
||||
EXPECT_EQ(ssout.str(), "2358 55");
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "VM.h"
|
||||
#include "Parser.h"
|
||||
#include "VM.h"
|
||||
|
||||
TEST(VMWithParserTest, BasicHello) {
|
||||
std::stringstream ssin;
|
||||
@@ -50,9 +50,9 @@ TEST(VMWithParserTest, RecFunction) {
|
||||
VM vm(ssin, ssout);
|
||||
Parser parser(vm);
|
||||
parser.loadSecd(
|
||||
"( DUM NIL LDF ( LD ( 1 . 1 ) SEL ( LD ( 1 . 1 ) LDC -1 ADD SEL ( NIL LD ( 1 . 1 ) LDC -1 ADD CONS LD ( 2 . 1 ) AP NIL LD ( 1 . 1 ) LDC -2 ADD CONS LD ( 2 . 1 ) AP ADD JOIN ) ( LDC 1 JOIN ) JOIN ) ( LDC 0 JOIN ) RET ) CONS LDF ( NIL LDC 20 CONS LD ( 1 . 1 ) AP RET ) RAP PUTNUM STOP )");
|
||||
"( DUM NIL LDF ( LD ( 1 . 1 ) SEL ( LD ( 1 . 1 ) LDC -1 ADD SEL ( NIL LD ( 1 . 1 ) LDC -1 ADD CONS LD ( 2 . 1 ) AP NIL LD ( 1 . 1 ) LDC -2 ADD CONS LD ( 2 . 1 ) AP ADD JOIN ) ( LDC 1 JOIN ) JOIN ) ( LDC 0 JOIN ) RET ) CONS LDF ( NIL LDC 10 CONS LD ( 1 . 1 ) AP RET ) RAP PUTNUM STOP )");
|
||||
vm.run();
|
||||
}
|
||||
ssout.flush();
|
||||
EXPECT_EQ(ssout.str(), "6765");
|
||||
EXPECT_EQ(ssout.str(), "55");
|
||||
}
|
||||
Reference in New Issue
Block a user