cvsuser     03/10/03 09:06:38

  Modified:    .        nci_test.c
               t/pmc    nci.t
  Log:
  nci test for struct access
  
  Revision  Changes    Path
  1.7       +9 -0      parrot/nci_test.c
  
  Index: nci_test.c
  ===================================================================
  RCS file: /cvs/public/parrot/nci_test.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -w -r1.6 -r1.7
  --- nci_test.c        2 Oct 2003 13:56:24 -0000       1.6
  +++ nci_test.c        3 Oct 2003 16:06:30 -0000       1.7
  @@ -1,4 +1,5 @@
   #include <stdio.h>
  +#include <malloc.h>
   /*
    * cc -shared -fpic nci_test.c -o libnci.so -g
    * export LD_LIBRARY_PATH=.
  @@ -73,6 +74,14 @@
       int r = a * *b;
       *b = 4711;
       return r;
  +}
  +
  +int * nci_pi(int i) {
  +    int *a = calloc(i, sizeof(int));
  +    a[0] = 42;
  +    a[1] = 100;
  +    a[2] = 200;
  +    return a;
   }
   
   #ifdef TEST
  
  
  
  1.16      +29 -1     parrot/t/pmc/nci.t
  
  Index: nci.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/nci.t,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -w -r1.15 -r1.16
  --- nci.t     2 Oct 2003 13:56:27 -0000       1.15
  +++ nci.t     3 Oct 2003 16:06:38 -0000       1.16
  @@ -1,4 +1,4 @@
  -use Parrot::Test tests => 14;
  +use Parrot::Test tests => 15;
   use Parrot::Config;
   
   print STDERR $PConfig{jitcpuarch}, " JIT CPU\n";
  @@ -377,6 +377,34 @@
     end
   CODE
   ok done
  +OUTPUT
  +
  +output_is(<<'CODE', <<'OUTPUT', "nci_p_i");
  +  loadlib P1, "libnci"
  +  # this test function returns an array of int
  +  dlfunc P0, P1, "nci_pi", "pi"
  +  set I5, 10
  +  invoke
  +  new P2, .PerlArray
  +.include "datatypes.pasm"
  +  push P2, .DATATYPE_INT
  +  push P2, 1
  +  push P2, 0
  +  push P2, .DATATYPE_INT
  +  push P2, 1
  +  sizeof I10, .DATATYPE_INT
  +  push P2, I10
  +  assign P5, P2
  +  set I0, P5[0]
  +  print I0
  +  print "\n"
  +  set I0, P5[1]
  +  print I0
  +  print "\n"
  +  end
  +CODE
  +42
  +100
   OUTPUT
   
   } # SKIP
  
  
  

Reply via email to