about summary refs log blame commit diff stats
path: root/050scenario.cc
blob: 0a1c0f902ae051ef3f03d1d930b502122992e653 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                                                                        
 


                                                                            



                            
                       





                            
 
                                    

              
                       




                         
                       
   


                         

   
 
                                           

              
                       
                         
   







                            

   
 









                           
                           






                                          

 
       
                                      

                              
                                                
                                                                               
                                     



                                                                            

                                   
                                     
                            
                                                         
                                             
                

 


                                                 
                    
 
                        






                                                                  





                                                                       
                                                     
                                                        
                                   


                          
                                             





                                                     


   

                                        
       
                                         
                        
                                               
                             




                                    
                           
                                                                                   


                                         
                                                
               




                                                  
                    
   
                          

 




                                                                             
                                   
                     
                     


                     
                     



                                                           
                                                      
 




                                                                  
               

             
                       






                                             
                                



                                       

                                                
                    
                                                                                                              
                                                      
                                                
                  

                                    
                                                                                                              

                                                                           
                                                            
                                                                          

 


                                                                    
                                                    



                                           


                        
                       

       
                       




                              
                                                                                  

                                                            




                                       
                        
                                   
                     





                         
                                                   



                                             
                                                                    



                                       

                                                
                     
                                                             






                                    
                                       



                                     
                           


                          
                                            


                                                             
                                   
                                                 
                                                                                       
                                                                   
                                                  
                                                           
                                    
                                                                                                                                                                                                                          


                                        
                                                                                                                                                                                  
       
                                       


                       

             





                                                 
                                                     
                                    




                                     
                                    
                               

                                                                     


                                   
                                                                               

 
                                                                 
                                                                         
                                                        
                                                       
                                                                                                                                                                                                                                                      
        
                                                                                                                                                                                                              
                                     




                     
                                
                                                     
                                                                     
                                                            
                                                           
                                    
                                                                                                                                                                                                                         


                                        
                                                                                                                                                                                 
       
                                       




                       



                                 
                                   
                     





                         
                                            

                                      
                                   
                     
             



                            



                         
                                                                        


                               



                            














                                                                            
                             
                                   
                     





                        
                                         



                                             
                                                                  



                                       

                                                
                     
                                                            



        
                                                                        


                                          
                                                            
                                          
                                       


                                                                                                                     

                         
                                                     

                  

   

                                                                                                        

                 

 
                                                        
                                             
                            
                                                 

                                    
                                               
                                                                                                     



                
                                              
                                   
                     

             
                     





                        
                                         

                                       
                                   
                     

             
                     




                        

                                         




                                                                            
                                      
                                   
                     

             
                     




                            
                                            



                                             
                                                                          



                                       

                                                
                     
                                                                    



        
                                                                        


                                            
                                             
                                                   
                                                                    
                                                                                                                              







                                                
                                   
                     




                            

                                            
 
                                                             
                                   
                     

             
                     





                            
                                            
 










                                             
                                                                                
                                       
                                   
                                    
                                                                                                                                                             

          
                                              
                                                                                                                                                                                               

          
                                                   
                                                                                                                                                                                                        

          





                                                         




                                                              
                                                                                                                                                                                            
                  
                  


                                      
                                                                                                                                                       










                                     
                     





                                    
                                                             
 




                                                                          

            
       

                                                         
                         

                         
                                   
                                   



                                  
//: Mu scenarios. This will get long, but these are the tests we want to
//: support in this layer.

//: You can use variable names in scenarios, but for the most part we'll use
//: raw location numbers, because that lets us make assertions on memory.
//: Tests should avoid abstraction as far as possible.
:(scenarios run_mu_scenario)
:(scenario scenario_block)
scenario foo [
  run [
    1:number <- copy 13
  ]
  memory-should-contain [
    1 <- 13
  ]
]
# checks are inside scenario

:(scenario scenario_multiple_blocks)
scenario foo [
  run [
    1:number <- copy 13
  ]
  memory-should-contain [
    1 <- 13
  ]
  run [
    2:number <- copy 13
  ]
  memory-should-contain [
    1 <- 13
    2 <- 13
  ]
]

:(scenario scenario_check_memory_and_trace)
scenario foo [
  run [
    1:number <- copy 13
    trace 1, [a], [a b c]
  ]
  memory-should-contain [
    1 <- 13
  ]
  trace-should-contain [
    a: a b c
  ]
  trace-should-not-contain [
    a: x y z
  ]
]

//:: Core data structure

:(before "End Types")
struct scenario {
  string name;
  string to_run;
};

:(before "End Globals")
vector<scenario> Scenarios;
set<string> Scenario_names;

//:: Parse the 'scenario' form.
//: Simply store the text of the scenario.

:(before "End Command Handlers")
else if (command == "scenario") {
  Scenarios.push_back(parse_scenario(in));
}

:(code)
scenario parse_scenario(istream& in) {
  scenario result;
  result.name = next_word(in);
  if (contains_key(Scenario_names, result.name))
    raise_error << "duplicate scenario name: " << result.name << '\n' << end();
  Scenario_names.insert(result.name);
  skip_whitespace_and_comments(in);
  assert(in.peek() == '[');
  // scenarios are take special 'code' strings so we need to ignore brackets
  // inside comments
  result.to_run = slurp_quoted(in);
  // delete [] delimiters
  assert(result.to_run.at(0) == '[');
  result.to_run.erase(0, 1);
  assert(result.to_run.at(SIZE(result.to_run)-1) == ']');
  result.to_run.erase(SIZE(result.to_run)-1);
  return result;
}

:(scenario read_scenario_with_bracket_in_comment)
scenario foo [
  # ']' in comment
  1:number <- copy 0
]
+run: 1:number <- copy 0

:(scenario read_scenario_with_bracket_in_comment_in_nested_string)
scenario foo [
  1:address:array:character <- new [# not a comment]
]
+run: 1:address:array:character <- new [# not a comment]

//:: Run scenarios when we run 'mu test'.
//: Treat the text of the scenario as a regular series of instructions.

:(before "End Tests")
time_t mu_time; time(&mu_time);
cerr << "\nMu tests: " << ctime(&mu_time);
for (long long int i = 0; i < SIZE(Scenarios); ++i) {
//?   cerr << i << ": " << Scenarios.at(i).name << '\n';
  run_mu_scenario(Scenarios.at(i));
  if (Passed) cerr << ".";
}

//: Convenience: run a single named scenario.
:(after "Test Runs")
for (long long int i = 0; i < SIZE(Scenarios); ++i) {
  if (Scenarios.at(i).name == argv[argc-1]) {
    run_mu_scenario(Scenarios.at(i));
    if (Passed) cerr << ".\n";
    return 0;
  }
}

:(before "End Globals")
const scenario* Current_scenario = NULL;
:(code)
void run_mu_scenario(const scenario& s) {
  Current_scenario = &s;
  bool not_already_inside_test = !Trace_stream;
//?   cerr << s.name << '\n';
  if (not_already_inside_test) {
    Trace_file = s.name;
    Trace_stream = new trace_stream;
    setup();
  }
  assert(Routines.empty());
  vector<recipe_ordinal> tmp = load("recipe scenario-"+s.name+" [ "+s.to_run+" ]");
  bind_special_scenario_names(tmp.at(0));
  transform_all();
  run(tmp.front());
  if (not_already_inside_test && Trace_stream) {
    teardown();
    ofstream fout((Trace_dir+Trace_file).c_str());
    fout << Trace_stream->readable_contents("");
    fout.close();
    delete Trace_stream;
    Trace_stream = NULL;
    Trace_file = "";
  }
  Current_scenario = NULL;
}

//: Watch out for redefinitions of scenario routines. We should never ever be
//: doing that, regardless of anything else.
:(scenarios run)
:(scenario warn_on_redefine_scenario)
% Hide_warnings = true;
% Disable_redefine_warnings = true;
recipe scenario-foo [
  1:number <- copy 34
]

recipe scenario-foo [
  1:number <- copy 35
]
+warn: redefining recipe scenario-foo

:(after "bool warn_on_redefine(const string& recipe_name)")
  if (recipe_name.find("scenario-") == 0) return true;

//:: The special instructions we want to support inside scenarios.
//: In a compiler for the mu VM these will require more work.

//: 'run' interprets a string as a set of instructions

:(scenario run)
recipe main [
  run [
    1:number <- copy 13
  ]
]
+mem: storing 13 in location 1

:(before "End Primitive Recipe Declarations")
RUN,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "run", RUN);
:(before "End Primitive Recipe Checks")
case RUN: {
  break;
}
:(before "End Primitive Recipe Implementations")
case RUN: {
  ostringstream tmp;
  tmp << "recipe run" << Next_recipe_ordinal << " [ " << current_instruction().ingredients.at(0).name << " ]";
  vector<recipe_ordinal> tmp_recipe = load(tmp.str());
  bind_special_scenario_names(tmp_recipe.at(0));
  transform_all();
  if (Trace_stream) {
    ++Trace_stream->callstack_depth;
    trace(9998, "trace") << "run: incrementing callstack depth to " << Trace_stream->callstack_depth << end();
    assert(Trace_stream->callstack_depth < 9000);  // 9998-101 plus cushion
  }
  Current_routine->calls.push_front(call(tmp_recipe.at(0)));
  continue;  // not done with caller; don't increment current_step_index()
}

// Some variables for fake resources always get special addresses in
// scenarios.
:(code)
void bind_special_scenario_names(recipe_ordinal r) {
  // Special Scenario Variable Names(r)
  // End Special Scenario Variable Names(r)
}

:(scenario run_multiple)
recipe main [
  run [
    1:number <- copy 13
  ]
  run [
    2:number <- copy 13
  ]
]
+mem: storing 13 in location 1
+mem: storing 13 in location 2

//: 'memory-should-contain' raises errors if specific locations aren't as expected
//: Also includes some special support for checking strings.

:(before "End Globals")
bool Scenario_testing_scenario = false;
:(before "End Setup")
Scenario_testing_scenario = false;

:(scenario memory_check)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  memory-should-contain [
    1 <- 13
  ]
]
+run: checking location 1
+error: expected location 1 to contain 13 but saw 0

:(before "End Primitive Recipe Declarations")
MEMORY_SHOULD_CONTAIN,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "memory-should-contain", MEMORY_SHOULD_CONTAIN);
:(before "End Primitive Recipe Checks")
case MEMORY_SHOULD_CONTAIN: {
  break;
}
:(before "End Primitive Recipe Implementations")
case MEMORY_SHOULD_CONTAIN: {
  if (!Passed) break;
  check_memory(current_instruction().ingredients.at(0).name);
  break;
}

:(code)
void check_memory(const string& s) {
  istringstream in(s);
  in >> std::noskipws;
  set<long long int> locations_checked;
  while (true) {
    skip_whitespace_and_comments(in);
    if (in.eof()) break;
    string lhs = next_word(in);
    if (!is_integer(lhs)) {
      check_type(lhs, in);
      continue;
    }
    long long int address = to_integer(lhs);
    skip_whitespace_and_comments(in);
    string _assign;  in >> _assign;  assert(_assign == "<-");
    skip_whitespace_and_comments(in);
    double value = 0;  in >> value;
    if (contains_key(locations_checked, address))
      raise_error << "duplicate expectation for location " << address << '\n' << end();
    trace(9999, "run") << "checking location " << address << end();
    if (get_or_insert(Memory, address) != value) {
      if (Current_scenario && !Scenario_testing_scenario) {
        // genuine test in a mu file
        raise_error << "\nF - " << Current_scenario->name << ": expected location " << address << " to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end();
      }
      else {
        // just testing scenario support
        raise_error << "expected location " << address << " to contain " << no_scientific(value) << " but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end();
      }
      if (!Scenario_testing_scenario) {
        Passed = false;
        ++Num_failures;
      }
      return;
    }
    locations_checked.insert(address);
  }
}

void check_type(const string& lhs, istream& in) {
  reagent x(lhs);
  if (x.properties.at(0).second->value == "string") {
    x.set_value(to_integer(x.name));
    skip_whitespace_and_comments(in);
    string _assign = next_word(in);
    assert(_assign == "<-");
    skip_whitespace_and_comments(in);
    string literal = next_word(in);
    long long int address = x.value;
    // exclude quoting brackets
    assert(*literal.begin() == '[');  literal.erase(literal.begin());
    assert(*--literal.end() == ']');  literal.erase(--literal.end());
    check_string(address, literal);
    return;
  }
  raise_error << "don't know how to check memory for " << lhs << '\n' << end();
}

void check_string(long long int address, const string& literal) {
  trace(9999, "run") << "checking string length at " << address << end();
  if (get_or_insert(Memory, address) != SIZE(literal)) {
    if (Current_scenario && !Scenario_testing_scenario)
      raise_error << "\nF - " << Current_scenario->name << ": expected location " << address << " to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end();
    else
      raise_error << "expected location " << address << " to contain length " << SIZE(literal) << " of string [" << literal << "] but saw " << no_scientific(get_or_insert(Memory, address)) << '\n' << end();
    if (!Scenario_testing_scenario) {
      Passed = false;
      ++Num_failures;
    }
    return;
  }
  ++address;  // now skip length
  for (long long int i = 0; i < SIZE(literal); ++i) {
    trace(9999, "run") << "checking location " << address+i << end();
    if (get_or_insert(Memory, address+i) != literal.at(i)) {
      if (Current_scenario && !Scenario_testing_scenario) {
        // genuine test in a mu file
        raise_error << "\nF - " << Current_scenario->name << ": expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << '\n' << end();
      }
      else {
        // just testing scenario support
        raise_error << "expected location " << (address+i) << " to contain " << literal.at(i) << " but saw " << no_scientific(get_or_insert(Memory, address+i)) << '\n' << end();
      }
      if (!Scenario_testing_scenario) {
        Passed = false;
        ++Num_failures;
      }
      return;
    }
  }
}

:(scenario memory_check_multiple)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  memory-should-contain [
    1 <- 0
    1 <- 0
  ]
]
+error: duplicate expectation for location 1

:(scenario memory_check_string_length)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  1:number <- copy 3
  2:number <- copy 97  # 'a'
  3:number <- copy 98  # 'b'
  4:number <- copy 99  # 'c'
  memory-should-contain [
    1:string <- [ab]
  ]
]
+error: expected location 1 to contain length 2 of string [ab] but saw 3

:(scenario memory_check_string)
recipe main [
  1:number <- copy 3
  2:number <- copy 97  # 'a'
  3:number <- copy 98  # 'b'
  4:number <- copy 99  # 'c'
  memory-should-contain [
    1:string <- [abc]
  ]
]
+run: checking string length at 1
+run: checking location 2
+run: checking location 3
+run: checking location 4

:(code)
//: 'trace-should-contain' is like the '+' lines in our scenarios so far
// Like runs of contiguous '+' lines, order is important. The trace checks
// that the lines are present *and* in the specified sequence. (There can be
// other lines in between.)

:(scenario trace_check_fails)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  trace-should-contain [
    a: b
    a: d
  ]
]
+error: missing [b] in trace with label a

:(before "End Primitive Recipe Declarations")
TRACE_SHOULD_CONTAIN,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "trace-should-contain", TRACE_SHOULD_CONTAIN);
:(before "End Primitive Recipe Checks")
case TRACE_SHOULD_CONTAIN: {
  break;
}
:(before "End Primitive Recipe Implementations")
case TRACE_SHOULD_CONTAIN: {
  if (!Passed) break;
  check_trace(current_instruction().ingredients.at(0).name);
  break;
}

:(code)
// simplified version of check_trace_contents() that emits errors rather
// than just printing to stderr
bool check_trace(const string& expected) {
  Trace_stream->newline();
  vector<trace_line> expected_lines = parse_trace(expected);
  if (expected_lines.empty()) return true;
  long long int curr_expected_line = 0;
  for (vector<trace_line>::iterator p = Trace_stream->past_lines.begin(); p != Trace_stream->past_lines.end(); ++p) {
    if (expected_lines.at(curr_expected_line).label != p->label) continue;
    if (expected_lines.at(curr_expected_line).contents != trim(p->contents)) continue;
    // match
    ++curr_expected_line;
    if (curr_expected_line == SIZE(expected_lines)) {
      return true;
    }
  }

  raise_error << "missing [" << expected_lines.at(curr_expected_line).contents << "] "
              << "in trace with label " << expected_lines.at(curr_expected_line).label << '\n' << end();
  Passed = false;
  return false;
}

vector<trace_line> parse_trace(const string& expected) {
  vector<string> buf = split(expected, "\n");
  vector<trace_line> result;
  for (long long int i = 0; i < SIZE(buf); ++i) {
    buf.at(i) = trim(buf.at(i));
    if (buf.at(i).empty()) continue;
    long long int delim = buf.at(i).find(": ");
    result.push_back(trace_line(trim(buf.at(i).substr(0, delim)),  trim(buf.at(i).substr(delim+2))));
  }
  return result;
}

:(scenario trace_check_fails_in_nonfirst_line)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  run [
    trace 1, [a], [b]
  ]
  trace-should-contain [
    a: b
    a: d
  ]
]
+error: missing [d] in trace with label a

:(scenario trace_check_passes_silently)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  run [
    trace 1, [a], [b]
  ]
  trace-should-contain [
    a: b
  ]
]
-error: missing [b] in trace with label a
$error: 0

//: 'trace-should-not-contain' is like the '-' lines in our scenarios so far
//: Each trace line is separately checked for absense. Order is *not*
//: important, so you can't say things like "B should not exist after A."

:(scenario trace_negative_check_fails)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  run [
    trace 1, [a], [b]
  ]
  trace-should-not-contain [
    a: b
  ]
]
+error: unexpected [b] in trace with label a

:(before "End Primitive Recipe Declarations")
TRACE_SHOULD_NOT_CONTAIN,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "trace-should-not-contain", TRACE_SHOULD_NOT_CONTAIN);
:(before "End Primitive Recipe Checks")
case TRACE_SHOULD_NOT_CONTAIN: {
  break;
}
:(before "End Primitive Recipe Implementations")
case TRACE_SHOULD_NOT_CONTAIN: {
  if (!Passed) break;
  check_trace_missing(current_instruction().ingredients.at(0).name);
  break;
}

:(code)
// simplified version of check_trace_contents() that emits errors rather
// than just printing to stderr
bool check_trace_missing(const string& in) {
  Trace_stream->newline();
  vector<trace_line> lines = parse_trace(in);
  for (long long int i = 0; i < SIZE(lines); ++i) {
    if (trace_count(lines.at(i).label, lines.at(i).contents) != 0) {
      raise_error << "unexpected [" << lines.at(i).contents << "] in trace with label " << lines.at(i).label << '\n' << end();
      Passed = false;
      return false;
    }
  }
  return true;
}

:(scenario trace_negative_check_passes_silently)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  trace-should-not-contain [
    a: b
  ]
]
-error: unexpected [b] in trace with label a
$error: 0

:(scenario trace_negative_check_fails_on_any_unexpected_line)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  run [
    trace 1, [a], [d]
  ]
  trace-should-not-contain [
    a: b
    a: d
  ]
]
+error: unexpected [d] in trace with label a

:(scenario trace_count_check)
recipe main [
  run [
    trace 1, [a], [foo]
  ]
  check-trace-count-for-label 1, [a]
]

:(before "End Primitive Recipe Declarations")
CHECK_TRACE_COUNT_FOR_LABEL,
:(before "End Primitive Recipe Numbers")
put(Recipe_ordinal, "check-trace-count-for-label", CHECK_TRACE_COUNT_FOR_LABEL);
:(before "End Primitive Recipe Checks")
case CHECK_TRACE_COUNT_FOR_LABEL: {
  if (SIZE(inst.ingredients) != 2) {
    raise_error << maybe(get(Recipe, r).name) << "'check-trace-for-label' requires exactly two ingredients, but got '" << inst.to_string() << "'\n" << end();
    break;
  }
  if (!is_mu_number(inst.ingredients.at(0))) {
    raise_error << maybe(get(Recipe, r).name) << "first ingredient of 'check-trace-for-label' should be a number (count), but got " << inst.ingredients.at(0).original_string << '\n' << end();
    break;
  }
  if (!is_literal_string(inst.ingredients.at(1))) {
    raise_error << maybe(get(Recipe, r).name) << "second ingredient of 'check-trace-for-label' should be a literal string (label), but got " << inst.ingredients.at(1).original_string << '\n' << end();
    break;
  }
  break;
}
:(before "End Primitive Recipe Implementations")
case CHECK_TRACE_COUNT_FOR_LABEL: {
  if (!Passed) break;
  long long int expected_count = ingredients.at(0).at(0);
  string label = current_instruction().ingredients.at(1).name;
  long long int count = trace_count(label);
  if (count != expected_count) {
    if (Current_scenario && !Scenario_testing_scenario) {
      // genuine test in a mu file
      raise_error << "\nF - " << Current_scenario->name << ": " << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label " << label << " in trace: ";
      DUMP(label);
      raise_error;
    }
    else {
      // just testing scenario support
      raise_error << maybe(current_recipe_name()) << "expected " << expected_count << " lines in trace with label " << label << " in trace\n" << end();
    }
    if (!Scenario_testing_scenario) {
      Passed = false;
      ++Num_failures;
    }
  }
  break;
}

:(scenario trace_count_check_2)
% Scenario_testing_scenario = true;
% Hide_errors = true;
recipe main [
  run [
    trace 1, [a], [foo]
  ]
  check-trace-count-for-label 2, [a]
]
+error: main: expected 2 lines in trace with label a in trace

//: Minor detail: ignore 'system' calls in scenarios, since anything we do
//: with them is by definition impossible to test through mu.
:(after "case _SYSTEM:")
  if (Current_scenario) break;

//:: Helpers

:(code)
// just for the scenarios running scenarios in C++ layers
void run_mu_scenario(const string& form) {
  Scenario_names.clear();
  istringstream in(form);
  in >> std::noskipws;
  skip_whitespace_and_comments(in);
  string _scenario = next_word(in);
  assert(_scenario == "scenario");
  scenario s = parse_scenario(in);
  run_mu_scenario(s);
}
quot; class="LineNr">265 </span> 68/push 0x41/imm32 <span id="L266" class="LineNr">266 </span> 68/push <a href='108write.subx.html#L148'>_test-stream</a>/imm32 <span id="L267" class="LineNr">267 </span> <span class="subxS2Comment"># . . call</span> <span id="L268" class="LineNr">268 </span> e8/call <a href='115write-byte.subx.html#L208'>append-byte</a>/disp32 <span id="L269" class="LineNr">269 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L270" class="LineNr">270 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 8/imm32 <span class="subxComment"># add to esp</span> <span id="L271" class="LineNr">271 </span> <span class="subxComment"># check-stream-equal(_test-stream, &quot;A&quot;, msg)</span> <span id="L272" class="LineNr">272 </span> <span class="subxS2Comment"># . . push args</span> <span id="L273" class="LineNr">273 </span> 68/push <span class="Constant">&quot;F - test-append-byte-single&quot;</span>/imm32 <span id="L274" class="LineNr">274 </span> 68/push <span class="Constant">&quot;A&quot;</span>/imm32 <span id="L275" class="LineNr">275 </span> 68/push <a href='108write.subx.html#L148'>_test-stream</a>/imm32 <span id="L276" class="LineNr">276 </span> <span class="subxS2Comment"># . . call</span> <span id="L277" class="LineNr">277 </span> e8/call <a href='109stream-equal.subx.html#L194'>check-stream-equal</a>/disp32 <span id="L278" class="LineNr">278 </span> <span class="subxS2Comment"># . . discard args</span> <span id="L279" class="LineNr">279 </span> 81 0/subop/add 3/mod/direct 4/rm32/esp <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> <span class="Normal"> . </span> 0xc/imm32 <span class="subxComment"># add to esp</span> <span id="L280" class="LineNr">280 </span> <span class="subxS1Comment"># . end</span> <span id="L281" class="LineNr">281 </span> c3/return <span id="L282" class="LineNr">282 </span> <span id="L283" class="LineNr">283 </span>== data <span id="L284" class="LineNr">284 </span> <span id="L285" class="LineNr">285 </span><span class="subxMinorFunction">_test-output-stream</span>: <span class="subxComment"># (stream byte)</span> <span id="L286" class="LineNr">286 </span> <span class="subxComment"># current write index</span> <span id="L287" class="LineNr">287 </span> 0/imm32 <span id="L288" class="LineNr">288 </span> <span class="subxComment"># current read index</span> <span id="L289" class="LineNr">289 </span> 0/imm32 <span id="L290" class="LineNr">290 </span> <span class="subxComment"># size</span> <span id="L291" class="LineNr">291 </span> 0x800/imm32 <span class="subxComment"># 2048 bytes</span> <span id="L292" class="LineNr">292 </span> <span class="subxComment"># data (128 lines x 16 bytes/line)</span> <span id="L293" class="LineNr">293 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L294" class="LineNr">294 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L295" class="LineNr">295 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L296" class="LineNr">296 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L297" class="LineNr">297 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L298" class="LineNr">298 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L299" class="LineNr">299 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L300" class="LineNr">300 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L301" class="LineNr">301 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L302" class="LineNr">302 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L303" class="LineNr">303 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L304" class="LineNr">304 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L305" class="LineNr">305 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L306" class="LineNr">306 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L307" class="LineNr">307 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L308" class="LineNr">308 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L309" class="LineNr">309 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L310" class="LineNr">310 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L311" class="LineNr">311 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L312" class="LineNr">312 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L313" class="LineNr">313 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L314" class="LineNr">314 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L315" class="LineNr">315 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L316" class="LineNr">316 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L317" class="LineNr">317 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L318" class="LineNr">318 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L319" class="LineNr">319 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L320" class="LineNr">320 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L321" class="LineNr">321 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L322" class="LineNr">322 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L323" class="LineNr">323 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L324" class="LineNr">324 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L325" class="LineNr">325 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L326" class="LineNr">326 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L327" class="LineNr">327 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L328" class="LineNr">328 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L329" class="LineNr">329 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L330" class="LineNr">330 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L331" class="LineNr">331 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L332" class="LineNr">332 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L333" class="LineNr">333 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L334" class="LineNr">334 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L335" class="LineNr">335 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L336" class="LineNr">336 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L337" class="LineNr">337 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L338" class="LineNr">338 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L339" class="LineNr">339 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L340" class="LineNr">340 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L341" class="LineNr">341 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L342" class="LineNr">342 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L343" class="LineNr">343 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L344" class="LineNr">344 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L345" class="LineNr">345 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L346" class="LineNr">346 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L347" class="LineNr">347 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L348" class="LineNr">348 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L349" class="LineNr">349 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L350" class="LineNr">350 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L351" class="LineNr">351 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L352" class="LineNr">352 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L353" class="LineNr">353 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L354" class="LineNr">354 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L355" class="LineNr">355 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L356" class="LineNr">356 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L357" class="LineNr">357 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L358" class="LineNr">358 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L359" class="LineNr">359 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L360" class="LineNr">360 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L361" class="LineNr">361 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L362" class="LineNr">362 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L363" class="LineNr">363 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L364" class="LineNr">364 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L365" class="LineNr">365 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L366" class="LineNr">366 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L367" class="LineNr">367 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L368" class="LineNr">368 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L369" class="LineNr">369 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L370" class="LineNr">370 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L371" class="LineNr">371 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L372" class="LineNr">372 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L373" class="LineNr">373 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L374" class="LineNr">374 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L375" class="LineNr">375 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L376" class="LineNr">376 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L377" class="LineNr">377 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L378" class="LineNr">378 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L379" class="LineNr">379 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L380" class="LineNr">380 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L381" class="LineNr">381 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L382" class="LineNr">382 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L383" class="LineNr">383 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L384" class="LineNr">384 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L385" class="LineNr">385 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L386" class="LineNr">386 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L387" class="LineNr">387 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L388" class="LineNr">388 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L389" class="LineNr">389 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L390" class="LineNr">390 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L391" class="LineNr">391 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L392" class="LineNr">392 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L393" class="LineNr">393 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L394" class="LineNr">394 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L395" class="LineNr">395 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L396" class="LineNr">396 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L397" class="LineNr">397 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L398" class="LineNr">398 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L399" class="LineNr">399 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L400" class="LineNr">400 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L401" class="LineNr">401 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L402" class="LineNr">402 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L403" class="LineNr">403 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L404" class="LineNr">404 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L405" class="LineNr">405 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L406" class="LineNr">406 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L407" class="LineNr">407 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L408" class="LineNr">408 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L409" class="LineNr">409 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L410" class="LineNr">410 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L411" class="LineNr">411 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L412" class="LineNr">412 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L413" class="LineNr">413 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L414" class="LineNr">414 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L415" class="LineNr">415 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L416" class="LineNr">416 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L417" class="LineNr">417 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L418" class="LineNr">418 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L419" class="LineNr">419 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L420" class="LineNr">420 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L421" class="LineNr">421 </span> <span id="L422" class="LineNr">422 </span><span class="subxComment"># a test buffered file for _test-output-stream</span> <span id="L423" class="LineNr">423 </span><span class="subxMinorFunction">_test-output-buffered-file</span>: <span class="subxComment"># buffered-file</span> <span id="L424" class="LineNr">424 </span> <span class="subxComment"># file descriptor or (addr stream byte)</span> <span id="L425" class="LineNr">425 </span> <a href='115write-byte.subx.html#L285'>_test-output-stream</a>/imm32 <span id="L426" class="LineNr">426 </span><span class="Constant">$_test-output-buffered-file-&gt;buffer</span>: <span id="L427" class="LineNr">427 </span> <span class="subxComment"># current write index</span> <span id="L428" class="LineNr">428 </span> 0/imm32 <span id="L429" class="LineNr">429 </span> <span class="subxComment"># current read index</span> <span id="L430" class="LineNr">430 </span> 0/imm32 <span id="L431" class="LineNr">431 </span> <span class="subxComment"># size</span> <span id="L432" class="LineNr">432 </span> 6/imm32 <span id="L433" class="LineNr">433 </span> <span class="subxComment"># data</span> <span id="L434" class="LineNr">434 </span> 00 00 00 00 00 00 <span class="subxComment"># 6 bytes</span> <span id="L435" class="LineNr">435 </span> <span id="L436" class="LineNr">436 </span><span class="subxMinorFunction">_test-error-stream</span>: <span class="subxComment"># (stream byte)</span> <span id="L437" class="LineNr">437 </span> <span class="subxComment"># current write index</span> <span id="L438" class="LineNr">438 </span> 0/imm32 <span id="L439" class="LineNr">439 </span> <span class="subxComment"># current read index</span> <span id="L440" class="LineNr">440 </span> 0/imm32 <span id="L441" class="LineNr">441 </span> <span class="subxComment"># line</span> <span id="L442" class="LineNr">442 </span> 0x80/imm32 <span class="subxComment"># 128 bytes</span> <span id="L443" class="LineNr">443 </span> <span class="subxComment"># data (8 lines x 16 bytes/line)</span> <span id="L444" class="LineNr">444 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L445" class="LineNr">445 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L446" class="LineNr">446 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L447" class="LineNr">447 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L448" class="LineNr">448 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L449" class="LineNr">449 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L450" class="LineNr">450 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L451" class="LineNr">451 </span> 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <span id="L452" class="LineNr">452 </span> <span id="L453" class="LineNr">453 </span><span class="subxComment"># a test buffered file for _test-error-stream</span> <span id="L454" class="LineNr">454 </span><span class="subxMinorFunction">_test-error-buffered-file</span>: <span class="subxComment"># buffered-file</span> <span id="L455" class="LineNr">455 </span> <span class="subxComment"># file descriptor or (addr stream byte)</span> <span id="L456" class="LineNr">456 </span> <a href='115write-byte.subx.html#L436'>_test-error-stream</a>/imm32 <span id="L457" class="LineNr">457 </span><span class="Constant">$_test-error-buffered-file-&gt;buffer</span>: <span id="L458" class="LineNr">458 </span> <span class="subxComment"># current write index</span> <span id="L459" class="LineNr">459 </span> 0/imm32 <span id="L460" class="LineNr">460 </span> <span class="subxComment"># current read index</span> <span id="L461" class="LineNr">461 </span> 0/imm32 <span id="L462" class="LineNr">462 </span> <span class="subxComment"># size</span> <span id="L463" class="LineNr">463 </span> 6/imm32 <span id="L464" class="LineNr">464 </span> <span class="subxComment"># data</span> <span id="L465" class="LineNr">465 </span> 00 00 00 00 00 00 <span class="subxComment"># 6 bytes</span> <span id="L466" class="LineNr">466 </span> <span id="L467" class="LineNr">467 </span><span class="subxS2Comment"># . . vim&#0058;nowrap:textwidth=0</span> </pre> </body> </html> <!-- vim: set foldmethod=manual : -->