J Test Scripts
Copyright (c) 2000-2008, Jsoftware Inc.

initial writing: 2000-05-05
last updated: 2008-02-21

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 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 pronoun testpath (set to the path where all the test scripts are stored) and 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:

   testpath=: 'c:\dev\j\js\'    NB. set test path; note the trailing \ or /
   0!:0 <testpath,'tsu.ijs'
   0!:2 <testpath,'g022.ijs'
   NB. >:y -----------------------------------------------------------------

   (>: -: 1&+) 1=?2 3 4$2
1
   (>: -: 1&+) _1e9+?2 3 4$2e9
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:
   testpath=: 'c:\dev\j\js\'
   0!:0 <testpath,'tsu.ijs'
   0!:3 <testpath,'g022.ijs'
1

The J test scripts are divided into three groups (running times are seconds on an AMD Athlon 3200+ 2 GHz computer):

 
Type  Number  Name List  Time (Seconds)
All  400     ddall  110    
Ordinary  342     ddg   73    
Sparse Arrays  46     ddgsp   36    
Mapped Boxed Arrays  12     ddgmbx  1    

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

   testpath=: 'c:\dev\j\js\'
   0!:1 <testpath,'tsu.ijs'
   bbb=: 0!:3 ddall

The boolean list bbb has the same length as ddall , and can be used to detect which test scripts have failed. The bad scripts (-.bbb)#ddall can be run using 0!:2 to home in on the offending expressions.