Unit tests for Literate Haskell litprog
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 16 Mar 2008 09:56:47 +0000 (10:56 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 31 Mar 2008 22:41:51 +0000 (00:41 +0200)
test/expected_dir/lithask1.lhs/documentation/blanks [new file with mode: 0644]
test/expected_dir/lithask1.lhs/documentation/comment [new file with mode: 0644]
test/expected_dir/lithask1.lhs/haskell/blanks [new file with mode: 0644]
test/expected_dir/lithask1.lhs/haskell/code [new file with mode: 0644]
test/expected_dir/lithask2.lhs/documentation/blanks [new file with mode: 0644]
test/expected_dir/lithask2.lhs/documentation/comment [new file with mode: 0644]
test/expected_dir/lithask2.lhs/haskell/blanks [new file with mode: 0644]
test/expected_dir/lithask2.lhs/haskell/code [new file with mode: 0644]
test/src_dir/lithask1.lhs [new file with mode: 0644]
test/src_dir/lithask2.lhs [new file with mode: 0644]
test/unit/lit_haskell_test.rb [new file with mode: 0644]

diff --git a/test/expected_dir/lithask1.lhs/documentation/blanks b/test/expected_dir/lithask1.lhs/documentation/blanks
new file mode 100644 (file)
index 0000000..7813681
--- /dev/null
@@ -0,0 +1 @@
+5
\ No newline at end of file
diff --git a/test/expected_dir/lithask1.lhs/documentation/comment b/test/expected_dir/lithask1.lhs/documentation/comment
new file mode 100644 (file)
index 0000000..5069232
--- /dev/null
@@ -0,0 +1,5 @@
+Example taken from http://www.haskell.org/onlinereport/literate.html,
+with additional tripping characters.
+This literate > program > prompts the user for a number
+>and prints the factorial of that number:
+This is the factorial function.
diff --git a/test/expected_dir/lithask1.lhs/haskell/blanks b/test/expected_dir/lithask1.lhs/haskell/blanks
new file mode 100644 (file)
index 0000000..c227083
--- /dev/null
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/test/expected_dir/lithask1.lhs/haskell/code b/test/expected_dir/lithask1.lhs/haskell/code
new file mode 100644 (file)
index 0000000..189a8c7
--- /dev/null
@@ -0,0 +1,8 @@
+> main :: IO ()
+> main = do putStr "Enter a number: "
+>           l <- readLine
+>           putStr "n!= "
+>           print (fact (read l))
+> fact :: Integer -> Integer
+> fact 0 = 1
+> fact n = n * fact (n-1)
diff --git a/test/expected_dir/lithask2.lhs/documentation/blanks b/test/expected_dir/lithask2.lhs/documentation/blanks
new file mode 100644 (file)
index 0000000..62f9457
--- /dev/null
@@ -0,0 +1 @@
+6
\ No newline at end of file
diff --git a/test/expected_dir/lithask2.lhs/documentation/comment b/test/expected_dir/lithask2.lhs/documentation/comment
new file mode 100644 (file)
index 0000000..3189b77
--- /dev/null
@@ -0,0 +1,9 @@
+\documentstyle{article}
+\begin{document}
+\section{Introduction}
+Example taken from http://www.haskell.org/onlinereport/literate.html,
+with additional tripping characters.
+This is a trivial \begin{code}program\end{code} that prints the first 20 factorials.
+\begin{code}
+\end{code}
+\end{document}
diff --git a/test/expected_dir/lithask2.lhs/haskell/blanks b/test/expected_dir/lithask2.lhs/haskell/blanks
new file mode 100644 (file)
index 0000000..c227083
--- /dev/null
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/test/expected_dir/lithask2.lhs/haskell/code b/test/expected_dir/lithask2.lhs/haskell/code
new file mode 100644 (file)
index 0000000..86be852
--- /dev/null
@@ -0,0 +1,2 @@
+main :: IO ()
+main =  print [ (n, product [1..n]) | n <- [1..20]]
diff --git a/test/src_dir/lithask1.lhs b/test/src_dir/lithask1.lhs
new file mode 100644 (file)
index 0000000..67e9f6f
--- /dev/null
@@ -0,0 +1,18 @@
+Example taken from http://www.haskell.org/onlinereport/literate.html,
+with additional tripping characters.
+
+   This literate > program > prompts the user for a number
+   >and prints the factorial of that number:
+
+> main :: IO ()
+
+> main = do putStr "Enter a number: "
+>           l <- readLine
+>           putStr "n!= "
+>           print (fact (read l))
+          
+  This is the factorial function.
+
+> fact :: Integer -> Integer
+> fact 0 = 1
+> fact n = n * fact (n-1)
diff --git a/test/src_dir/lithask2.lhs b/test/src_dir/lithask2.lhs
new file mode 100644 (file)
index 0000000..919853c
--- /dev/null
@@ -0,0 +1,17 @@
+\documentstyle{article}
+
+\begin{document}
+
+\section{Introduction}
+
+Example taken from http://www.haskell.org/onlinereport/literate.html,
+with additional tripping characters.
+
+This is a trivial \begin{code}program\end{code} that prints the first 20 factorials.
+
+\begin{code}
+main :: IO ()
+main =  print [ (n, product [1..n]) | n <- [1..20]]
+\end{code}
+
+\end{document}
diff --git a/test/unit/lit_haskell_test.rb b/test/unit/lit_haskell_test.rb
new file mode 100644 (file)
index 0000000..cfdeddb
--- /dev/null
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class Ohcount::LitHaskellTest < Ohcount::Test
+       def test_comprehensive
+               verify_parse("lithask1.lhs")
+               verify_parse("lithask2.lhs")
+       end
+end