Commit 486294bf authored by Ian Lynagh's avatar Ian Lynagh

Add tests for quasi-quoting unboxed values

parent 2f2ebd32
{-# LANGUAGE MagicHash, UnboxedTuples #-}
-- test the representation of unboxed literals
module Main where
import GHC.Exts
import GHC.Float
import Language.Haskell.TH
import Text.PrettyPrint
import System.IO
main :: IO ()
main = do putStrLn $ show $ $( do e <- [| 20# |]
runIO $ putStrLn $ show e
runIO $ putStrLn $ pprint e
runIO $ hFlush stdout
[| I# $( return e) |] )
putStrLn $ show $ $( do e <- [| 32## |]
runIO $ putStrLn $ show e
runIO $ putStrLn $ pprint e
runIO $ hFlush stdout
[| W# $(return e) |] )
putStrLn $ show $ $( do e <- [| 12.3# |]
runIO $ putStrLn $ show e
runIO $ putStrLn $ pprint e
runIO $ hFlush stdout
[| F# $(return e) |] )
putStrLn $ show $ $( do e <- [| 24.6## |]
runIO $ putStrLn $ show e
runIO $ putStrLn $ pprint e
runIO $ hFlush stdout
[| D# $(return e) |] )
LitE (IntPrimL 20)
20#
LitE (WordPrimL 32)
32##
LitE (FloatPrimL (123 % 10))
12.3#
LitE (DoublePrimL (123 % 5))
24.6##
{-# LANGUAGE MagicHash, UnboxedTuples #-}
-- test the representation of unboxed literals
module Main
where
import GHC.Exts
import GHC.Float
import Language.Haskell.TH
import Text.PrettyPrint
import System.IO
main :: IO ()
main = do putStrLn $ show $ $( do e <- [| 20# |]
[| I# $(return e) |] )
putStrLn $ show $ $( do e <- [| 32## |]
[| W# $(return e) |] )
putStrLn $ show $ $( do e <- [| 12.3# |]
[| F# $(return e) |] )
putStrLn $ show $ $( do e <- [| 24.6## |]
[| D# $(return e) |] )
......@@ -20,8 +20,10 @@ test('TH_repE1', normal, compile, [''])
test('TH_repE2', normal, compile_and_run, [''])
test('TH_repE3', normal, compile, [''])
test('TH_repPrim', normal, compile, ['-v0'])
test('TH_repPrim2', normal, compile, ['-v0'])
test('TH_spliceGuard', normal, compile, ['-v0'])
test('TH_repPrimOutput', normal, compile_and_run, [''])
test('TH_repPrimOutput2', normal, compile_and_run, [''])
test('TH_repGuard', normal, compile, ['-v0'])
test('TH_repGuardOutput', normal, compile_and_run, [''])
test('TH_repPatSig', normal, compile_fail, [''])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment