Commit 1752a9b3 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Rename lexNum test to lex001, and expand it

parent ba5bea9b
......@@ -19,7 +19,7 @@ test('unicode002',
test('data-fixed-show-read', normal, compile_and_run, [''])
test('showDouble', normal, compile_and_run, [''])
test('hash001', normal, compile_and_run, [''])
test('lexNum', normal, compile_and_run, [''])
test('lex001', normal, compile_and_run, [''])
test('take001', extra_run_opts('1'), compile_and_run, [''])
test('genericNegative001', extra_run_opts('-1'), compile_and_run, [''])
test('ix001', normal, compile_and_run, [''])
......
module Main where
import Text.ParserCombinators.ReadP
import qualified Text.Read.Lex
testStrings
= [ "0x3y",
"0X3abx",
......@@ -7,7 +10,12 @@ testStrings
"0O334z",
"NaN",
"NaNx",
"Infinity",
"Infinityx",
"Wibble Foo",
"Wibble8_+",
"34yy",
"34.4x",
......@@ -24,5 +32,8 @@ testStrings
main = mapM test testStrings
test s = print (lex s)
test s = do print s
print (lex s)
print (readP_to_S Text.Read.Lex.lex s)
putStrLn ""
"0x3y"
[("0x3","y")]
[(Number (MkNumber 16 [3]),"y")]
"0X3abx"
[("0X3ab","x")]
[(Number (MkNumber 16 [3,10,11]),"x")]
"0o39y"
[("0o3","9y")]
[(Number (MkNumber 8 [3]),"9y")]
"0O334z"
[("0O334","z")]
[(Number (MkNumber 8 [3,3,4]),"z")]
"NaN"
[("NaN","")]
[(Ident "NaN","")]
"NaNx"
[("NaNx","")]
[(Ident "NaNx","")]
"Infinity"
[("Infinity","")]
[(Ident "Infinity","")]
"Infinityx"
[("Infinityx","")]
[(Ident "Infinityx","")]
"Wibble Foo"
[("Wibble"," Foo")]
[(Ident "Wibble"," Foo")]
"Wibble8_+"
[("Wibble8_","+")]
[(Ident "Wibble8_","+")]
"34yy"
[("34","yy")]
[(Number (MkDecimal [3,4] Nothing Nothing),"yy")]
"34.4x"
[("34.4","x")]
[(Number (MkDecimal [3,4] (Just [4]) Nothing),"x")]
"034.4x"
[("034.4","x")]
[(Number (MkDecimal [0,3,4] (Just [4]) Nothing),"x")]
"31.45e-6y"
[("31.45e-6","y")]
[(Number (MkDecimal [3,1] (Just [4,5]) (Just (-6))),"y")]
"49.2v"
[("49.2","v")]
[(Number (MkDecimal [4,9] (Just [2]) Nothing),"v")]
"049.2v"
[("049.2","v")]
[(Number (MkDecimal [0,4,9] (Just [2]) Nothing),"v")]
"35e-3x"
[("35e-3","x")]
[(Number (MkDecimal [3,5] Nothing (Just (-3))),"x")]
"035e-3x"
[("035e-3","x")]
[(Number (MkDecimal [0,3,5] Nothing (Just (-3))),"x")]
"35e+3y"
[("35e+3","y")]
[(Number (MkDecimal [3,5] Nothing (Just 3)),"y")]
"83.3e-22"
[("83.3e-22","")]
[(Number (MkDecimal [8,3] (Just [3]) (Just (-22))),"")]
"083.3e-22"
[("083.3e-22","")]
[(Number (MkDecimal [0,8,3] (Just [3]) (Just (-22))),"")]
[("0x3","y")]
[("0X3ab","x")]
[("0o3","9y")]
[("0O334","z")]
[("NaN","")]
[("Infinity","")]
[("34","yy")]
[("34.4","x")]
[("034.4","x")]
[("31.45e-6","y")]
[("49.2","v")]
[("049.2","v")]
[("35e-3","x")]
[("035e-3","x")]
[("35e+3","y")]
[("83.3e-22","")]
[("083.3e-22","")]
Supports Markdown
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