simon       01/09/10 03:05:23

  Modified:    .        test.pbc test_main.c
  Added:       .        test2.pasm
  Log:
  Other string bits and pieces; note "-s" flag to test prog.
  
  Revision  Changes    Path
  1.2       +1 -1      parrot/test.pbc
  
        <<Binary file>>
  
  
  1.2       +21 -0     parrot/test_main.c
  
  Index: test_main.c
  ===================================================================
  RCS file: /home/perlcvs/parrot/test_main.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -w -r1.1 -r1.2
  --- test_main.c       2001/08/29 12:07:04     1.1
  +++ test_main.c       2001/09/10 10:05:23     1.2
  @@ -29,6 +29,27 @@
     if (argc == 1) {
       runops(interpreter, opcodes);
     }
  +  else if (argc == 2 && !strcmp(argv[1], "-s")) { /* String tests */
  +      STRING *s = string_make("foo", 3, enc_native, 0, 0);
  +      STRING *t = string_make("quux", 4, enc_native, 0, 0);
  +      int i;
  +      time_t foo;
  +
  +      printf("String %p has length %i: %.*s\n", s, string_length(s), 
string_length(s), s->bufstart);
  +      string_concat(s, t, 0);
  +      printf("String %p has length %i: %.*s\n", s, string_length(s), 
string_length(s), s->bufstart);
  +      string_chopn(s, 4);
  +      printf("String %p has length %i: %.*s\n", s, string_length(s), 
string_length(s), s->bufstart);
  +      string_chopn(s, 4);
  +      printf("String %p has length %i: %.*s\n", s, string_length(s), 
string_length(s), s->bufstart);
  +      foo = time(0);
  +      for (i = 0; i < 100000000; i++) {
  +            string_concat(s, t, 0);
  +            string_chopn(s, 4);
  +      }
  +      printf("10000000 concats and chops took %i seconds.\n", time(0)-foo);
  +      string_destroy(s);
  +  }
     /* Otherwise load in the program they gave and try that */
     else {
       void *program_code;
  
  
  
  1.1                  parrot/test2.pasm
  
  Index: test2.pasm
  ===================================================================
          set_i_ic I2, 1
          set_i_ic I1, 0
          set_s_sc S1, "Hello World"
  REDO:   eq_i_ic I1, I2, DONE, NEXT
  NEXT:   length_s_i I1, S1
          print_s S1
          chopn_s_ic S1, 1
          branch_ic REDO
  DONE:   end
  
  
  

Reply via email to