diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-02-25 17:17:20 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-02-25 17:17:20 -0800 |
commit | dcc060c7d4ef56b978beb34ddce8d8ffcec94fa6 (patch) | |
tree | 7cbb9cd1d8544c7c6c65725fa195ca3821b04b07 /html/050scenario.cc.html | |
parent | 0f5a2f4e21046e319ce0fadec32cc5e89d2f4620 (diff) | |
download | mu-dcc060c7d4ef56b978beb34ddce8d8ffcec94fa6.tar.gz |
2706 - update html
Diffstat (limited to 'html/050scenario.cc.html')
-rw-r--r-- | html/050scenario.cc.html | 65 |
1 files changed, 51 insertions, 14 deletions
diff --git a/html/050scenario.cc.html b/html/050scenario.cc.html index f43664f9..420826b2 100644 --- a/html/050scenario.cc.html +++ b/html/050scenario.cc.html @@ -147,7 +147,7 @@ long long int Num_core_mu_tests = <span class="Constant">0</span><span class="De <span class="Delimiter">:(after "Check For .mu Files")</span> Num_core_mu_tests = SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> <span class="Delimiter">:(before "End Tests")</span> -Warn_on_missing_default_space = <span class="Constant">true</span><span class="Delimiter">;</span> +Hide_missing_default_space_errors = <span class="Constant">false</span><span class="Delimiter">;</span> time_t mu_time<span class="Delimiter">;</span> time<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> cerr << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">Mu tests: "</span> << ctime<span class="Delimiter">(</span>&mu_time<span class="Delimiter">);</span> for <span class="Delimiter">(</span>long long int i = <span class="Constant">0</span><span class="Delimiter">;</span> i < SIZE<span class="Delimiter">(</span>Scenarios<span class="Delimiter">);</span> ++i<span class="Delimiter">)</span> <span class="Delimiter">{</span> @@ -186,6 +186,10 @@ void run_mu_scenario<span class="Delimiter">(</span>const scenario& s<span c bind_special_scenario_names<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">));</span> transform_all<span class="Delimiter">();</span> run<span class="Delimiter">(</span>tmp<span class="Delimiter">.</span>front<span class="Delimiter">());</span> + if <span class="Delimiter">(</span>Passed && !Hide_errors && trace_count<span class="Delimiter">(</span><span class="Constant">"error"</span><span class="Delimiter">)</span> > <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> + Passed = <span class="Constant">false</span><span class="Delimiter">;</span> + ++Num_failures<span class="Delimiter">;</span> + <span class="Delimiter">}</span> if <span class="Delimiter">(</span>not_already_inside_test && Trace_stream<span class="Delimiter">)</span> <span class="Delimiter">{</span> teardown<span class="Delimiter">();</span> ofstream fout<span class="Delimiter">((</span>Trace_dir+Trace_file<span class="Delimiter">).</span>c_str<span class="Delimiter">());</span> @@ -201,9 +205,9 @@ void run_mu_scenario<span class="Delimiter">(</span>const scenario& s<span c <span class="Comment">//: Watch out for redefinitions of scenario routines. We should never ever be</span> <span class="Comment">//: doing that, regardless of anything else.</span> <span class="Delimiter">:(scenarios run)</span> -<span class="Delimiter">:(scenario warn_on_redefine_scenario)</span> -<span class="Special">% Hide_warnings = true;</span> -<span class="Special">% Disable_redefine_warnings = true;</span> +<span class="Delimiter">:(scenario forbid_redefining_scenario_even_if_forced)</span> +<span class="Special">% Hide_errors = true;</span> +<span class="Special">% Disable_redefine_checks = true;</span> recipe scenario-foo [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> ] @@ -211,9 +215,9 @@ recipe scenario-foo [ recipe scenario-foo [ <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">35</span> ] -<span class="traceContains">+warn: redefining recipe scenario-foo</span> +<span class="traceContains">+error: redefining recipe scenario-foo</span> -<span class="Delimiter">:(after "bool warn_on_redefine(const string& recipe_name)")</span> +<span class="Delimiter">:(after "bool should_check_for_redefine(const string& recipe_name)")</span> if <span class="Delimiter">(</span>recipe_name<span class="Delimiter">.</span>find<span class="Delimiter">(</span><span class="Constant">"scenario-"</span><span class="Delimiter">)</span> == <span class="Constant">0</span><span class="Delimiter">)</span> <span class="Identifier">return</span> <span class="Constant">true</span><span class="Delimiter">;</span> <span class="SalientComment">//:: The special instructions we want to support inside scenarios.</span> @@ -330,7 +334,21 @@ void check_memory<span class="Delimiter">(</span>const string& s<span class= skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> string _assign<span class="Delimiter">;</span> in >> _assign<span class="Delimiter">;</span> assert<span class="Delimiter">(</span>_assign == <span class="Constant">"<-"</span><span class="Delimiter">);</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> - double value = <span class="Constant">0</span><span class="Delimiter">;</span> in >> value<span class="Delimiter">;</span> + string rhs = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> + if <span class="Delimiter">(</span>!is_integer<span class="Delimiter">(</span>rhs<span class="Delimiter">)</span> && !is_noninteger<span class="Delimiter">(</span>rhs<span class="Delimiter">))</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> + <span class="Comment">// genuine test in a mu file</span> + raise_error << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": location "</span> << address << <span class="Constant">" can't contain non-number "</span> << rhs << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + else + <span class="Comment">// just testing scenario support</span> + raise_error << <span class="Constant">"location "</span> << address << <span class="Constant">" can't contain non-number "</span> << rhs << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + if <span class="Delimiter">(</span>!Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> + Passed = <span class="Constant">false</span><span class="Delimiter">;</span> + ++Num_failures<span class="Delimiter">;</span> + <span class="Delimiter">}</span> + <span class="Identifier">return</span><span class="Delimiter">;</span> + <span class="Delimiter">}</span> + double value = to_double<span class="Delimiter">(</span>rhs<span class="Delimiter">);</span> if <span class="Delimiter">(</span>contains_key<span class="Delimiter">(</span>locations_checked<span class="Delimiter">,</span> address<span class="Delimiter">))</span> raise_error << <span class="Constant">"duplicate expectation for location "</span> << address << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> trace<span class="Delimiter">(</span><span class="Constant">9999</span><span class="Delimiter">,</span> <span class="Constant">"run"</span><span class="Delimiter">)</span> << <span class="Constant">"checking location "</span> << address << end<span class="Delimiter">();</span> @@ -355,10 +373,9 @@ void check_memory<span class="Delimiter">(</span>const string& s<span class= void check_type<span class="Delimiter">(</span>const string& lhs<span class="Delimiter">,</span> istream& in<span class="Delimiter">)</span> <span class="Delimiter">{</span> reagent x<span class="Delimiter">(</span>lhs<span class="Delimiter">);</span> - const string_tree* type_name = x<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">).</span>second<span class="Delimiter">;</span> - if <span class="Delimiter">(</span>type_name<span class="Delimiter">-></span>value == <span class="Constant">"array"</span> - && type_name<span class="Delimiter">-></span>right && type_name<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value == <span class="Constant">"character"</span> - && !type_name<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + if <span class="Delimiter">(</span>x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>name == <span class="Constant">"array"</span> + && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right && x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>name == <span class="Constant">"character"</span> + && !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> x<span class="Delimiter">.</span>set_value<span class="Delimiter">(</span>to_integer<span class="Delimiter">(</span>x<span class="Delimiter">.</span>name<span class="Delimiter">));</span> skip_whitespace_and_comments<span class="Delimiter">(</span>in<span class="Delimiter">);</span> string _assign = next_word<span class="Delimiter">(</span>in<span class="Delimiter">);</span> @@ -372,6 +389,7 @@ void check_type<span class="Delimiter">(</span>const string& lhs<span class= check_string<span class="Delimiter">(</span>address<span class="Delimiter">,</span> literal<span class="Delimiter">);</span> <span class="Identifier">return</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> + <span class="Comment">// End Scenario Type Cases</span> raise_error << <span class="Constant">"don't know how to check memory for "</span> << lhs << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> <span class="Delimiter">}</span> @@ -449,6 +467,26 @@ recipe main [ <span class="traceContains">+run: checking location 3</span> <span class="traceContains">+run: checking location 4</span> +<span class="Delimiter">:(scenario memory_invalid_string_check)</span> +<span class="Special">% Scenario_testing_scenario = true;</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + memory-should-contain [ + <span class="Constant">1</span><span class="Special"> <- </span>[abc] + ] +] +<span class="traceContains">+error: location 1 can't contain non-number [abc]</span> + +<span class="Delimiter">:(scenario memory_check_with_comment)</span> +<span class="Special">% Scenario_testing_scenario = true;</span> +<span class="Special">% Hide_errors = true;</span> +recipe main [ + memory-should-contain [ + <span class="Constant">1</span><span class="Special"> <- </span><span class="Constant">34</span> <span class="Comment"># comment</span> + ] +] +<span class="traceAbsent">-error: location 1 can't contain non-number 34 # comment</span> + <span class="Delimiter">:(code)</span> <span class="Comment">//: 'trace-should-contain' is like the '+' lines in our scenarios so far</span> <span class="Comment">// Like runs of contiguous '+' lines, order is important. The trace checks</span> @@ -630,7 +668,7 @@ put<span class="Delimiter">(</span>Recipe_ordinal<span class="Delimiter">,</span <span class="Delimiter">:(before "End Primitive Recipe Checks")</span> case CHECK_TRACE_COUNT_FOR_LABEL: <span class="Delimiter">{</span> if <span class="Delimiter">(</span>SIZE<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">)</span> != <span class="Constant">2</span><span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'check-trace-for-label' requires exactly two ingredients, but got '"</span> << inst<span class="Delimiter">.</span>to_string<span class="Delimiter">()</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> + raise_error << maybe<span class="Delimiter">(</span>get<span class="Delimiter">(</span>Recipe<span class="Delimiter">,</span> r<span class="Delimiter">).</span>name<span class="Delimiter">)</span> << <span class="Constant">"'check-trace-for-label' requires exactly two ingredients, but got '"</span> << to_string<span class="Delimiter">(</span>inst<span class="Delimiter">)</span> << <span class="Constant">"'</span><span class="cSpecial">\n</span><span class="Constant">"</span> << end<span class="Delimiter">();</span> <span class="Identifier">break</span><span class="Delimiter">;</span> <span class="Delimiter">}</span> if <span class="Delimiter">(</span>!is_mu_number<span class="Delimiter">(</span>inst<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">)))</span> <span class="Delimiter">{</span> @@ -652,9 +690,8 @@ case CHECK_TRACE_COUNT_FOR_LABEL: <span class="Delimiter">{</span> if <span class="Delimiter">(</span>count != expected_count<span class="Delimiter">)</span> <span class="Delimiter">{</span> if <span class="Delimiter">(</span>Current_scenario && !Scenario_testing_scenario<span class="Delimiter">)</span> <span class="Delimiter">{</span> <span class="Comment">// genuine test in a mu file</span> - raise_error << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": "</span> << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"expected "</span> << expected_count << <span class="Constant">" lines in trace with label "</span> << label << <span class="Constant">" in trace: "</span><span class="Delimiter">;</span> + raise_error << <span class="Constant">"</span><span class="cSpecial">\n</span><span class="Constant">F - "</span> << Current_scenario<span class="Delimiter">-></span>name << <span class="Constant">": "</span> << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"expected "</span> << expected_count << <span class="Constant">" lines in trace with label "</span> << label << <span class="Constant">" in trace: "</span> << end<span class="Delimiter">();</span> DUMP<span class="Delimiter">(</span>label<span class="Delimiter">);</span> - raise_error<span class="Delimiter">;</span> <span class="Delimiter">}</span> else <span class="Delimiter">{</span> <span class="Comment">// just testing scenario support</span> |