From f01d522a13bd70c60cb7b2d631fe70b19d4e0580 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 16 Mar 2008 10:56:47 +0100 Subject: [PATCH] Unit tests for Literate Haskell --- .../lithask1.lhs/documentation/blanks | 1 + .../lithask1.lhs/documentation/comment | 5 +++++ test/expected_dir/lithask1.lhs/haskell/blanks | 1 + test/expected_dir/lithask1.lhs/haskell/code | 8 ++++++++ .../lithask2.lhs/documentation/blanks | 1 + .../lithask2.lhs/documentation/comment | 9 +++++++++ test/expected_dir/lithask2.lhs/haskell/blanks | 1 + test/expected_dir/lithask2.lhs/haskell/code | 2 ++ test/src_dir/lithask1.lhs | 18 ++++++++++++++++++ test/src_dir/lithask2.lhs | 17 +++++++++++++++++ test/unit/lit_haskell_test.rb | 8 ++++++++ 11 files changed, 71 insertions(+) create mode 100644 test/expected_dir/lithask1.lhs/documentation/blanks create mode 100644 test/expected_dir/lithask1.lhs/documentation/comment create mode 100644 test/expected_dir/lithask1.lhs/haskell/blanks create mode 100644 test/expected_dir/lithask1.lhs/haskell/code create mode 100644 test/expected_dir/lithask2.lhs/documentation/blanks create mode 100644 test/expected_dir/lithask2.lhs/documentation/comment create mode 100644 test/expected_dir/lithask2.lhs/haskell/blanks create mode 100644 test/expected_dir/lithask2.lhs/haskell/code create mode 100644 test/src_dir/lithask1.lhs create mode 100644 test/src_dir/lithask2.lhs create mode 100644 test/unit/lit_haskell_test.rb diff --git a/test/expected_dir/lithask1.lhs/documentation/blanks b/test/expected_dir/lithask1.lhs/documentation/blanks new file mode 100644 index 0000000..7813681 --- /dev/null +++ b/test/expected_dir/lithask1.lhs/documentation/blanks @@ -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 index 0000000..5069232 --- /dev/null +++ b/test/expected_dir/lithask1.lhs/documentation/comment @@ -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 index 0000000..c227083 --- /dev/null +++ b/test/expected_dir/lithask1.lhs/haskell/blanks @@ -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 index 0000000..189a8c7 --- /dev/null +++ b/test/expected_dir/lithask1.lhs/haskell/code @@ -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 index 0000000..62f9457 --- /dev/null +++ b/test/expected_dir/lithask2.lhs/documentation/blanks @@ -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 index 0000000..3189b77 --- /dev/null +++ b/test/expected_dir/lithask2.lhs/documentation/comment @@ -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 index 0000000..c227083 --- /dev/null +++ b/test/expected_dir/lithask2.lhs/haskell/blanks @@ -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 index 0000000..86be852 --- /dev/null +++ b/test/expected_dir/lithask2.lhs/haskell/code @@ -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 index 0000000..67e9f6f --- /dev/null +++ b/test/src_dir/lithask1.lhs @@ -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 index 0000000..919853c --- /dev/null +++ b/test/src_dir/lithask2.lhs @@ -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 index 0000000..cfdeddb --- /dev/null +++ b/test/unit/lit_haskell_test.rb @@ -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 -- 2.32.0.93.g670b81a890