Skip to content

Commit d7414ac

Browse files
author
Leonidas Loucas
committed
Add tests for HexFloatLiterals #455
1 parent d4639b7 commit d7414ac

10 files changed

+1014
-0
lines changed

tests/examples/HexFloatLiteralsBad.hs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- Missing hex float literals extension. Should fail.
2+
f :: Float -> ()
3+
f 0xFF.FFp12 = ()
4+
f _ = ()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ParseFailed
2+
(SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1)
3+
"Parse error in pattern: f"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f"
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{-# LANGUAGE HexFloatLiterals #-}
2+
3+
import GHC.Types
4+
5+
main = do
6+
print [ 0x0, -0x0, 0x1, -0x1
7+
, 0xF, -0xF, 0xF, -0xF
8+
, 0x00000000000000000000000000000000000000000000000000000000000000000000000000001
9+
, 0x0000000000000000000000000000000000000000000000000000000000000000000000000000F
10+
, -0x00000000000000000000000000000000000000000000000000000000000000000000000000001
11+
, -0x0000000000000000000000000000000000000000000000000000000000000000000000000000F
12+
, -0x11.11, -0x11.11
13+
, -0xFF.FF, -0xFF.FF
14+
, -0xFF.FFp12, -0xFF.FFp12
15+
, -0xFF.FFp-12, -0xFF.FFp-12
16+
]
17+
18+
print [ 0x0, 0x1, 0x10, 0x11, 0x100, 0x101, 0x110, 0x111 :: Integer
19+
, -0x0, -0x1, -0x10, -0x11, -0x100, -0x101, -0x110, -0x111
20+
, 0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
21+
, -0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
22+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Match

tests/examples/HexFloatLiteralsGood.hs.parser.golden

+959
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Roundtrip test failed
2+
3+
AST 1:
4+
5+
Module () Nothing [LanguagePragma () [Ident () "HexFloatLiterals"]] [ImportDecl {importAnn = (), importModule = ModuleName () "GHC.Types", importQualified = False, importSrc = False, importSafe = False, importPkg = Nothing, importAs = Nothing, importSpecs = Nothing}] [PatBind () (PVar () (Ident () "main")) (UnGuardedRhs () (Do () [Qualifier () (App () (Var () (UnQual () (Ident () "print"))) (List () [Lit () (Int () 0 "0x0"),NegApp () (Lit () (Int () 0 "0x0")),Lit () (Int () 1 "0x1"),NegApp () (Lit () (Int () 1 "0x1")),Lit () (Int () 15 "0xF"),NegApp () (Lit () (Int () 15 "0xF")),Lit () (Int () 15 "0xF"),NegApp () (Lit () (Int () 15 "0xF")),Lit () (Int () 1 "0x00000000000000000000000000000000000000000000000000000000000000000000000000001"),Lit () (Int () 15 "0x0000000000000000000000000000000000000000000000000000000000000000000000000000F"),NegApp () (Lit () (Int () 1 "0x00000000000000000000000000000000000000000000000000000000000000000000000000001")),NegApp () (Lit () (Int () 15 "0x0000000000000000000000000000000000000000000000000000000000000000000000000000F")),NegApp () (Lit () (Frac () (4369 % 256) "0x11.11")),NegApp () (Lit () (Frac () (4369 % 256) "0x11.11")),NegApp () (Lit () (Frac () (65535 % 256) "0xFF.FF")),NegApp () (Lit () (Frac () (65535 % 256) "0xFF.FF")),NegApp () (Lit () (Frac () (1048560 % 1) "0xFF.FFp12")),NegApp () (Lit () (Frac () (1048560 % 1) "0xFF.FFp12")),NegApp () (Lit () (Frac () (65535 % 1048576) "0xFF.FFp-12")),NegApp () (Lit () (Frac () (65535 % 1048576) "0xFF.FFp-12"))])),Qualifier () (App () (Var () (UnQual () (Ident () "print"))) (List () [Lit () (Int () 0 "0x0"),Lit () (Int () 1 "0x1"),Lit () (Int () 16 "0x10"),Lit () (Int () 17 "0x11"),Lit () (Int () 256 "0x100"),Lit () (Int () 257 "0x101"),Lit () (Int () 272 "0x110"),ExpTypeSig () (Lit () (Int () 273 "0x111")) (TyCon () (UnQual () (Ident () "Integer"))),NegApp () (Lit () (Int () 0 "0x0")),NegApp () (Lit () (Int () 1 "0x1")),NegApp () (Lit () (Int () 16 "0x10")),NegApp () (Lit () (Int () 17 "0x11")),NegApp () (Lit () (Int () 256 "0x100")),NegApp () (Lit () (Int () 257 "0x101")),NegApp () (Lit () (Int () 272 "0x110")),NegApp () (Lit () (Int () 273 "0x111")),Lit () (Int () 893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273 "0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"),NegApp () (Lit () (Int () 893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273 "0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"))]))])) Nothing]
6+
7+
AST 2:
8+
9+
Module () Nothing [LanguagePragma () [Ident () "HexFloatLiterals"]] [ImportDecl {importAnn = (), importModule = ModuleName () "GHC.Types", importQualified = False, importSrc = False, importSafe = False, importPkg = Nothing, importAs = Nothing, importSpecs = Nothing}] [PatBind () (PVar () (Ident () "main")) (UnGuardedRhs () (Do () [Qualifier () (App () (Var () (UnQual () (Ident () "print"))) (List () [Lit () (Int () 0 "0"),NegApp () (Lit () (Int () 0 "0")),Lit () (Int () 1 "1"),NegApp () (Lit () (Int () 1 "1")),Lit () (Int () 15 "15"),NegApp () (Lit () (Int () 15 "15")),Lit () (Int () 15 "15"),NegApp () (Lit () (Int () 15 "15")),Lit () (Int () 1 "1"),Lit () (Int () 15 "15"),NegApp () (Lit () (Int () 1 "1")),NegApp () (Lit () (Int () 15 "15")),NegApp () (Lit () (Frac () (4369 % 256) "17.06640625")),NegApp () (Lit () (Frac () (4369 % 256) "17.06640625")),NegApp () (Lit () (Frac () (65535 % 256) "255.99609375")),NegApp () (Lit () (Frac () (65535 % 256) "255.99609375")),NegApp () (Lit () (Frac () (1048560 % 1) "1048560.0")),NegApp () (Lit () (Frac () (1048560 % 1) "1048560.0")),NegApp () (Lit () (Frac () (31249523162841797 % 500000000000000000) "6.2499046325683594e-2")),NegApp () (Lit () (Frac () (31249523162841797 % 500000000000000000) "6.2499046325683594e-2"))])),Qualifier () (App () (Var () (UnQual () (Ident () "print"))) (List () [Lit () (Int () 0 "0"),Lit () (Int () 1 "1"),Lit () (Int () 16 "16"),Lit () (Int () 17 "17"),Lit () (Int () 256 "256"),Lit () (Int () 257 "257"),Lit () (Int () 272 "272"),ExpTypeSig () (Lit () (Int () 273 "273")) (TyCon () (UnQual () (Ident () "Integer"))),NegApp () (Lit () (Int () 0 "0")),NegApp () (Lit () (Int () 1 "1")),NegApp () (Lit () (Int () 16 "16")),NegApp () (Lit () (Int () 17 "17")),NegApp () (Lit () (Int () 256 "256")),NegApp () (Lit () (Int () 257 "257")),NegApp () (Lit () (Int () 272 "272")),NegApp () (Lit () (Int () 273 "273")),Lit () (Int () 893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273 "893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273"),NegApp () (Lit () (Int () 893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273 "893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273"))]))])) Nothing]
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{-# LANGUAGE HexFloatLiterals #-}
2+
import GHC.Types
3+
main
4+
= do print
5+
[0, -0, 1, -1, 15, -15, 15, -15, 1, 15, -1, -15, -17.06640625,
6+
-17.06640625, -255.99609375, -255.99609375, -1048560.0, -1048560.0,
7+
-6.2499046325683594e-2, -6.2499046325683594e-2]
8+
print
9+
[0, 1, 16, 17, 256, 257, 272, 273 :: Integer, -0, -1, -16, -17,
10+
-256, -257, -272, -273,
11+
893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273,
12+
-893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273]

0 commit comments

Comments
 (0)