blob: 519220fcbbe01fb82685d6a7ad3c806a75ee52ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
(fate_version 1)
(global string test_name)
(set! test_name ( CAST ))
(global int i)
(global float f)
(global string s)
(set! i (cast int ( 42 )))
(assert! (= (var i) 42) [FAILED] (var test_name) equality 1: (var i).)
(set! f (cast float ( 42.57 )))
(assert! (= (var f) 42.57) [FAILED] (var test_name) equality 2: (var f).)
(assert! (= (var i) 42 (cast int (var f))) [FAILED] (var test_name) equality 3: (cast int (var f)).)
;; TO INT
(assert! (= 42 (cast int 42.72)) [FAILED] (var test_name) float->int: (cast int 42.72).)
(assert! (= 42 (cast int (+ 40.70 2.02))) [FAILED] (var test_name) extra float->int: (cast int (+ 40.70 2.02)).)
(assert! (= 42 (cast int 42)) [FAILED] (var test_name) int->int: (cast int 42).)
(assert! (= 42 (cast int (+ 40 2))) [FAILED] (var test_name) extra int->int: (cast int (+ 40 2)).)
(assert! (= 42 (cast int ( 42 ))) [FAILED] (var test_name) string->int: (cast int ( 42 )).)
;; TO FLOAT
(assert!
(>
0.05
(abs
(-
(cast float 42.72)
42.72
)
)
)
[FAILED] (var test_name) float->float: (cast float 42.72).
)
(assert!
(> 0.05
(abs
(-
(cast float (+ 40.70 2.02))
42.72
)
)
)
[FAILED] (var test_name) extra float->float: (cast float (+ 40.70 2.02)).
)
(assert! (= 42.0 (cast float 42)) [FAILED] (var test_name) int->float: (cast float 42).)
(assert! (= 42.0 (cast float (+ 40 2))) [FAILED] (var test_name) extra float->float: (cast float (+ 40 2)).)
(assert!
(> 0.05
(abs
(-
(cast float ( 42.72 ))
42.72
)
)
)
[FAILED] (var test_name) string->float: (cast float ( 42.72 )).
)
;; TO BOOL
(assert! (= (true) (cast bool (true))) [FAILED] (var test_name) bool->bool: (cast bool (true)).)
(assert! (= (true) (cast bool (or (true) (false)))) [FAILED] (var test_name) extra bool->bool: (cast bool (or (true) (false))).)
(assert! (= (true) (cast bool ( true ))) [FAILED] (var test_name) string->bool: (cast bool ( true )).)
;; TO STRING
(assert! (= ( 42 ) (cast string 42)) [FAILED] (var test_name) int->string: (cast string 42).)
(assert! (= ( 42 ) (cast string (+ 40 2))) [FAILED] (var test_name) extra int->string: (cast string (+ 40 2)).)
(assert!
(> 0.05
(abs
(-
(cast float (cast string 42.72))
42.72
)
)
)
[FAILED] (var test_name) float->string: (cast string 42.72).
)
(assert!
(> 0.05
(abs
(-
(cast float (cast string (+ 40.7 2.02)))
42.72
)
)
)
[FAILED] (var test_name) extra float->string: (cast string (+ 40.7 2.02)).
)
(assert! (= ( true ) (cast string (true))) [FAILED] (var test_name) bool->string: (cast string (true)).)
(assert! (= ( true ) (cast string (or (true) (false)))) [FAILED] (var test_name) extra bool->string: (cast string (true)).)
(assert! (= ( something ) (cast string ( something ))) [FAILED] (var test_name) string->string: (cast string ( something )).)
[COMPLETED] (var test_name)
(end!)
|