From d5d908dda655c791329563522faad42d7e4ee618 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 12 Jul 2015 00:11:56 -0700 Subject: 1766 --- html/072scenario_screen.cc.html | 42 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'html/072scenario_screen.cc.html') diff --git a/html/072scenario_screen.cc.html b/html/072scenario_screen.cc.html index f5210f0b..5df91b60 100644 --- a/html/072scenario_screen.cc.html +++ b/html/072scenario_screen.cc.html @@ -106,6 +106,7 @@ scenario screen-in-scenario-color [ ] :(scenario screen_in_scenario_error) +% Scenario_testing_scenario = true; % Hide_warnings = true; scenario screen-in-scenario-error [ assume-screen 5:literal/width, 3:literal/height @@ -122,6 +123,7 @@ scenario screen-in-scenario-error [ +warn: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a') :(scenario screen_in_scenario_color_error) +% Scenario_testing_scenario = true; % Hide_warnings = true; # screen-should-contain can check unicode characters in the fake screen scenario screen-in-scenario-color [ @@ -144,6 +146,7 @@ if (s == "screen" :(scenarios run) :(scenario convert_names_does_not_warn_when_mixing_special_names_and_numeric_locations) +% Scenario_testing_scenario = true; % Hide_warnings = true; recipe main [ screen:number <- copy 1:number @@ -178,21 +181,21 @@ Name[r]["screen"] = SCREEN// `screen:address <- new-fake-screen width, height` //? cout << "before: " << curr.to_string() << '\n'; //? 1 if (curr.name == "assume-screen") { - curr.operation = Recipe_number["new-fake-screen"]; + curr.operation = Recipe_ordinal["new-fake-screen"]; curr.name = "new-fake-screen"; assert(curr.operation); assert(curr.products.empty()); curr.products.push_back(reagent("screen:address")); curr.products.at(0).set_value(SCREEN); //? cout << "after: " << curr.to_string() << '\n'; //? 1 -//? cout << "AAA " << Recipe_number["new-fake-screen"] << '\n'; //? 1 +//? cout << "AAA " << Recipe_ordinal["new-fake-screen"] << '\n'; //? 1 } //: screen-should-contain is a regular instruction :(before "End Primitive Recipe Declarations") SCREEN_SHOULD_CONTAIN, :(before "End Primitive Recipe Numbers") -Recipe_number["screen-should-contain"] = SCREEN_SHOULD_CONTAIN; +Recipe_ordinal["screen-should-contain"] = SCREEN_SHOULD_CONTAIN; :(before "End Primitive Recipe Implementations") case SCREEN_SHOULD_CONTAIN: { if (!Passed) break; @@ -203,7 +206,7 @@ case SCREEN_SHOULD_CONTAIN: { :(before "End Primitive Recipe Declarations") SCREEN_SHOULD_CONTAIN_IN_COLOR, :(before "End Primitive Recipe Numbers") -Recipe_number["screen-should-contain-in-color"] = SCREEN_SHOULD_CONTAIN_IN_COLOR; +Recipe_ordinal["screen-should-contain-in-color"] = SCREEN_SHOULD_CONTAIN_IN_COLOR; :(before "End Primitive Recipe Implementations") case SCREEN_SHOULD_CONTAIN_IN_COLOR: { if (!Passed) break; @@ -231,36 +234,42 @@ void check_screen(const string& expected_cont //? cerr << "Checking screen for color " << color << "\n"; //? 2 assert(!Current_routine->calls.front().default_space); // not supported long long int screen_location = Memory[SCREEN]; - int data_offset = find_element_name(Type_number["screen"], "data"); + int data_offset = find_element_name(Type_ordinal["screen"], "data"); assert(data_offset >= 0); long long int screen_data_location = screen_location+data_offset; // type: address:array:character long long int screen_data_start = Memory[screen_data_location]; // type: array:character - int width_offset = find_element_name(Type_number["screen"], "num-columns"); + int width_offset = find_element_name(Type_ordinal["screen"], "num-columns"); long long int screen_width = Memory[screen_location+width_offset]; - int height_offset = find_element_name(Type_number["screen"], "num-rows"); + int height_offset = find_element_name(Type_ordinal["screen"], "num-rows"); long long int screen_height = Memory[screen_location+height_offset]; raw_string_stream cursor(expected_contents); // todo: too-long expected_contents should fail long long int addr = screen_data_start+1; // skip length //? cerr << "screen height " << screen_height << '\n'; //? 1 for (long long int row = 0; row < screen_height; ++row) { -//? cerr << "row: " << row << '\n'; //? 1 +//? cerr << "row: " << row << '\n'; //? 3 +//? cerr << "contents: " << cursor.buf+cursor.index << "$\n"; //? 1 cursor.skip_whitespace_and_comments(); if (cursor.at_end()) break; +//? cerr << "row2\n"; //? 2 assert(cursor.get() == '.'); for (long long int column = 0; column < screen_width; ++column, addr+= /*size of screen-cell*/2) { const int cell_color_offset = 1; uint32_t curr = cursor.get(); +//? cerr << "col: " << column << '\n'; //? 1 if (Memory[addr] == 0 && isspace(curr)) continue; //? cerr << color << " vs " << Memory[addr+1] << '\n'; //? 1 if (curr == ' ' && color != -1 && color != Memory[addr+cell_color_offset]) { // filter out other colors continue; } +//? cerr << "col3 " << column << ": " << Memory[addr] << " " << curr << '\n'; //? 1 if (Memory[addr] != 0 && Memory[addr] == curr) { +//? cerr << "col4\n"; //? 1 if (color == -1 || color == Memory[addr+cell_color_offset]) continue; +//? cerr << "col5: " << column << '\n'; //? 1 // contents match but color is off - if (Current_scenario && !Hide_warnings) { + if (Current_scenario && !Scenario_testing_scenario) { // genuine test in a mu file raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ", address " << addr << ", value " << Memory[addr] << ") to be in color " << color << " instead of " << Memory[addr+cell_color_offset] << "\n"; } @@ -268,13 +277,14 @@ void check_screen(const string& expected_cont // just testing check_screen raise << "expected screen location (" << row << ", " << column << ") to be in color " << color << " instead of " << Memory[addr+cell_color_offset] << '\n'; } - if (!Hide_warnings) { + if (!Scenario_testing_scenario) { Passed = false; ++Num_failures; } return; } +//? cerr << "col6 " << column << ": " << Memory[addr] << " " << curr << '\n'; //? 1 // really a mismatch // can't print multi-byte unicode characters in warnings just yet. not very useful for debugging anyway. char expected_pretty[10] = {0}; @@ -288,7 +298,7 @@ void check_screen(const string& expected_cont actual_pretty[0] = ' ', actual_pretty[1] = '(', actual_pretty[2] = '\'', actual_pretty[3] = static_cast<unsigned char>(Memory[addr]), actual_pretty[4] = '\'', actual_pretty[5] = ')', actual_pretty[6] = '\0'; } - if (Current_scenario && !Hide_warnings) { + if (Current_scenario && !Scenario_testing_scenario) { // genuine test in a mu file raise << "\nF - " << Current_scenario->name << ": expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << " instead of " << Memory[addr] << actual_pretty << '\n'; dump_screen(); @@ -297,7 +307,7 @@ void check_screen(const string& expected_cont // just testing check_screen raise << "expected screen location (" << row << ", " << column << ") to contain " << curr << expected_pretty << " instead of " << Memory[addr] << actual_pretty << '\n'; } - if (!Hide_warnings) { + if (!Scenario_testing_scenario) { Passed = false; ++Num_failures; } @@ -354,7 +364,7 @@ void raw_string_stream::skip_whitespace_and_comments():(before "End Primitive Recipe Declarations") _DUMP_SCREEN, :(before "End Primitive Recipe Numbers") -Recipe_number["$dump-screen"] = _DUMP_SCREEN; +Recipe_ordinal["$dump-screen"] = _DUMP_SCREEN; :(before "End Primitive Recipe Implementations") case _DUMP_SCREEN: { dump_screen(); @@ -365,11 +375,11 @@ case _DUMP_SCREEN: { void dump_screen() { assert(!Current_routine->calls.front().default_space); // not supported long long int screen_location = Memory[SCREEN]; - int width_offset = find_element_name(Type_number["screen"], "num-columns"); + int width_offset = find_element_name(Type_ordinal["screen"], "num-columns"); long long int screen_width = Memory[screen_location+width_offset]; - int height_offset = find_element_name(Type_number["screen"], "num-rows"); + int height_offset = find_element_name(Type_ordinal["screen"], "num-rows"); long long int screen_height = Memory[screen_location+height_offset]; - int data_offset = find_element_name(Type_number["screen"], "data"); + int data_offset = find_element_name(Type_ordinal["screen"], "data"); assert(data_offset >= 0); long long int screen_data_location = screen_location+data_offset; // type: address:array:character long long int screen_data_start = Memory[screen_data_location]; // type: array:character -- cgit 1.4.1-2-gfad0