| ... |
... |
@@ -3,6 +3,7 @@ |
|
3
|
3
|
{-# LANGUAGE MagicHash #-}
|
|
4
|
4
|
{-# LANGUAGE UnboxedTuples #-}
|
|
5
|
5
|
{-# LANGUAGE UnliftedFFITypes #-}
|
|
|
6
|
+{-# LANGUAGE ExtendedLiterals #-}
|
|
6
|
7
|
|
|
7
|
8
|
-- | This test ensures that sub-word signed and unsigned parameters are correctly
|
|
8
|
9
|
-- handed over to C functions. I.e. it asserts the calling-convention.
|
| ... |
... |
@@ -59,6 +60,31 @@ foreign import ccall "fun32" |
|
59
|
60
|
Int32# -> -- s1
|
|
60
|
61
|
Int64# -- result
|
|
61
|
62
|
|
|
|
63
|
+foreign import ccall "shrink32"
|
|
|
64
|
+ shrink32 ::
|
|
|
65
|
+ Int64# -> -- a0
|
|
|
66
|
+ Int32# -- result
|
|
|
67
|
+
|
|
|
68
|
+foreign import ccall "shrink16"
|
|
|
69
|
+ shrink16 ::
|
|
|
70
|
+ Int64# -> -- a0
|
|
|
71
|
+ Int16# -- result
|
|
|
72
|
+
|
|
|
73
|
+foreign import ccall "shrink8"
|
|
|
74
|
+ shrink8 ::
|
|
|
75
|
+ Int64# -> -- a0
|
|
|
76
|
+ Int8# -- result
|
|
|
77
|
+
|
|
|
78
|
+foreign import ccall "shrink32_16"
|
|
|
79
|
+ shrink32_16 ::
|
|
|
80
|
+ Int32# -> -- a0
|
|
|
81
|
+ Int16# -- result
|
|
|
82
|
+
|
|
|
83
|
+foreign import ccall "shrink32_8"
|
|
|
84
|
+ shrink32_8 ::
|
|
|
85
|
+ Int32# -> -- a0
|
|
|
86
|
+ Int8# -- result
|
|
|
87
|
+
|
|
62
|
88
|
foreign import ccall "funFloat"
|
|
63
|
89
|
funFloat ::
|
|
64
|
90
|
Float# -> -- a0
|
| ... |
... |
@@ -115,6 +141,42 @@ main = do |
|
115
|
141
|
hFlush stdout
|
|
116
|
142
|
assertEqual expected_res32 (I64# res32)
|
|
117
|
143
|
|
|
|
144
|
+ -- Shrinking/zeroing of subword sizes
|
|
|
145
|
+ let input :: Int64# = -1#Int64
|
|
|
146
|
+ res32 :: Int32# = shrink32 input
|
|
|
147
|
+ expected_res32 :: Int32 = fromIntegral (I64# input)
|
|
|
148
|
+ print $ "fun32 result:" ++ show (I64# res32)
|
|
|
149
|
+ hFlush stdout
|
|
|
150
|
+ assertEqual expected_res32 (I64# res32)
|
|
|
151
|
+
|
|
|
152
|
+ let input :: Int64# = -1#Int64
|
|
|
153
|
+ res16 :: Int16# = shrink16 input
|
|
|
154
|
+ expected_res16 :: Int16 = fromIntegral (I64# input)
|
|
|
155
|
+ print $ "shrink16 result:" ++ show (I16# res16)
|
|
|
156
|
+ hFlush stdout
|
|
|
157
|
+ assertEqual expected_res16 (I16# res16)
|
|
|
158
|
+
|
|
|
159
|
+ let input :: Int64# = -1#Int64
|
|
|
160
|
+ res8 :: Int8# = shrink8 input
|
|
|
161
|
+ expected_res8 :: Int8 = fromIntegral (I64# input)
|
|
|
162
|
+ print $ "shrink8 result:" ++ show (I8# res8)
|
|
|
163
|
+ hFlush stdout
|
|
|
164
|
+ assertEqual expected_res8 (I8# res8)
|
|
|
165
|
+
|
|
|
166
|
+ let input32 :: Int32# = -1#Int32
|
|
|
167
|
+ res16 :: Int16# = shrink32_16 input32
|
|
|
168
|
+ expected_res16 :: Int16 = fromIntegral (I32# input32)
|
|
|
169
|
+ print $ "shrink32_16 result:" ++ show (I16# res16)
|
|
|
170
|
+ hFlush stdout
|
|
|
171
|
+ assertEqual expected_res16 (I16# res16)
|
|
|
172
|
+
|
|
|
173
|
+ let input32 :: Int32# = -1#Int32
|
|
|
174
|
+ res8 :: Int8# = shrink32_8 input32
|
|
|
175
|
+ expected_res8 :: Int8 = fromIntegral (I32# input32)
|
|
|
176
|
+ print $ "shrink32_8 result:" ++ show (I8# res8)
|
|
|
177
|
+ hFlush stdout
|
|
|
178
|
+ assertEqual expected_res8 (I8# res8)
|
|
|
179
|
+
|
|
118
|
180
|
let resFloat :: Float = F# (funFloat 1.0# 1.1# 1.2# 1.3# 1.4# 1.5# 1.6# 1.7# 1.8# 1.9#)
|
|
119
|
181
|
print $ "funFloat result:" ++ show resFloat
|
|
120
|
182
|
hFlush stdout
|