setTestOpts(only_compiler_types(['ghc']))

hide_all = '-hide-all-packages -XNoImplicitPrelude '
incr_containers = '-package "containers (Data.Map as Map, Data.Set)" '
inc_containers = '-package containers '
incr_ghc = '-package "ghc (HsTypes as MyHsTypes, HsUtils)" '
inc_ghc = '-package ghc '
hide_ghc = '-hide-package ghc '

def normaliseGhcVersion(str):
    return re.sub('ghc-[0-9.]+', 'ghc-<VERSION>', str)

test('package01',  normal, compile,      [hide_all + incr_containers])
test('package01e', normal, compile_fail, [hide_all + incr_containers])
test('package02',  normal, compile,      [hide_all + inc_containers + incr_containers])
test('package03',  normal, compile,      [hide_all + incr_containers + inc_containers])
test('package04',  normal, compile,      [incr_containers])
test('package05',  normal, compile,      [incr_ghc + inc_ghc])
test('package06',  normal, compile,      [incr_ghc])
test('package06e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc])
test('package07e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc + inc_ghc + hide_ghc])
test('package08e', normalise_errmsg_fun(normaliseGhcVersion), compile_fail, [incr_ghc + hide_ghc])
test('package09e', normal, compile_fail, ['-package "containers (Data.Map as M, Data.Set as M)"'])
test('package10',  normal, compile,      ['-hide-all-packages -package "ghc (UniqFM as Prelude)" '])
