From 0865df19c63839185b608832f1cfbab63f41eb8a Mon Sep 17 00:00:00 2001
From: simonm <unknown>
Date: Tue, 6 Apr 1999 09:52:03 +0000
Subject: [PATCH] [project @ 1999-04-06 09:52:03 by simonm]
 -funbox-strict-fields test.

---
 ghc/tests/deSugar/should_compile/Makefile |  1 +
 ghc/tests/deSugar/should_compile/ds044.hs | 30 +++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 ghc/tests/deSugar/should_compile/ds044.hs

diff --git a/ghc/tests/deSugar/should_compile/Makefile b/ghc/tests/deSugar/should_compile/Makefile
index 034b977ea9a7..8ed1fdfb8996 100644
--- a/ghc/tests/deSugar/should_compile/Makefile
+++ b/ghc/tests/deSugar/should_compile/Makefile
@@ -5,6 +5,7 @@ include $(TOP)/mk/should_compile.mk
 SRC_HC_OPTS += -noC -dcore-lint
 
 ds035_HC_OPTS = -fglasgow-exts
+ds044_HC_OPTS = -O -funbox-strict-fields
 
 # mkdependHS doesn't understand OPTIONS pragmas...
 SRC_MKDEPENDHS_OPTS += -fglasgow-exts
diff --git a/ghc/tests/deSugar/should_compile/ds044.hs b/ghc/tests/deSugar/should_compile/ds044.hs
new file mode 100644
index 000000000000..15d71995a4a3
--- /dev/null
+++ b/ghc/tests/deSugar/should_compile/ds044.hs
@@ -0,0 +1,30 @@
+module Test where
+
+-- Strict field unpacking tests: compile with -O -funbox-strict-fields.
+
+-- test 1: simple unboxed int field
+data T = T !Int
+t (T i) = i + 1
+
+-- test 2: mutual recursion (should back off from unboxing either field)
+data R = R !R
+data S = S !S
+
+r (R s) = s
+
+-- test 3: multi-level unboxing
+data A = A Int !B Int
+data B = B !Int
+
+f = A 1 (B 2) 1
+g (A x (B y) z) = A x (B (y+2)) z
+h (A x (B y) z) = y + 2
+
+-- test 4: flattening nested tuples
+data C = C !(Int,Int)
+j (C (a,b)) = a + b
+
+-- test 5: polymorphism, multiple strict fields
+data D a b = D Int !(a,b) !(E Int)
+data E a = E a
+k (D a (b,c) (E d)) = a + b + c + d
-- 
GitLab