Commit fe35b85a authored by Joachim Breitner's avatar Joachim Breitner

Add testcase for #14186

and move the generally useful helpers check_errmsg and grep_errmsg to
testlib.py. Some documentation can be found on
https://ghc.haskell.org/trac/ghc/wiki/Building/RunningTests/Adding
parent 838a10fc
......@@ -520,6 +520,19 @@ def normalise_errmsg_fun( *fs ):
def _normalise_errmsg_fun( name, opts, *fs ):
opts.extra_errmsg_normaliser = join_normalisers(opts.extra_errmsg_normaliser, fs)
def check_errmsg(needle):
def norm(str):
if needle in str:
return "%s contained in -ddump-simpl\n" % needle
else:
return "%s not contained in -ddump-simpl\n" % needle
return normalise_errmsg_fun(norm)
def grep_errmsg(needle):
def norm(str):
return "".join(filter(lambda l: re.search(needle, l), str.splitlines(True)))
return normalise_errmsg_fun(norm)
def normalise_whitespace_fun(f):
return lambda name, opts: _normalise_whitespace_fun(name, opts, f)
......
module T14186 where
foo f g (x, xs) = (f (g x), map (f . g) xs)
bar f g (x, xs) = (f (g x), map (f . g) xs)
==================== Tidy Core ====================
Result size of Tidy Core
= {terms: 52, types: 99, coercions: 0, joins: 0/0}
-- RHS size: {terms: 18, types: 29, coercions: 0, joins: 0/0}
foo
:: forall t1 b t2.
(t1 -> b) -> (t2 -> t1) -> (t2, [t2]) -> (b, [b])
[GblId, Arity=3]
foo
= \ (@ t_aUk)
(@ b_aUs)
(@ t1_aUo)
(f_apH :: t_aUk -> b_aUs)
(g_apI :: t1_aUo -> t_aUk)
(ds_dVH :: (t1_aUo, [t1_aUo])) ->
case ds_dVH of { (x_apJ, xs_apK) ->
(f_apH (g_apI x_apJ),
map
@ t1_aUo @ b_aUs (. @ t_aUk @ b_aUs @ t1_aUo f_apH g_apI) xs_apK)
}
-- RHS size: {terms: 18, types: 29, coercions: 0, joins: 0/0}
bar
:: forall t1 b t2.
(t1 -> b) -> (t2 -> t1) -> (t2, [t2]) -> (b, [b])
[GblId, Arity=3]
bar = foo
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
$trModule1_rVy :: GHC.Prim.Addr#
[GblId, Caf=NoCafRefs]
$trModule1_rVy = "main"#
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
$trModule2_rVX :: GHC.Types.TrName
[GblId, Caf=NoCafRefs]
$trModule2_rVX = GHC.Types.TrNameS $trModule1_rVy
-- RHS size: {terms: 1, types: 0, coercions: 0, joins: 0/0}
$trModule3_rVY :: GHC.Prim.Addr#
[GblId, Caf=NoCafRefs]
$trModule3_rVY = "T14186"#
-- RHS size: {terms: 2, types: 0, coercions: 0, joins: 0/0}
$trModule4_rVZ :: GHC.Types.TrName
[GblId, Caf=NoCafRefs]
$trModule4_rVZ = GHC.Types.TrNameS $trModule3_rVY
-- RHS size: {terms: 3, types: 0, coercions: 0, joins: 0/0}
T14186.$trModule :: GHC.Types.Module
[GblId, Caf=NoCafRefs]
T14186.$trModule = GHC.Types.Module $trModule2_rVX $trModule4_rVZ
......@@ -269,4 +269,8 @@ test('T12600',
['$MAKE -s --no-print-directory T12600'])
test('T13658', normal, compile, ['-dcore-lint'])
test('T13708', normal, compile, [''])
test('T14137', normal, compile, ['-dsuppress-uniques -ddump-simpl'])
# thunk should inline here, so check whether or not it appears in the Core
test('T14137', [ check_errmsg(r'thunk') ], compile, ['-dsuppress-uniques -ddump-simpl'])
# bar and foo should CSEd here, so check for that in the Core
test('T14186', [ only_ways(['optasm']), check_errmsg(r'bar = foo'), expect_broken(14186) ], compile, ['-ddump-simpl'])
# Only compile with optimisation
setTestOpts( only_ways(['optasm']) )
def checkCoreString(needle):
def norm(str):
if needle in str:
return "%s contained in -ddump-simpl\n" % needle
else:
return "%s not contained in -ddump-simpl\n" % needle
return normalise_errmsg_fun(norm)
def grepCoreString(needle):
def norm(str):
return "".join(filter(lambda l: re.search(needle, l), str.splitlines(True)))
return normalise_errmsg_fun(norm)
test('default', normal, compile, [''])
test('fact', normal, compile, [''])
test('fun', normal, compile, [''])
......@@ -39,15 +26,15 @@ test('T8743', [], multimod_compile, ['T8743', '-v0'])
# with two unboxed args. See Trac #10482 for background
#
# Set -dppr-cols to ensure output doesn't wrap
test('T10482', [ grepCoreString(r'wfoo.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T10482a', [ grepCoreString(r'wf.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T10482', [ grep_errmsg(r'wfoo.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T10482a', [ grep_errmsg(r'wf.*Int#') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T9208', when(compiler_debugged(), expect_broken(9208)), compile, [''])
# T9208 fails (and should do so) if you have assertion checking on in the compiler
# Hence the above expect_broken. See comments in the Trac ticket
test('T10694', [ grepCoreString(r'Str=') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T11770', [ checkCoreString('OneShot') ], compile, ['-ddump-simpl'])
test('T10694', [ grep_errmsg(r'Str=') ], compile, ['-dppr-cols=200 -ddump-simpl'])
test('T11770', [ check_errmsg('OneShot') ], compile, ['-ddump-simpl'])
test('T13031', normal, run_command,
['$MAKE -s --no-print-directory T13031'])
......
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