-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonidas Loucas
committed
Jun 29, 2020
1 parent
d4639b7
commit 9872cc4
Showing
10 changed files
with
1,014 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Missing hex float literals extension. Should fail. | ||
f :: Float -> () | ||
f 0xFF.FFp12 = () | ||
f _ = () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ParseFailed | ||
(SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) | ||
"Parse error in pattern: f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ParseFailed (SrcLoc "tests/examples/HexFloatLiteralsBad.hs" 4 1) "Parse error in pattern: f" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{-# LANGUAGE HexFloatLiteral #-} | ||
|
||
import GHC.Types | ||
|
||
main = do | ||
print [ 0x0, -0x0, 0x1, -0x1 | ||
, 0xF, -0xF, 0xF, -0xF | ||
, 0x00000000000000000000000000000000000000000000000000000000000000000000000000001 | ||
, 0x0000000000000000000000000000000000000000000000000000000000000000000000000000F | ||
, -0x00000000000000000000000000000000000000000000000000000000000000000000000000001 | ||
, -0x0000000000000000000000000000000000000000000000000000000000000000000000000000F | ||
, -0x11.11, -0x11.11 | ||
, -0xFF.FF, -0xFF.FF | ||
, -0xFF.FFp12, -0xFF.FFp12 | ||
, -0xFF.FFp-12, -0xFF.FFp-12 | ||
] | ||
|
||
print [ 0x0, 0x1, 0x10, 0x11, 0x100, 0x101, 0x110, 0x111 :: Integer | ||
, -0x0, -0x1, -0x10, -0x11, -0x100, -0x101, -0x110, -0x111 | ||
, 0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
, -0x11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Match |
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
tests/examples/HexFloatLiteralsGood.hs.prettyparser.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Roundtrip test failed | ||
|
||
AST 1: | ||
|
||
Module () Nothing [LanguagePragma () [Ident () "HexFloatLiteral"]] [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] | ||
|
||
AST 2: | ||
|
||
Module () Nothing [LanguagePragma () [Ident () "HexFloatLiteral"]] [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] | ||
|
12 changes: 12 additions & 0 deletions
12
tests/examples/HexFloatLiteralsGood.hs.prettyprinter.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{-# LANGUAGE HexFloatLiteral #-} | ||
import GHC.Types | ||
main | ||
= do print | ||
[0, -0, 1, -1, 15, -15, 15, -15, 1, 15, -1, -15, -17.06640625, | ||
-17.06640625, -255.99609375, -255.99609375, -1048560.0, -1048560.0, | ||
-6.2499046325683594e-2, -6.2499046325683594e-2] | ||
[0, 1, 16, 17, 256, 257, 272, 273 :: Integer, -0, -1, -16, -17, | ||
-256, -257, -272, -273, | ||
893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273, | ||
-893853861996173139971601666547056408498624388039492891848237429581450935338236465120124953211126895179335457212432403390250258854129771329762243267072273] |