summaryrefslogtreecommitdiff
path: root/testsuite/tests/programs/fun_insts
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/programs/fun_insts
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/programs/fun_insts')
-rw-r--r--testsuite/tests/programs/fun_insts/Main.hs26
-rw-r--r--testsuite/tests/programs/fun_insts/Makefile3
-rw-r--r--testsuite/tests/programs/fun_insts/fun_insts.stdout1
-rw-r--r--testsuite/tests/programs/fun_insts/test.T6
4 files changed, 36 insertions, 0 deletions
diff --git a/testsuite/tests/programs/fun_insts/Main.hs b/testsuite/tests/programs/fun_insts/Main.hs
new file mode 100644
index 0000000000..fece8c9c47
--- /dev/null
+++ b/testsuite/tests/programs/fun_insts/Main.hs
@@ -0,0 +1,26 @@
+-- !!! Defines functions as an instance of Num
+
+module Main where
+
+instance (Eq a, Eq b) => Eq (a->b)
+
+
+instance Show (a->b) where
+ show f = "<<function>>"
+
+instance (Num a, Num b) => Num (a->b) where
+ f + g = \x -> f x + g x
+ negate f = \x -> - (f x)
+ f * g = \x -> f x * g x
+ fromInteger n = \x -> fromInteger n
+
+ss :: Float -> Float
+cc :: Float -> Float
+tt :: Float -> Float
+
+ss = sin * sin
+cc = cos * cos
+tt = ss + cc
+-- sin**2 + cos**2 = 1
+
+main = putStrLn ((show (tt 0.4))++ " "++(show (tt 1.652)))
diff --git a/testsuite/tests/programs/fun_insts/Makefile b/testsuite/tests/programs/fun_insts/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/programs/fun_insts/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/programs/fun_insts/fun_insts.stdout b/testsuite/tests/programs/fun_insts/fun_insts.stdout
new file mode 100644
index 0000000000..7886e5523c
--- /dev/null
+++ b/testsuite/tests/programs/fun_insts/fun_insts.stdout
@@ -0,0 +1 @@
+1.0 1.0
diff --git a/testsuite/tests/programs/fun_insts/test.T b/testsuite/tests/programs/fun_insts/test.T
new file mode 100644
index 0000000000..5151488038
--- /dev/null
+++ b/testsuite/tests/programs/fun_insts/test.T
@@ -0,0 +1,6 @@
+
+test('fun_insts',
+ [skip_if_fast, extra_clean(['Main.hi', 'Main.o'])],
+ multimod_compile_and_run,
+ ['Main', ''])
+