Mercurial > hg > jgplsrc
diff test/tsu.ijs @ 0:e0bbaa717f41 draft default tip
lol J
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Mon, 25 Nov 2013 11:56:30 -0500 |
parents | |
children |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/test/tsu.ijs @@ -0,0 +1,64 @@ +NB. test script utilities ----------------------------------------------- + +1=#$ testpath NB. testpath must already be defined as path to tests (with final / or \) before loading tsu.ijs + +testfiles=: 3 : 0 NB. y. is prefix - e.g., 'g' or 'gm' or 'gs' + testpath&,&.> /:~ {."1 [1!:0 testpath,y,'*.ijs' +) + +ddall =: testfiles 'g' NB. all +ddgmbx =: testfiles 'gmbx' NB. map boxed arrays +ddgsp =: testfiles 'gsp' NB. sparse arrays +ddg =: ddall -. ddgmbx,ddgsp NB. "ordinary" + +etx =: 1 : 'x :: (<:@(13!:11)@i.@0: >@{ 9!:8@i.@0:)' +ex =: ". etx +fex =: }. @ (i.&(10{a.) {. ]) @ (13!:12) @ i. @ 0: @ (0!:110) + +threshold=: 0.75 NB. for timing tests +timer =: 6!:2 + +type =: 3!:0 +imax =: IF64{:: 2147483647; 9223372036854775807 +imin =: (-imax)-1 + +scheck=: 3 : 0 NB. check sparse array + s=. $ y + a=. 2 $. y + e=. 3 $. y + i=. 4 $. y + x=. 5 $. y + + assert. 1 = #$s NB. 0 + assert. s -: <.s NB. 1 + assert. imax >: #s NB. 2 + assert. *./ (0 <: s) *. s <: imax NB. 3 + assert. _ > */s NB. 4 + + assert. 1 = #$a NB. 5 + assert. *./ a e. i.#s NB. 6 + assert. a -: ~.a NB. 7 + + assert. 0 = #$e NB. 8 + assert. (type e) = <. 0.001*type y NB. 9 + assert. (type e) = type x NB. 10 + + assert. 2 = #$i NB. 11 + assert. i -: <.i NB. 12 + assert. imax >: #i NB. 13 + assert. (#i) = #x NB. 14 + assert. ({:$i) = #a NB. 15 + assert. *./, (0<:i) *. i<"1 a{s NB. 16 + assert. i -: ~. i NB. 17 + assert. i -: /:~i NB. 18 + + assert. (#$x) = 1+(#s)-#a NB. 19 + assert. (}.$x) -: ((i.#s)-.a){s NB. 20 + 1 +) + +comb=: 4 : 0 + c=. 1 {.~ - d=. 1+y-x + z=. i.1 0 + for_j. (d-1+y)+/&i.d do. z=. (c#j) ,. z{~;(-c){.&.><i.{.c=. +/\.c end. +)