Test Scripts
An Implementation of J
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' 10!: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' 1The 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 |
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 endThe 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.