Created
January 12, 2010 19:50
-
-
Save domdorn/275537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! runhugs | |
-- Testfaelle fuer Aufgabe 9 der LVA 185.161 Funktionale Programmierung im WS09/10 | |
-- an der Technischen Universitaet Wien | |
-- Aufgabenstellung: http://www.complang.tuwien.ac.at/knoop/fp185161_ws0910.html | |
-- Module ---------------------------------------------------------------------- | |
module Main where | |
-- Imports --------------------------------------------------------------------- | |
import Aufgabe9 | |
import IO (stderr, hPutStr) | |
-- Functions ------------------------------------------------------------------- | |
printTest :: Bool -> IO () | |
printTest False = putStr ("-----> FAILED\n") | |
printTest True = putStr (" PASSED\n") | |
main = | |
do | |
putStr(" Eigene Hilfsfunktion lookupNumber \r\n") | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "" == 0 ) | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "a" == 0 ) | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "aaa" == 1 ) | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "bbb" == 2 ) | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "ccc" == 3 ) | |
printTest( lookupNumber ["aaa", "bbb", "ccc"] "ddd" == 0 ) | |
putStr(" Testfaelle LVA Leitung zu renameTTree \r\n") | |
printTest( renameTTree (TLeaf 3.14) == TLeaf 1 ) | |
printTest( renameTTree (TNode "abc" (TNode "xyz" (TLeaf "abc") (TLeaf "abc") (TLeaf "abc")) (TLeaf "abc") (TLeaf "uv")) == (TNode 1 (TNode 2 (TLeaf 1) (TLeaf 1) (TLeaf 1)) (TLeaf 1) (TLeaf 3)) ) | |
printTest( mRTT (TLeaf 3.14) == (TLeaf 1) ) | |
printTest( mRTT (TNode "abc" (TNode "xyz" (TLeaf "abc") (TLeaf "abc") (TLeaf "abc")) (TLeaf "abc") (TLeaf "uv")) == (TNode 1 (TNode 2 (TLeaf 1) (TLeaf 1) (TLeaf 1)) (TLeaf 1) (TLeaf 3)) ) | |
-- | |
putStr( "numberTree \n\n") | |
printTest( numberTree (Leaf 3.14) == (Leaf 1) ) | |
printTest( numberTree (Node "abc" (Node "xyz" (Leaf "abc") (Leaf "abc")) (Leaf "abc")) == (Node 1 (Node 2 (Leaf 3) (Leaf 4)) (Leaf 5)) ) | |
printTest( numberTree ( Node "1 zeile" (Node "2. Zeile links" (Node "3. zeile 1. elem" ( Leaf "4. Zeile 1. elem" ) ( Leaf "4. Zeile 2. elem" ) )(Node "3. zeile 2. elem" (Node "4. zeile 3. elem" (Leaf "bal") (Leaf "blub") ) (Leaf "3. zeile 4. elem")) )(Node "2. zeile rechts" ( Node "3. zeile 3. elem" (Leaf "bing") (Leaf "google") ) ( Node "3. zeile 4. elem" (Leaf "yahoo") (Leaf "altavista") ) ) ) == ( Node 1 (Node 2 (Node 3 ( Leaf 4 ) ( Leaf 5 ) )(Node 6 (Node 7 (Leaf 8) (Leaf 9) ) (Leaf 10)) )(Node 11 ( Node 12 (Leaf 13) (Leaf 14) ) ( Node 15 (Leaf 16) (Leaf 17) ) ) ) ) | |
-- | |
putStr( "numberTreeMF \n\n") | |
printTest( numberTreeMF (Leaf 3.14) == (Leaf 1) ) | |
printTest( numberTreeMF (Node "abc" (Leaf "abc") (Leaf "abc")) == (Node 1 (Leaf 2) (Leaf 3)) ) | |
printTest( numberTreeMF (Node "abc" (Node "xyz" (Leaf "abc") (Leaf "abc")) (Leaf "abc")) == (Node 1 (Node 2 (Leaf 3) (Leaf 4)) (Leaf 5)) ) | |
printTest( numberTreeMF ( Node "1 zeile" (Node "2. Zeile links" (Node "3. zeile 1. elem" ( Leaf "4. Zeile 1. elem" ) ( Leaf "4. Zeile 2. elem" ) )(Node "3. zeile 2. elem" (Node "4. zeile 3. elem" (Leaf "bal") (Leaf "blub") ) (Leaf "3. zeile 4. elem")) )(Node "2. zeile rechts" ( Node "3. zeile 3. elem" (Leaf "bing") (Leaf "google") ) ( Node "3. zeile 4. elem" (Leaf "yahoo") (Leaf "altavista") ) ) ) == ( Node 1 (Node 2 (Node 3 ( Leaf 4 ) ( Leaf 5 ) )(Node 6 (Node 7 (Leaf 8) (Leaf 9) ) (Leaf 10)) )(Node 11 ( Node 12 (Leaf 13) (Leaf 14) ) ( Node 15 (Leaf 16) (Leaf 17) ) ) ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment