diff --git a/testsuite/tests/ghci/caf_crash/A.hs b/testsuite/tests/ghci/caf_crash/A.hs new file mode 100644 index 0000000000000000000000000000000000000000..302c3b31321320170b72e75a29bdb9a577930591 --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/A.hs @@ -0,0 +1,18 @@ +module A (caf, mainx, square) where + +import B (idd) + +caf :: Int +caf = 23423 + +mainx :: IO () +mainx = do + putStrLn $ show (caf + idd) + putStrLn "Hello" + putStrLn "World" + +square :: IO Int +square = do + let ss = "I'm a square" + putStrLn $ ss + return $ length ss diff --git a/testsuite/tests/ghci/caf_crash/B.hs b/testsuite/tests/ghci/caf_crash/B.hs new file mode 100644 index 0000000000000000000000000000000000000000..06dc96ee20d0dacf2546666906af04ae70da093f --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/B.hs @@ -0,0 +1,5 @@ +module B (idd) where + +idd :: Int +idd = 100000242418429 + diff --git a/testsuite/tests/ghci/caf_crash/D.hs b/testsuite/tests/ghci/caf_crash/D.hs new file mode 100644 index 0000000000000000000000000000000000000000..3dfcdc99ee1621fc73f7da50cd7ad26c219b0c44 --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/D.hs @@ -0,0 +1,22 @@ +module D where + +import A + +data MyFunc = MyFunc String (IO Int) + +funcCaf :: [MyFunc] +funcCaf = [MyFunc "square" square] + +f1 :: MyFunc -> String +f1 (MyFunc s _) = s + +f2 :: MyFunc -> IO Int +f2 (MyFunc s d) = d + +main :: IO () +main = do + mainx + putStrLn $ show $ length funcCaf + putStrLn $ show $ f1 $ head funcCaf + yay <- f2 $ head funcCaf + print yay diff --git a/testsuite/tests/ghci/caf_crash/all.T b/testsuite/tests/ghci/caf_crash/all.T new file mode 100644 index 0000000000000000000000000000000000000000..6fe22dd454eafd4f492234fa15478832c11b859d --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/all.T @@ -0,0 +1,6 @@ +test('caf_crash', + [extra_files(['A.hs', 'B.hs', 'D.hs', ]), + when(ghc_dynamic(), skip), + extra_ways(['ghci-ext']), + omit_ways(['ghci']), ], + ghci_script, ['caf_crash.script']) diff --git a/testsuite/tests/ghci/caf_crash/caf_crash.script b/testsuite/tests/ghci/caf_crash/caf_crash.script new file mode 100644 index 0000000000000000000000000000000000000000..6e09c2ab21e18fb7c8f581659a9a0b117054a8f5 --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/caf_crash.script @@ -0,0 +1,9 @@ +:set -fobject-code +:l D.hs +:set -fbyte-code +:add *D +main +:l [] +System.Mem.performGC +System.Mem.performGC +3+4 diff --git a/testsuite/tests/ghci/caf_crash/caf_crash.stdout b/testsuite/tests/ghci/caf_crash/caf_crash.stdout new file mode 100644 index 0000000000000000000000000000000000000000..19539a410d062de365df2e8217482fe4d54a77f6 --- /dev/null +++ b/testsuite/tests/ghci/caf_crash/caf_crash.stdout @@ -0,0 +1,7 @@ +100000242441852 +Hello +World +1 +"square" +I'm a square +12