view test/test_complex.yeti @ 84:c1c99f26d1fc

More toward structured outputs
author Chris Cannam
date Sun, 17 Mar 2013 22:29:19 +0000
parents 08b2b9fce25c
children
line wrap: on
line source
module test.test_complex;

{ real, imaginary, complex, magnitude, angle, add, scale }
   = load complex;

{ compare } = load test.test;

[

"complex": \( 
    compare (complex 1 2) (complex 1 2) and
        complex (-1) 2 != complex 1 2
),

"real": \(
    compare (real (complex 3 2)) 3
),

"imaginary": \(
    compare (imaginary (complex 3 4)) 4
),

"magnitude": \(
    compare (magnitude (complex (-3) 4)) 5
),

"angle": \(
    compare (angle (complex 1 0)) 0 and
        compare (angle (complex 1 1)) (pi/4) and
        compare (angle (complex 0 1)) (pi/2) and
        compare (angle (complex (-1) 0)) pi and
        compare (angle (complex 0 (-1))) (-pi/2)
),

"add": \(
    compare (add (complex 2 3) (complex (-4) 5)) (complex (-2) 8)
),

"scale": \(
    compare (scale 4 (complex 2 3)) (complex 8 12)
),

] is hash<string, () -> boolean>;