1
2
3
4
5
6
7
8 :(before "End initialize_transform_rewrite_literal_string_to_text()")
9 recipes_taking_literal_strings.insert("screen-should-contain");
10 recipes_taking_literal_strings.insert("screen-should-contain-in-color");
11
12 :(scenarios run_mu_scenario)
13 :(scenario screen_in_scenario)
14 scenario screen-in-scenario [
15 local-scope
16 assume-screen 5/width, 3/height
17 run [
18 a:char <- copy 97/a
19 screen:&:screen <- print screen:&:screen, a
20 ]
21 screen-should-contain [
22
23 .a .
24 . .
25 . .
26 ]
27 ]
28
29
30 :(scenario screen_in_scenario_unicode)
31
32 scenario screen-in-scenario-unicode [
33 local-scope
34 assume-screen 5/width, 3/height
35 run [
36 lambda:char <- copy 955/greek-small-lambda
37 screen:&:screen <- print screen:&:screen, lambda
38 a:char <- copy 97/a
39 screen:&:screen <- print screen:&:screen, a
40 ]
41 screen-should-contain [
42
43 .λa .
44 . .
45 . .
46 ]
47 ]
48
49
50 :(scenario screen_in_scenario_color)
51 scenario screen-in-scenario-color [
52 local-scope
53 assume-screen 5/width, 3/height
54 run [
55 lambda:char <- copy 955/greek-small-lambda
56 screen:&:screen <- print screen:&:screen, lambda, 1/red
57 a:char <- copy 97/a
58 screen:&:screen <- print screen:&:screen, a, 7/white
59 ]
60
61 screen-should-contain [
62
63 .λa .
64 . .
65 . .
66 ]
67
68
69 screen-should-contain-in-color 7/white, [
70
71 . a .
72 . .
73 . .
74 ]
75
76 screen-should-contain-in-color 1/red, [
77
78 .λ .
79 . .
80 . .
81 ]
82 ]
83
84
85 :(scenario screen_in_scenario_error)
86 % Scenario_testing_scenario = true;
87 % Hide_errors = true;
88 scenario screen-in-scenario-error [
89 local-scope
90 assume-screen 5/width, 3/height
91 run [
92 a:char <- copy 97/a
93 screen:&:screen <- print screen:&:screen, a
94 ]
95 screen-should-contain [
96
97 .b .
98 . .
99 . .
100 ]
101 ]
102 +error: F - screen-in-scenario-error: expected screen location (0, 0) to contain 98 ('b') instead of 97 ('a')
103
104 :(scenario screen_in_scenario_color_error)
105 % Scenario_testing_scenario = true;
106 % Hide_errors = true;
107
108 scenario screen-in-scenario-color-error [
109 local-scope
110 assume-screen 5/width, 3/height
111 run [
112 a:char <- copy 97/a
113 screen:&:screen <- print screen:&:screen, a, 1/red
114 ]
115 screen-should-contain-in-color 2/green, [
116
117 .a .
118 . .
119 . .
120 ]
121 ]
122 +error: F - screen-in-scenario-color-error: expected screen location (0, 0) to contain 'a' in color 2 instead of 1
123
124 :(scenarios run)
125 :(scenario convert_names_does_not_fail_when_mixing_special_names_and_numeric_locations)
126 % Scenario_testing_scenario = true;
127 def main [
128 screen:num <- copy 1:num
129 ]
130 -error: mixing variable names and numeric addresses in main
131 $error: 0
132 :(scenarios run_mu_scenario)
133
134
135
136
137
138
139
140 :(before "End Globals")
141 extern const int Max_variables_in_scenarios = Reserved_for_tests-100;
142 int Next_predefined_global_for_scenarios = Max_variables_in_scenarios;
143 :(before "End Reset")
144 assert(Next_predefined_global_for_scenarios < Reserved_for_tests);
145
146 :(before "End Globals")
147
148 extern const int SCREEN = Next_predefined_global_for_scenarios++;
149
150
151
152 :(before "End Special Scenario Variable Names(r)")
153 Name[r]["screen"] = SCREEN;
154
155 :(before "End is_special_name Special-cases")
156 if (s == "screen") return true;
157
158 :(before "End Rewrite Instruction(curr, recipe result)")
159
160
161 if (curr.name == "assume-screen") {
162 curr.name = "new-fake-screen";
163 if (!curr.products.empty()) {
164 raise << result.name << ": 'assume-screen' has no products\n" << end();
165 }
166 else if (!starts_with(result.name, "scenario_")) {
167 raise << result.name << ": 'assume-screen' can't be called here, only in scenarios\n" << end();
168 }
169 else {
170 assert(curr.products.empty());
171 curr.products.pu