update to fp2 yay, public and licence
[fp1415.git] / fp1 / week2 / mart / VectorOverloadingTest.icl
1 module VectorOverloadingTest
2
3 /* Test module VectorOverloading
4 Voor werken met Gast:
5 (*) gebruik Environment 'Gast'
6 (*) zet Project Options op 'Basic Values Only'
7 */
8
9 import VectorOverloading
10 import StdEnv
11 import gast
12
13 Start
14 = testn 1000
15 (\v ->
16 zero_is_neutral_for_addition v /\
17 zero_is_neutral_for_subtraction v /\
18 one_is_neutral_for_multiplication v /\
19 one_is_neutral_for_division v /\
20 negation_is_idempotent v /\
21 add_then_subtract_yields_identity v /\
22 subtract_then_add_yields_identity v /\
23 True
24 )
25
26 :: BaseType
27 :== Int
28 // :== Real
29
30 zero_is_neutral_for_addition :: (Vector2 BaseType) -> Property
31 zero_is_neutral_for_addition a = name "zero_is_neutral_for_addition"
32 (zero + a == a && a == a + zero)
33
34 zero_is_neutral_for_subtraction :: (Vector2 BaseType) -> Property
35 zero_is_neutral_for_subtraction a = name "zero_is_neutral_for_subtraction"
36 (a - zero == a && a == ~ (zero - a))
37
38 one_is_neutral_for_multiplication :: (Vector2 BaseType) -> Property
39 one_is_neutral_for_multiplication a = name "one_is_neutral_for_multiplication"
40 (one * a == a && a == a * one)
41
42 zero_is_zero_for_multiplication :: (Vector2 BaseType) -> Property
43 zero_is_zero_for_multiplication a = name "zero_is_zero_for_multiplication"
44 (zero * a == zero && zero == a * zero)
45
46 one_is_neutral_for_division :: (Vector2 BaseType) -> Property
47 one_is_neutral_for_division a = name "one_is_neutral_for_division"
48 (a / one == a)
49
50 negation_is_idempotent :: (Vector2 BaseType) -> Property
51 negation_is_idempotent a = name "negation_is_idempotent"
52 (~ (~ a) == a)
53
54 add_then_subtract_yields_identity :: (Vector2 BaseType) -> Property
55 add_then_subtract_yields_identity a = name "add then subtract" ((a + a) - a == a)
56
57 subtract_then_add_yields_identity :: (Vector2 BaseType) -> Property
58 subtract_then_add_yields_identity a = name "subtract then add" ((zero - a - a) + a + a == zero)
59
60 derive genShow Vector2
61 derive ggen Vector2
62 derive bimap []