mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-29 03:07:49 +01:00
fixup test options
This commit is contained in:
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
Logger &Logger::get() {
|
Logger &Logger::get() {
|
||||||
// Ensure proper destruction order for tests
|
|
||||||
Options::get();
|
|
||||||
static Logger logger;
|
static Logger logger;
|
||||||
return logger;
|
return logger;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,9 +197,6 @@ void MemoryContext::gc_thread_entry() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemoryContext &MemoryContext::get() {
|
MemoryContext &MemoryContext::get() {
|
||||||
// Ensure proper destruction order for tests
|
|
||||||
Options::get();
|
|
||||||
Logger::get();
|
|
||||||
static MemoryContext mc;
|
static MemoryContext mc;
|
||||||
return mc;
|
return mc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,22 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "MemoryContext.h"
|
#include "MemoryContext.h"
|
||||||
|
class Environment : public ::testing::Environment {
|
||||||
|
public:
|
||||||
|
~Environment() override {}
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
Options::set_int("cell_limit", 60000);
|
||||||
|
Logger::set_level("MemoryContext", Logger::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
Options::reset();
|
||||||
|
Logger::reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
testing::Environment *const env = testing::AddGlobalTestEnvironment(new Environment);
|
||||||
|
|
||||||
TEST(GCTest, GCTest) {
|
TEST(GCTest, GCTest) {
|
||||||
|
|
||||||
@@ -19,6 +35,7 @@ TEST(GCTest, GCTest) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
{
|
{
|
||||||
Handle c = Handle::cons(nullptr, nullptr);
|
Handle c = Handle::cons(nullptr, nullptr);
|
||||||
@@ -31,6 +48,7 @@ TEST(GCTest, GCTest) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +63,7 @@ TEST(GCTest, GCTestAppend) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
TEST(GCTest, GCTestPop) {
|
TEST(GCTest, GCTestPop) {
|
||||||
@@ -63,6 +82,7 @@ TEST(GCTest, GCTestPop) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +100,7 @@ TEST(GCTest, GCTestAppend2) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,5 +119,6 @@ TEST(GCTest, GCTestAppend3) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "VM.h"
|
#include "VM.h"
|
||||||
|
class Environment : public ::testing::Environment {
|
||||||
|
public:
|
||||||
|
~Environment() override {}
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
Options::set_int("cell_limit", 1000);
|
||||||
|
Logger::set_level("MemoryContext", Logger::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
Options::reset();
|
||||||
|
Logger::reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
testing::Environment *const env = testing::AddGlobalTestEnvironment(new Environment);
|
||||||
|
|
||||||
using namespace Command;
|
using namespace Command;
|
||||||
TEST(VMTest, BasicHello) {
|
TEST(VMTest, BasicHello) {
|
||||||
|
|||||||
@@ -3,6 +3,24 @@
|
|||||||
#include "Parser.h"
|
#include "Parser.h"
|
||||||
#include "VM.h"
|
#include "VM.h"
|
||||||
|
|
||||||
|
class Environment : public ::testing::Environment {
|
||||||
|
public:
|
||||||
|
~Environment() override {}
|
||||||
|
|
||||||
|
void SetUp() override {
|
||||||
|
Options::set_int("cell_limit", 2000);
|
||||||
|
Logger::set_level("MemoryContext", Logger::INFO);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TearDown() override {
|
||||||
|
Options::reset();
|
||||||
|
Logger::reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
testing::Environment *const env = testing::AddGlobalTestEnvironment(new Environment);
|
||||||
|
|
||||||
|
|
||||||
TEST(VMWithParserTest, BasicHello) {
|
TEST(VMWithParserTest, BasicHello) {
|
||||||
std::stringstream ssin;
|
std::stringstream ssin;
|
||||||
std::stringstream ssout;
|
std::stringstream ssout;
|
||||||
@@ -63,6 +81,7 @@ TEST(VMWithParserTest, RecFunction) {
|
|||||||
}
|
}
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "6765");
|
EXPECT_EQ(ssout.str(), "6765");
|
||||||
|
|||||||
Reference in New Issue
Block a user