im bored.

This commit is contained in:
ManDude
2022-04-17 06:14:30 +01:00
parent d827db20b3
commit 070e957ce8
54 changed files with 275 additions and 282 deletions
+2 -2
View File
@@ -293,11 +293,11 @@ void FormRegressionTest::test_final_function(
settings.do_expressions = true;
auto test = make_function(code, ts, settings);
ASSERT_TRUE(test);
auto expected_form =
auto& expected_form =
pretty_print::get_pretty_printer_reader().read_from_string(expected, false).as_pair()->car;
ASSERT_TRUE(test->func.ir2.top_form);
auto final = final_defun_out(test->func, test->func.ir2.env, *dts);
auto actual_form =
auto& actual_form =
pretty_print::get_pretty_printer_reader().read_from_string(final, false).as_pair()->car;
if (expected_form != actual_form) {
printf("Got:\n%s\n\nExpected\n%s\n", pretty_print::to_string(actual_form).c_str(),
+3 -3
View File
@@ -21,9 +21,9 @@ class DataDecompTest : public ::testing::Test {
static void TearDownTestCase() { dts.reset(); }
void check_forms_equal(const std::string& actual, const std::string& expected) {
auto expected_form =
auto& expected_form =
pretty_print::get_pretty_printer_reader().read_from_string(expected, false).as_pair()->car;
auto actual_form =
auto& actual_form =
pretty_print::get_pretty_printer_reader().read_from_string(actual, false).as_pair()->car;
if (expected_form != actual_form) {
printf("Got:\n%s\n\nExpected\n%s\n", pretty_print::to_string(actual_form).c_str(),
@@ -405,4 +405,4 @@ TEST_F(DataDecompTest, ReverseArtExt) {
input.offset = 108;
result = dts->ts.reverse_field_multi_lookup(input);
EXPECT_EQ(result.results.at(0).tokens.at(2).print(), "type");
}
}
+2 -2
View File
@@ -348,14 +348,14 @@ TEST_F(WithGameTests, DebuggerMemoryMap) {
// we should have gkernel main segment
listener::MemoryMapEntry gk_main;
EXPECT_TRUE(mem_map.lookup("gkernel", MAIN_SEGMENT, &gk_main));
auto lookup_2 = mem_map.lookup(gk_main.start_addr + 12);
auto& lookup_2 = mem_map.lookup(gk_main.start_addr + 12);
EXPECT_TRUE(lookup_2.obj_name == "gkernel");
EXPECT_FALSE(lookup_2.empty);
EXPECT_EQ(lookup_2.seg_id, MAIN_SEGMENT);
}
TEST_F(WithGameTests, DebuggerDisassemble) {
auto di = shared_compiler->compiler.get_debugger().get_debug_info_for_object("gcommon");
auto& di = shared_compiler->compiler.get_debugger().get_debug_info_for_object("gcommon");
bool fail = false;
auto result = di.disassemble_all_functions(&fail, &shared_compiler->compiler.get_goos().reader);
// printf("Got\n%s\n", result.c_str());
+23 -23
View File
@@ -9,7 +9,7 @@ using namespace goos;
namespace {
Object read(const std::string& str) {
auto body = pretty_print::get_pretty_printer_reader().read_from_string(str).as_pair()->cdr;
auto& body = pretty_print::get_pretty_printer_reader().read_from_string(str).as_pair()->cdr;
EXPECT_TRUE(body.as_pair()->cdr.is_empty_list());
return body.as_pair()->car;
}
@@ -38,11 +38,11 @@ TEST(PrettyPrinter, ReadAgain) {
{"goal_src", "kernel", "gcommon.gc"});
// pretty print it
auto printed_gcommon = pretty_print::to_string(gcommon_code);
auto gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
auto& gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
auto printed_gcommon2 = pretty_print::to_string_v1(gcommon_code);
EXPECT_TRUE(gcommon_code == gcommon_code2);
}
@@ -54,11 +54,11 @@ TEST(PrettyPrinter, ReadAgainVeryShortLines) {
// pretty print it but with a very short line length. This looks terrible but will hopefully
// hit many of the cases for line breaking.
auto printed_gcommon = pretty_print::to_string(gcommon_code, 80);
auto gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
auto& gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
auto printed_gcommon2 = pretty_print::to_string_v1(gcommon_code);
EXPECT_TRUE(gcommon_code == gcommon_code2);
}
@@ -71,11 +71,11 @@ TEST(PrettyPrinter, DefunNoArgs) {
" (the-as symbol #f)\n"
" )";
auto obj = pretty_print::get_pretty_printer_reader()
.read_from_string(code)
.as_pair()
->cdr.as_pair()
->car;
auto& obj = pretty_print::get_pretty_printer_reader()
.read_from_string(code)
.as_pair()
->cdr.as_pair()
->car;
auto printed = pretty_print::to_string_v1(obj, 80);
EXPECT_EQ(printed,
@@ -93,17 +93,17 @@ TEST(PrettyPrinter2, Debugging) {
{"goal_src", "kernel", "gcommon.gc"});
// pretty print it
auto printed_gcommon = pretty_print::to_string(gcommon_code);
auto gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
auto& gcommon_code2 = pretty_print::get_pretty_printer_reader()
.read_from_string(printed_gcommon)
.as_pair()
->cdr.as_pair()
->car;
EXPECT_TRUE(gcommon_code == gcommon_code2);
}
namespace {
std::string pretty_print_v2(const std::string& str, int line_length = 110) {
auto obj =
auto& obj =
pretty_print::get_pretty_printer_reader().read_from_string(str).as_pair()->cdr.as_pair()->car;
return pretty_print::to_string(obj, line_length);
}
@@ -316,4 +316,4 @@ TEST(PrettyPrint2, AnotherBug) {
" (t9-2 vector-xz-normalize!)\n"
" )\n"
" )");
}
}
+4 -4
View File
@@ -345,10 +345,10 @@ TEST(GoosReader, FromFile) {
TEST(GoosReader, TextDb) {
// very specific to this particular test file, but whatever.
Reader reader;
auto result = reader.read_from_file({"test", "test_data", "test_reader_file0.gc"})
.as_pair()
->cdr.as_pair()
->car;
auto& result = reader.read_from_file({"test", "test_data", "test_reader_file0.gc"})
.as_pair()
->cdr.as_pair()
->car;
std::string expected = "test/test_data/test_reader_file0.gc:5\n(1 2 3 4)\n ^\n";
EXPECT_EQ(expected, reader.db.get_info_for(result));
}