Date Tags cduce

I’ve written a small unit testing suite for cduce using the OUnit library (http://www.xs4all.nl/~mmzeeman/ocaml/ounit-doc/OUnit.html)

Everything is in my dacrs repo waiting for integration: http://web-cduce.pps.jussieu.fr/cgi-bin/darcsweb.cgi?r=cduce;a=summary

I wrote only a handful of tests. This is the main cduce program:

let t1 (s : Latin1) ( t : OUnit.test )    : OUnit.test = (`TestLabel, s, t)
let t2 (s : Latin1) ( f : `nil -> `nil )  : OUnit.test = (`TestLabel, s, (`TestCase, f))
let t3 (s : Latin1) ( l : [OUnit.test*] ) : OUnit.test = (`TestLabel, s, (`TestList, l))

let compare (a : Any) (b : Any) : Bool = a = b

type t = ( `A, Int )

let ae_t      = OUnit.assert_equal with { t } [compare] [] []

let ae_string = OUnit.assert_equal  with { Latin1   } [compare] [] []
let ae_int    = OUnit.assert_equal  with { Caml_int } [compare] [] []
let ae_bool   = OUnit.assert_equal  with { Bool }     [compare] [] []
let ae_Int    = OUnit.assert_equal  with { Int }      [compare] [] []
let ae_float  = OUnit.assert_equal  with { Float }    [compare] [] []
let ae_char   = OUnit.assert_equal  with { Char }     [compare] [] []

let test_funs     ( _ : `nil ) : `nil = ae_Int 45 funs.a

let test_scalar : OUnit.test =
    let factres =
        93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
    in
    let test1 ( _ : `nil ) : `nil = ae_Int factres (scalars.facto 100)
    in
    let test2 ( _ : `nil ) : `nil = ae_Int 10 (scalars.abs -10) in
    let test3 ( _ : `nil ) : `nil = ae_Int 10 (scalars.wrap 100) in
    let test4 ( _ : `nil ) : `nil = ae_Int 10 (scalars.exp_wrap 100) in
    let test5 ( _ : `nil ) : `nil =
        try let _ = (scalars.exp_wrap 101) in raise "Failure"
        with _ -> `nil
    in
    let test6 ( _ : `nil ) : `nil = ae_Int 35 (scalars.eval (`add, 10,
    (`add, 20, 5))) in
    let test7 ( _ : `nil ) : `nil = ae_bool `true (scalars.interval_unicode 'a')
    in
    let test8 ( _ : `nil ) : `nil = ae_bool `false (scalars.interval_unicode 'z')
    in
    let test9 ( _ : `nil ) : `nil = ae_Int 97 (scalars.ic 'a') in
    let test10 ( _ : `nil ) : `nil = ae_char 'a' (scalars.ci 97) in
    let test11 ( _ : `nil ) : `nil =
        namespace ns1 = "A" in
        ae_bool `true (compare `ns1:B scalars.atom) in
    let test12 ( _ : `nil ) : `nil = ae_bool `true (compare [ "A" 'B' ]
    scalars.split) in
    t3 "Test Scalars" [
        (t2 "facto"  test1)
        (t2 "abs"  test2)
        (t2 "wrap"  test3)
        (t2 "exception wrap positive"  test4)
        (t2 "exception wrap negative"  test5)
        (t2 "expr eval negative"  test6)
        (t2 "interval unicode positive"  test7)
        (t2 "interval unicode negative"  test8)
        (t2 "int of char"  test9)
        (t2 "char of int"  test10)
        (t2 "atom"  test11)
        (t2 "split"  test12)
]

let test_operators : OUnit.test =
    let test1 ( _ : `nil ) : `nil =
        ae_bool `true (compare [ 1 2 3 4 ] (operators.seq [1 2] [3 4]))
    in
    let test2 ( _ : `nil ) : `nil = ae_bool `true (operators.neq 1 2) in
    let test3 ( _ : `nil ) : `nil = ae_bool `true notes.load_notes in

    t3 "Test Built-in Operators" [
        (t2 "Sequence"  test1)
        (t2 "neq"  test2)
        (t2 "load_xml"  test3)
    ]


let suite : OUnit.test = t3 "Cduce test suite" [
    test_scalar
    test_operators
]

let _ = OUnit.run_test_tt_main suite