cvsuser     04/07/16 09:09:16

  Modified:    .        MANIFEST
               classes  resizablepmcarray.pmc
               languages/python pie-thon.pl
  Added:       languages/python/t/pie b1.t b6.t
  Log:
  Pie-thon 73 - more tests
  
  Revision  Changes    Path
  1.707     +2 -0      parrot/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /cvs/public/parrot/MANIFEST,v
  retrieving revision 1.706
  retrieving revision 1.707
  diff -u -w -r1.706 -r1.707
  --- MANIFEST  14 Jul 2004 12:18:02 -0000      1.706
  +++ MANIFEST  16 Jul 2004 16:09:07 -0000      1.707
  @@ -2273,8 +2273,10 @@
   languages/python/t/basic/oo_attr.t                []
   languages/python/t/basic/oo_class.t               []
   languages/python/t/basic/iter.t                   []
  +languages/python/t/pie/b1.t                       []
   languages/python/t/pie/b2.t                       []
   languages/python/t/pie/b5.t                       []
  +languages/python/t/pie/b6.t                       []
   languages/regex/ChangeLog                         [regex]
   languages/regex/MAINTAINER                        [regex]
   languages/regex/Makefile                          [regex]
  
  
  
  1.1                  parrot/languages/python/t/pie/b1.t
  
  Index: b1.t
  ===================================================================
  # $Id: b1.t,v 1.1 2004/07/16 16:09:11 leo Exp $
  
  use strict;
  use lib '../../lib';
  
  use Parrot::Test tests => 1;
  
  sub test {
      language_output_is('python', $_[0], '', $_[1]);
  }
  
  test(<<'CODE', 'b1.py');
  def depth0(n):
      try:
          n = depth0(n+1)
      except RuntimeError:
          pass
      return n
  
  def depth1(n, pea):
      p = (pea, pea)
      for i in xrange(n):
          p = (p, pea)
      try:
          n, p = depth1(n+1, p)
      except RuntimeError:
          pass
      return n, p
  
  def main():
      print depth0(0) >= 996
      pea = []
      base, p = depth1(0, pea)
      print base >= 996
      pea.append(p)
      while p[1] is not pea:
          q = p[1]
          n = 0
          while p[1] is q:
              n += 1
              p = p[0]
          if n != base+1:
              raise RuntimeError, (n, base)
          base -= 1
      print base
      del pea[:]
  
  if __name__ == '__main__':
      main()
  CODE
  
  
  
  1.1                  parrot/languages/python/t/pie/b6.t
  
  Index: b6.t
  ===================================================================
  # $Id: b6.t,v 1.1 2004/07/16 16:09:11 leo Exp $
  
  use strict;
  use lib '../../lib';
  
  use Parrot::Test tests => 1;
  
  sub test {
      language_output_is('python', $_[0], '', $_[1]);
  }
  
  test(<<'CODE', 'b6 - mul array x');
  # from b5 import check
  show=True
  def check(a, b):
      if __debug__:
          if show:
              print `a`, "==", `b`
      if not a == b:
          raise AssertionError("%.30r != %.30r" % (a, b))
  
  def main():
      L = [1]*100
      L[-1] = 42
      n = 0
      for i in L:
          n += i
      check(i, 42)
      #check(n, 1000041)
  
  if __name__ == '__main__':
      main()
  CODE
  
  
  
  1.7       +45 -4     parrot/classes/resizablepmcarray.pmc
  
  Index: resizablepmcarray.pmc
  ===================================================================
  RCS file: /cvs/public/parrot/classes/resizablepmcarray.pmc,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- resizablepmcarray.pmc     15 Jul 2004 11:25:53 -0000      1.6
  +++ resizablepmcarray.pmc     16 Jul 2004 16:09:14 -0000      1.7
  @@ -1,6 +1,6 @@
   /*
   Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -$Id: resizablepmcarray.pmc,v 1.6 2004/07/15 11:25:53 leo Exp $
  +$Id: resizablepmcarray.pmc,v 1.7 2004/07/16 16:09:14 leo Exp $
   
   =head1 NAME
   
  @@ -121,6 +121,8 @@
       PMC* get_pmc_keyed_int (INTVAL key) {
           PMC **data;
           if (key < 0)
  +            key += PMC_int_val(SELF);
  +        if (key < 0)
               internal_exception(OUT_OF_BOUNDS,
                   "ResizablePMCArray: index out of bounds!\n");
           if (key >= PMC_int_val(SELF))
  @@ -142,12 +144,14 @@
   */
   
       void set_pmc_keyed_int (INTVAL key, PMC* src) {
  -        if (key < 0)
  -            internal_exception(OUT_OF_BOUNDS,
  -                "ResizablePMCArray: index out of bounds!\n");
           /*
            * TODO in python mode, only .append is allowed
            */
  +        if (key < 0)
  +            key += PMC_int_val(SELF);
  +        if (key < 0)
  +            internal_exception(OUT_OF_BOUNDS,
  +                "ResizablePMCArray: index out of bounds!\n");
           if (key >= PMC_int_val(SELF))
               DYNSELF.set_integer_native(key+1);
           ((PMC**)PMC_data(SELF))[key] = src;
  @@ -229,6 +233,43 @@
           }
           return 1;
       }
  +/*
  +
  +=item C<void multiply_int(INTVAL value,  PMC *dest)>
  +
  +Python (b6.main):
  +
  + # L = [1] * 1000000
  +
  +  4           0 LOAD_CONST               1 (1)
  +              3 BUILD_LIST               1
  +              6 LOAD_CONST               2 (1000000)
  +              9 BINARY_MULTIPLY
  +             10 STORE_FAST               2 (L)
  +
  +Build a list by duplicating the passed list N times. Only implemented for
  +list.elements == 1.
  +
  +=cut
  +
  +*/
  +
  +    void multiply_int (INTVAL value,  PMC* dest) {
  +        INTVAL k = DYNSELF.elements();
  +        INTVAL i;
  +        PMC *elem;
  +        PMC **data;
  +
  +        if (k != 1)
  +            internal_exception(1, "multiply_int: unimplemented list size");
  +        elem = VTABLE_get_pmc_keyed_int(INTERP, SELF, 0);
  +        pmc_reuse(INTERP, dest, enum_class_ResizablePMCArray, 0);
  +        VTABLE_set_integer_native(INTERP, dest, value);
  +        data = PMC_data(dest);
  +        for (i = 0; i < value; ++i)
  +            data[i] = elem;
  +    }
  +
   
   }
   
  
  
  
  1.48      +4 -4      parrot/languages/python/pie-thon.pl
  
  Index: pie-thon.pl
  ===================================================================
  RCS file: /cvs/public/parrot/languages/python/pie-thon.pl,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -w -r1.47 -r1.48
  --- pie-thon.pl       15 Jul 2004 14:15:58 -0000      1.47
  +++ pie-thon.pl       16 Jul 2004 16:09:16 -0000      1.48
  @@ -1365,17 +1365,17 @@
       my $v = pop @stack;
       my $w = pop @stack;
       my $x = pop @stack;
  -    push @stack, $w;
  -    push @stack, $x;
       push @stack, $v;
  +    push @stack, $x;
  +    push @stack, $w;
   }
   
   sub STORE_SUBSCR
   {
       my ($n, $c, $cmt) = @_;
  -    my $w = pop @stack;
  -    my $v = pop @stack;
       my $x = pop @stack;
  +    my $v = pop @stack;
  +    my $w = pop @stack;
       my $key = $x->[1];
       if ($v->[0] eq 'hash') {
        if ($key =~ /^\d+$/) {
  
  
  

Reply via email to