Skip to content

Commit

Permalink
#111: test
Browse files Browse the repository at this point in the history
  • Loading branch information
levBagryansky committed Jun 14, 2024
1 parent 47ef30f commit 48c2f64
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/ChaiVM/interpreter/garbage-collector-test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
#include <gtest/gtest.h>
#include "executor-test-fixture.hpp"

using namespace chai;
using namespace interpreter;
using namespace utils::fileformat;

TEST_F(ExecutorTest, CollectRoots) {
//
auto bar_klass = chaiFile_.registerKlass("Bar");
chaiFile_.addField(bar_klass, "bar.num1", 0U, FieldTag::I64);
chaiFile_.addField(bar_klass, "bar.num2", 0U, FieldTag::I64);
chaiFile_.addField(bar_klass, "bar.num3", 0U, FieldTag::I64);
chaiFile_.addField(bar_klass, "bar.num4", 0U, FieldTag::I64);
constexpr int64_t threshold = 1000;
//Immidiate zero_imm = chaiFile_.addConst(std::make_unique<ConstI64>(0));
Immidiate one_imm = chaiFile_.addConst(std::make_unique<ConstI64>(1));
Immidiate threshold_imm = chaiFile_.addConst(std::make_unique<ConstI64>(threshold));

load<Ldia>(one_imm);
load<Star>(R1);
load<Ldia>(threshold_imm);
load<Star>(R10);
load<AllocRef>(bar_klass);
load<Ldra>(R2);
load<Add>(R1);
load<Star>(R2);
load<If_icmplt>(R10, static_cast<Immidiate>(-4));
load<Ret>();
update();
exec_.run();
EXPECT_EQ(exec_.acc(), threshold);
}

0 comments on commit 48c2f64

Please sign in to comment.