mirror of
https://github.com/usatiuk/psil.git
synced 2025-10-28 18:57:48 +01:00
Fix log tags, change EXPECT_ to ASSERT_ in tests
This commit is contained in:
47
.idea/codeStyles/Project.xml
generated
47
.idea/codeStyles/Project.xml
generated
@@ -1,47 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<code_scheme name="Project" version="173">
|
|
||||||
<Objective-C-extensions>
|
|
||||||
<rules>
|
|
||||||
<rule entity="NAMESPACE" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="MACRO" visibility="ANY" specifier="ANY" prefix="" style="SCREAMING_SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="ENUM" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="ENUMERATOR" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="TYPEDEF" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="UNION" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="_" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="_" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="GLOBAL_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="GLOBAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SCREAMING_SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="PARAMETER" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="LOCAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
</rules>
|
|
||||||
</Objective-C-extensions>
|
|
||||||
<Objective-C-extensions>
|
|
||||||
<rules>
|
|
||||||
<rule entity="NAMESPACE" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="MACRO" visibility="ANY" specifier="ANY" prefix="" style="SCREAMING_SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="ENUM" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="ENUMERATOR" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="TYPEDEF" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="UNION" visibility="ANY" specifier="ANY" prefix="" style="PASCAL_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT_MEMBER_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="CLASS_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="_" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="STRUCT_MEMBER_FIELD" visibility="ANY" specifier="ANY" prefix="_" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="GLOBAL_FUNCTION" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="GLOBAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SCREAMING_SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="PARAMETER" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
<rule entity="LOCAL_VARIABLE" visibility="ANY" specifier="ANY" prefix="" style="SNAKE_CASE" suffix="" />
|
|
||||||
</rules>
|
|
||||||
</Objective-C-extensions>
|
|
||||||
<clangFormatSettings>
|
|
||||||
<option name="ENABLED" value="true" />
|
|
||||||
</clangFormatSettings>
|
|
||||||
</code_scheme>
|
|
||||||
</component>
|
|
||||||
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,5 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="CMakePythonSetting">
|
||||||
|
<option name="pythonIntegrationState" value="YES" />
|
||||||
|
</component>
|
||||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||||
<component name="CidrRootsConfiguration">
|
<component name="CidrRootsConfiguration">
|
||||||
<excludeRoots>
|
<excludeRoots>
|
||||||
|
|||||||
@@ -14,12 +14,15 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class Logger {
|
class Logger
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
Logger();
|
Logger();
|
||||||
|
|
||||||
enum LogLevel { ALWAYS = 0, ERROR = 1, INFO = 2, DEBUG = 3, TRACE = 4 };
|
enum LogLevel { ALWAYS = 0, ERROR = 1, INFO = 2, DEBUG = 3, TRACE = 4 };
|
||||||
|
|
||||||
enum LogTag { MemoryContext, VM, Compiler, LogTagMax };
|
enum LogTag { MemoryContext, VM, Compiler, LogTagMax };
|
||||||
|
|
||||||
static void log(LogTag tag, const std::string& what, int level);
|
static void log(LogTag tag, const std::string& what, int level);
|
||||||
static void log(LogTag tag, const std::function<void(std::ostream&)>& fn, int level);
|
static void log(LogTag tag, const std::function<void(std::ostream&)>& fn, int level);
|
||||||
|
|
||||||
@@ -40,6 +43,7 @@ public:
|
|||||||
static Logger& get();
|
static Logger& get();
|
||||||
|
|
||||||
static LogTag str_to_tag(const std::string& str) { return _str_to_tag.at(str); }
|
static LogTag str_to_tag(const std::string& str) { return _str_to_tag.at(str); }
|
||||||
|
static const std::string& tag_to_str(LogTag tag) { return _tag_to_str.at(tag); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<LogLevel, LogTag::LogTagMax> _levels{};
|
std::array<LogLevel, LogTag::LogTagMax> _levels{};
|
||||||
@@ -51,6 +55,12 @@ private:
|
|||||||
{"MemoryContext", MemoryContext},
|
{"MemoryContext", MemoryContext},
|
||||||
{"Compiler", Compiler},
|
{"Compiler", Compiler},
|
||||||
};
|
};
|
||||||
|
static inline std::unordered_map<LogTag, std::string> _tag_to_str{
|
||||||
|
{VM, "VM"},
|
||||||
|
{MemoryContext, "MemoryContext"},
|
||||||
|
{Compiler, "Compiler"},
|
||||||
|
};
|
||||||
|
|
||||||
std::chrono::time_point<std::chrono::high_resolution_clock> _start_time = std::chrono::high_resolution_clock::now();
|
std::chrono::time_point<std::chrono::high_resolution_clock> _start_time = std::chrono::high_resolution_clock::now();
|
||||||
std::reference_wrapper<std::ostream> _out = std::cout;
|
std::reference_wrapper<std::ostream> _out = std::cout;
|
||||||
std::reference_wrapper<std::ostream> _out_err = std::cerr;
|
std::reference_wrapper<std::ostream> _out_err = std::cerr;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
|
|
||||||
Logger &Logger::get() {
|
Logger &Logger::get() {
|
||||||
static Logger logger;
|
static Logger logger;
|
||||||
return logger;
|
return logger;
|
||||||
@@ -23,11 +24,10 @@ void Logger::log(LogTag tag, const std::string &what, int level) {
|
|||||||
std::chrono::duration_cast<std::chrono::milliseconds>(now - get()._start_time).count()) /
|
std::chrono::duration_cast<std::chrono::milliseconds>(now - get()._start_time).count()) /
|
||||||
1000.0
|
1000.0
|
||||||
<< "s]"
|
<< "s]"
|
||||||
<< "[" << tag << "][" << get()._level_names.at(level) << "] " << what << '\n';
|
<< "[" << tag_to_str(tag) << "][" << get()._level_names.at(level) << "] " << what << '\n';
|
||||||
|
|
||||||
if (level == 1) get()._out_err.get() << out.str();
|
if (level == 1) get()._out_err.get() << out.str();
|
||||||
else
|
else get()._out.get() << out.str();
|
||||||
get()._out.get() << out.str();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ TEST(CompilerTest, BasicHello) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "3\n");
|
ASSERT_EQ(ssout.str(), "3\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, BasicLet) {
|
TEST(CompilerTest, BasicLet) {
|
||||||
@@ -54,7 +54,7 @@ TEST(CompilerTest, BasicLet) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1\n");
|
ASSERT_EQ(ssout.str(), "1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, BasicFn) {
|
TEST(CompilerTest, BasicFn) {
|
||||||
@@ -69,7 +69,7 @@ TEST(CompilerTest, BasicFn) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "5\n");
|
ASSERT_EQ(ssout.str(), "5\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, BasicFn2) {
|
TEST(CompilerTest, BasicFn2) {
|
||||||
@@ -84,7 +84,7 @@ TEST(CompilerTest, BasicFn2) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "-1\n");
|
ASSERT_EQ(ssout.str(), "-1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, MultiLet) {
|
TEST(CompilerTest, MultiLet) {
|
||||||
@@ -109,7 +109,7 @@ TEST(CompilerTest, MultiLet) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "-1\n1\n");
|
ASSERT_EQ(ssout.str(), "-1\n1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,8 +125,9 @@ TEST(CompilerTest, BasicFnIfT) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1\n");
|
ASSERT_EQ(ssout.str(), "1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, BasicFnIfF) {
|
TEST(CompilerTest, BasicFnIfF) {
|
||||||
std::stringstream ssin;
|
std::stringstream ssin;
|
||||||
std::stringstream ssout;
|
std::stringstream ssout;
|
||||||
@@ -139,8 +140,9 @@ TEST(CompilerTest, BasicFnIfF) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "2\n");
|
ASSERT_EQ(ssout.str(), "2\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, RecursiveFn) {
|
TEST(CompilerTest, RecursiveFn) {
|
||||||
std::stringstream ssin;
|
std::stringstream ssin;
|
||||||
std::stringstream ssout;
|
std::stringstream ssout;
|
||||||
@@ -154,7 +156,7 @@ TEST(CompilerTest, RecursiveFn) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "55\n");
|
ASSERT_EQ(ssout.str(), "55\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefine) {
|
TEST(CompilerTest, GlobalDefine) {
|
||||||
@@ -169,7 +171,7 @@ TEST(CompilerTest, GlobalDefine) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1\n");
|
ASSERT_EQ(ssout.str(), "1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -185,7 +187,7 @@ TEST(CompilerTest, GlobalDefineFn) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "5\n");
|
ASSERT_EQ(ssout.str(), "5\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefineFnQuote) {
|
TEST(CompilerTest, GlobalDefineFnQuote) {
|
||||||
@@ -200,7 +202,7 @@ TEST(CompilerTest, GlobalDefineFnQuote) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "(1 2)\n");
|
ASSERT_EQ(ssout.str(), "(1 2)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefineFnCar) {
|
TEST(CompilerTest, GlobalDefineFnCar) {
|
||||||
@@ -216,7 +218,7 @@ TEST(CompilerTest, GlobalDefineFnCar) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1\n2\n");
|
ASSERT_EQ(ssout.str(), "1\n2\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefineFnEq) {
|
TEST(CompilerTest, GlobalDefineFnEq) {
|
||||||
@@ -241,7 +243,7 @@ TEST(CompilerTest, GlobalDefineFnEq) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1\n1\n1\n1\n");
|
ASSERT_EQ(ssout.str(), "1\n1\n1\n1\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefineFnMulti) {
|
TEST(CompilerTest, GlobalDefineFnMulti) {
|
||||||
@@ -257,7 +259,7 @@ TEST(CompilerTest, GlobalDefineFnMulti) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "6\n");
|
ASSERT_EQ(ssout.str(), "6\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(CompilerTest, GlobalDefineFnMultiTwo) {
|
TEST(CompilerTest, GlobalDefineFnMultiTwo) {
|
||||||
@@ -273,7 +275,7 @@ TEST(CompilerTest, GlobalDefineFnMultiTwo) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "0\n");
|
ASSERT_EQ(ssout.str(), "0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -293,5 +295,5 @@ TEST(CompilerTest, GlobalDefineFnRec) {
|
|||||||
Options::set<bool>("command_strs", true);
|
Options::set<bool>("command_strs", true);
|
||||||
Logger::set_level(Logger::VM, Logger::DEBUG);
|
Logger::set_level(Logger::VM, Logger::DEBUG);
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "6765\n");
|
ASSERT_EQ(ssout.str(), "6765\n");
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "MemoryContext.h"
|
#include "MemoryContext.h"
|
||||||
|
|
||||||
class Environment : public ::testing::Environment {
|
class Environment : public ::testing::Environment {
|
||||||
public:
|
public:
|
||||||
~Environment() override {}
|
~Environment() override {}
|
||||||
@@ -30,26 +31,26 @@ TEST(GCTest, GCTest) {
|
|||||||
c.append(Handle::makeNumCell(1));
|
c.append(Handle::makeNumCell(1));
|
||||||
c.append(Handle::makeNumCell(2));
|
c.append(Handle::makeNumCell(2));
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(c.car().val(), 1);
|
ASSERT_EQ(c.car().val(), 1);
|
||||||
EXPECT_EQ(c.cdr().car().val(), 2);
|
ASSERT_EQ(c.cdr().car().val(), 2);
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
{
|
{
|
||||||
Handle c = Handle::cons(nullptr, nullptr);
|
Handle c = Handle::cons(nullptr, nullptr);
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
c.push(Handle::makeNumCell(1));
|
c.push(Handle::makeNumCell(1));
|
||||||
c.push(Handle::makeNumCell(2));
|
c.push(Handle::makeNumCell(2));
|
||||||
MemoryContext::get().request_gc_and_wait();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(c.car().val(), 2);
|
ASSERT_EQ(c.car().val(), 2);
|
||||||
EXPECT_EQ(c.cdr().car().val(), 1);
|
ASSERT_EQ(c.cdr().car().val(), 1);
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GCTest, GCTestAppend) {
|
TEST(GCTest, GCTestAppend) {
|
||||||
@@ -59,13 +60,14 @@ TEST(GCTest, GCTestAppend) {
|
|||||||
MemoryContext::get().request_gc();
|
MemoryContext::get().request_gc();
|
||||||
c.append(Handle::makeNumCell(1));
|
c.append(Handle::makeNumCell(1));
|
||||||
MemoryContext::get().request_gc();
|
MemoryContext::get().request_gc();
|
||||||
EXPECT_EQ(c.car().val(), 1);
|
ASSERT_EQ(c.car().val(), 1);
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GCTest, GCTestPop) {
|
TEST(GCTest, GCTestPop) {
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -77,13 +79,13 @@ TEST(GCTest, GCTestPop) {
|
|||||||
}
|
}
|
||||||
for (int i = test_size - 1; i >= 0; i--) {
|
for (int i = test_size - 1; i >= 0; i--) {
|
||||||
MemoryContext::get().request_gc();
|
MemoryContext::get().request_gc();
|
||||||
EXPECT_EQ(i, c.pop().val());
|
ASSERT_EQ(i, c.pop().val());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GCTest, GCTestAppend2) {
|
TEST(GCTest, GCTestAppend2) {
|
||||||
@@ -96,12 +98,12 @@ TEST(GCTest, GCTestAppend2) {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < test_size; i++) {
|
for (int i = 0; i < test_size; i++) {
|
||||||
MemoryContext::get().request_gc();
|
MemoryContext::get().request_gc();
|
||||||
EXPECT_EQ(i, c.pop().val());
|
ASSERT_EQ(i, c.pop().val());
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(GCTest, GCTestAppend3) {
|
TEST(GCTest, GCTestAppend3) {
|
||||||
@@ -114,11 +116,11 @@ TEST(GCTest, GCTestAppend3) {
|
|||||||
MemoryContext::get().request_gc();
|
MemoryContext::get().request_gc();
|
||||||
Handle n = c.cdr();
|
Handle n = c.cdr();
|
||||||
c.setcdr(nullptr);
|
c.setcdr(nullptr);
|
||||||
EXPECT_EQ(n.car().val(), 2);
|
ASSERT_EQ(n.car().val(), 2);
|
||||||
EXPECT_EQ(c.car().val(), 1);
|
ASSERT_EQ(c.car().val(), 1);
|
||||||
}
|
}
|
||||||
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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
#include "VM.h"
|
#include "VM.h"
|
||||||
|
|
||||||
class Environment : public ::testing::Environment {
|
class Environment : public ::testing::Environment {
|
||||||
public:
|
public:
|
||||||
~Environment() override {}
|
~Environment() override {}
|
||||||
@@ -36,7 +37,7 @@ TEST(VMTest, BasicHello) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "h");
|
ASSERT_EQ(ssout.str(), "h");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: maybe rewrite it all...
|
//TODO: maybe rewrite it all...
|
||||||
@@ -84,7 +85,7 @@ TEST(VMTest, BasicHello) {
|
|||||||
// vm.run();
|
// vm.run();
|
||||||
// }
|
// }
|
||||||
// ssout.flush();
|
// ssout.flush();
|
||||||
// EXPECT_EQ(ssout.str(), "14");
|
// ASSERT_EQ(ssout.str(), "14");
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//TEST(VMTest, SimpleFunction) {
|
//TEST(VMTest, SimpleFunction) {
|
||||||
@@ -112,7 +113,7 @@ TEST(VMTest, BasicHello) {
|
|||||||
// vm.run();
|
// vm.run();
|
||||||
// }
|
// }
|
||||||
// ssout.flush();
|
// ssout.flush();
|
||||||
// EXPECT_EQ(ssout.str(), "3");
|
// ASSERT_EQ(ssout.str(), "3");
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//TEST(VMTest, RecursiveFunction) {
|
//TEST(VMTest, RecursiveFunction) {
|
||||||
@@ -257,5 +258,5 @@ TEST(VMTest, BasicHello) {
|
|||||||
//vm.run();
|
//vm.run();
|
||||||
//}
|
//}
|
||||||
//ssout.flush();
|
//ssout.flush();
|
||||||
//EXPECT_EQ(ssout.str(), "2358 55");
|
//ASSERT_EQ(ssout.str(), "2358 55");
|
||||||
//}
|
//}
|
||||||
@@ -33,7 +33,7 @@ TEST(VMWithParserTest, BasicHello) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "h");
|
ASSERT_EQ(ssout.str(), "h");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VMWithParserTest, BasicBranch) {
|
TEST(VMWithParserTest, BasicBranch) {
|
||||||
@@ -49,7 +49,7 @@ TEST(VMWithParserTest, BasicBranch) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "1040");
|
ASSERT_EQ(ssout.str(), "1040");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VMWithParserTest, BasicFunction) {
|
TEST(VMWithParserTest, BasicFunction) {
|
||||||
@@ -64,7 +64,7 @@ TEST(VMWithParserTest, BasicFunction) {
|
|||||||
vm.run();
|
vm.run();
|
||||||
}
|
}
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "3");
|
ASSERT_EQ(ssout.str(), "3");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VMWithParserTest, RecFunction) {
|
TEST(VMWithParserTest, RecFunction) {
|
||||||
@@ -85,7 +85,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();
|
MemoryContext::get().request_gc_and_wait();
|
||||||
EXPECT_EQ(MemoryContext::get().cell_count(), 0);
|
ASSERT_EQ(MemoryContext::get().cell_count(), 0);
|
||||||
ssout.flush();
|
ssout.flush();
|
||||||
EXPECT_EQ(ssout.str(), "6765");
|
ASSERT_EQ(ssout.str(), "6765");
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user