summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-18 12:17:48 -0400
committerBen Gamari <ben@smart-cactus.org>2019-06-18 15:12:52 -0400
commitf01924adcfbd3c8b087c74bc26d5ddf9559097f7 (patch)
tree3d8d9f5801116ce29b012c0466eb767e4fc59c15
parent2a960c3a04afcfcdb25a13e9a6e65c94c22a169f (diff)
downloadhaskell-wip/reset-static-link-on-revert.tar.gz
testsuite: Add caf_crash testcasewip/reset-static-link-on-revert
-rw-r--r--testsuite/tests/ghci/caf_crash/A.hs18
-rw-r--r--testsuite/tests/ghci/caf_crash/B.hs5
-rw-r--r--testsuite/tests/ghci/caf_crash/D.hs22
-rw-r--r--testsuite/tests/ghci/caf_crash/all.T6
-rw-r--r--testsuite/tests/ghci/caf_crash/caf_crash.script9
-rw-r--r--testsuite/tests/ghci/caf_crash/caf_crash.stdout7
6 files changed, 67 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/caf_crash/A.hs b/testsuite/tests/ghci/caf_crash/A.hs
new file mode 100644
index 0000000000..302c3b3132
--- /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 0000000000..06dc96ee20
--- /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 0000000000..3dfcdc99ee
--- /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 0000000000..6fe22dd454
--- /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 0000000000..6e09c2ab21
--- /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 0000000000..19539a410d
--- /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