Test Scripts
An Implementation of J



A script is an ASCII text file containing J sentences; a test script is script which contains purportedly true J sentences.

The J test scripts are a set of about 280 scripts that test the J interpreter. Each script tests a particular aspect, usually a single primitive. The scripts have names of the form gxxx.ijs, where xxx is an encoding based on the vocabulary page of the J dictionary. For example, the script g022.ijs tests the primitive >: (increment / larger or equal), named on the basis that >: is group 0, row 2, and column 2.

Test scripts require the utilities in the script tsu.ijs. Test scripts can be run with either the 0!:2 or the 0!:3 primitive.

0!:2 runs a test script with output, stopping at the first result which is not all 1s, or at the first (untrapped) error. For example:

   0!:0 <'\dev\js\tsu.ijs'
   0!:2 <'\dev\js\g022.ijs'
   NB. >:y -----------------------------------------------------------------
   
   (>: -: 1&+) 1=?2 3 4$2
1
   (>: -: 1&+) _1e9+?2 3 4$2e9
1
   (>: -: 1&+) o._1e9+?2 3 4$2e9
1
   (>: -: 1&+) j./?2 3 4$2e9
1
   
   _1 0 1 2 3  -: >: _2 _1 0 1 2
1
   2147483648  -: >: 2147483647
1
   _2147483647 -: >:_2147483648
1
   
   t -: [&.>: t=._1e9+?2 3 4$2e9
1
   
   'domain error' -: >: etx 'abc' 
1
   'domain error' -: >: etx <'abc'  
1
   
   
   NB. x>:y ----------------------------------------------------------------
   
   1 0 1 1 -: 0 0 1 1 >: 0 1 0 1
1
   
   'domain error' -: 'abc' >: etx 3 4 5
1
   'domain error' -: 'abc' >:~etx 3 4 5 
1
   'domain error' -: 3j4   >: etx 3 4 5 
1
   'domain error' -: 3j4   >:~etx 3 4 5
1
   'domain error' -: (<34) >: etx 3 4 5
1
   'domain error' -: (<34) >:~etx 3 4 5 
1
   
   'length error' -: 3 4     >: etx 5 6 7
1

   'length error' -: 3 4     >:~etx 5 6 7
1
   'length error' -: (i.3 4) >: etx i.5 4
1
   'length error' -: (i.3 4) >:~etx i.5 4  
1

   4!:55 ;:'t'
1
0!:3 runs a test script without output, returning a result of 0 if the script had a result which is not all 1s or if it contained an (untrapped) error, and a result of 1 otherwise. For example:
   0!:0 <'\dev\js\tsu.ijs'
   0!:3 <'\dev\js\g022.ijs'
1
The J test scripts are divided into three groups (running times are seconds on a Pentium III 500 MHz computer):

    Type      Number      Name List        Run      Time (Seconds)
Ordinary 240 ddall rundd.ijs 113
Sparse Arrays 27 ssall runss.ijs 1140
Mapped Boxed Arrays 12 mbxall runmbx.ijs 3

For example, the "ordinary" test scripts can be run as follows:

   0!:2 <'\dev\js\rundd.ijs'
   NB. run dd test scripts

   0!:0 <'d:\dev\js\tsu.ijs'               NB. define utilities
   jsts0=: 6!:0 ''                         NB. timestamp at start
   ddall=: 3!:2 (1!:1) <'d:\dev\js\ddall'  NB. define namelist
   ] bbb=: 0!:3 ddall                      NB. run the test scripts
1 1 1 1 1 1 1 1 1 1 1 1 1 ...
   jsts1=: 6!:0 ''                         NB. timestamp at end
The rundd.ijs script first runs the tsu.ijs script (to define the requisite utilities), then defines ddall, the list of test script names, then runs the test scripts. The boolean vector bbb has the same shape as ddall, and can be used to detect which test scripts have failed. The bad scripts (-.b)#ddall can be run using the 0!:2 primitive to narrow in on the offending expressions.



NextPreviousIndexTable of Contents