testsuite: Add caf_crash testcase
authorBen Gamari <ben@smart-cactus.org>
Tue, 18 Jun 2019 16:17:48 +0000 (12:17 -0400)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Sat, 22 Jun 2019 14:06:05 +0000 (10:06 -0400)
testsuite/tests/ghci/caf_crash/A.hs [new file with mode: 0644]
testsuite/tests/ghci/caf_crash/B.hs [new file with mode: 0644]
testsuite/tests/ghci/caf_crash/D.hs [new file with mode: 0644]
testsuite/tests/ghci/caf_crash/all.T [new file with mode: 0644]
testsuite/tests/ghci/caf_crash/caf_crash.script [new file with mode: 0644]
testsuite/tests/ghci/caf_crash/caf_crash.stdout [new file with mode: 0644]

diff --git a/testsuite/tests/ghci/caf_crash/A.hs b/testsuite/tests/ghci/caf_crash/A.hs
new file mode 100644 (file)
index 0000000..302c3b3
--- /dev/null
@@ -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 (file)
index 0000000..06dc96e
--- /dev/null
@@ -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 (file)
index 0000000..3dfcdc9
--- /dev/null
@@ -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 (file)
index 0000000..6fe22dd
--- /dev/null
@@ -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 (file)
index 0000000..6e09c2a
--- /dev/null
@@ -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 (file)
index 0000000..19539a4
--- /dev/null
@@ -0,0 +1,7 @@
+100000242441852
+Hello
+World
+1
+"square"
+I'm a square
+12