3 . /cs/www/classes/cs372/spring15/a3/tests /cs/www/classes/cs372/spring15/a3/master # # 'problem' lines specify a problem name (for -p) and source file(s) for the problem problem warmup warmup.hs # # Just 'runghc' is enough to see if it compiles. If there's a compilation error, there's # an exit code of 1. If not, it should encounter a missing main, but then the exit code is 0. # If that latter behavior changes then we'll need to go back to using build-hs # build runghc warmup.hs # # 'test' lines specify a test name and then any files that should be # copied from the tests directory ($t) into the student's directory before # running the tests. (Take a look at $t/tesths) # test mp tesths # # A 'template' line specifies the command that should be run for # the following cases. The text "" is replaced by the text # of each case in turn, starting with the text after any options. # # warmup.hs template ulimit -t 2; ./tesths warmup.hs '' case mp (\x -> x*x) [1,2,3,4] case mp Data.Char.toUpper "abcde" case mp even [1..100] case mp length [[1],[1..2],[1..3],[1..4]] case length (mp (\x -> [x]) [tail, init]) test filt tesths template ulimit -t 2; ./tesths warmup.hs '' case filt even [1,2,3] case filt Data.Char.isUpper "aBcDe" case filt odd [1,2] case filt ((<) 5) [1..10] #case filt not [] test fldl tesths template ulimit -t 2; ./tesths warmup.hs '' case fldl (\xs x -> (Data.Char.toUpper x):xs) "" "abc" case fldl (\xs x -> (Data.Char.toLower x):xs) "" "AbC" case fldl (+) 0 [1..10] case fldl (\acc x -> if x == 2 then True else acc) False [1..10] case fldl (\xs x -> if (head x) < 2 then (last x):xs else xs) [] (replicate 3 [1,2]) case fldl (/) 1 [2,3,4,5] test fldr tesths template ulimit -t 2; ./tesths warmup.hs '' case fldr (\x y -> (Data.Char.ord x) + y) 0 "abc" case fldr (+) 0 [1..1000000] case fldr (\y ys -> ys ++ [y]) [] [1,2,3] case fldr (\x acc -> if x==2 then True else acc) False [1..10] case fldr (\x xs -> (Data.Char.toLower x):xs) "" "AbC" case fldr (/) 1 [2,3] test myany tesths template ulimit -t 2; ./tesths warmup.hs '' case myany Data.Char.isDigit "abc" case myany Data.Char.isDigit "abcd 1 dcba" case myany (>5) [1..5] case myany (\x -> all Data.Char.isLetter x) ["a","ab","abc"] case myany (\x -> (length x)>3) [[1],[1..2],[1..3],[1..4]] test myall tesths template ulimit -t 2; ./tesths warmup.hs '' case myall Data.Char.isLetter "abc" case myall Data.Char.isLetter "abc1cba" case myall (>0) [1..5] case myall (\x -> any Data.Char.isLetter x) ["a","ab","abc"] case myall (\x -> (length x)>1) [[1],[1..2],[1..3],[1..4]] # dezip.hs problem dezip dezip.hs build runghc dezip.hs test dezip template ulimit -t 2; ./tesths dezip.hs '' #case :type dezip case dezip [(1,10),(2,20),(3,30)] case dezip [("just","testing")] case dezip [] # repl.hs problem repl repl.hs build runghc repl.hs test repl template ulimit -t 2; ./tesths repl.hs '' #case :t repl case repl 3 7 case repl 3 "a" case repl 5 '\''a'\'' case repl 2 it # doubler.hs problem doubler doubler.hs build runghc doubler.hs test doubler template ulimit -t 2; ./tesths doubler.hs '' #case :t doubler case doubler [1..5] case doubler "bet" case doubler [5, 1, 3, 7] case doubler [[]] case doubler ["abc","def"] case doubler [] # revwords.hs problem revwords revwords.hs build runghc revwords.hs test revwords template ulimit -t 2; ./tesths revwords.hs '' case revwords "Reverse the words in this sentence" case revwords "The quick brown fox jumped over the lazy dog" case revwords "testing" case revwords "" # cpfx.hs problem cpfx cpfx.hs build runghc cpfx.hs test cpfx tesths template ulimit -t 2; ./tesths cpfx.hs '' case cpfx ["abc", "ab", "abcd"] case cpfx ["abc", "abcef", "a123"] case cpfx ["xabc", "xabcef", "axbc"] case cpfx ["obscure", "obscures", "obscured", "obscuring"] case cpfx ["abc", "acb", "bac"] case cpfx ["xabc"] case cpfx ["aaa", "aaa", "aaa"] case cpfx ["aaa", "aa", "a"] case cpfx ["", "123", "123", "123"] case cpfx $ map show [20..29] case cpfx $ map show [1000..1099] # nnn.hs problem nnn nnn.hs build runghc nnn.hs test nnn tesths template ulimit -t 2; ./tesths nnn.hs '' #case :t nnn case nnn [1,3..10] case nnn [3,1,5] case nnn [10,2,4] case length (head (nnn [100])) case nnn [] case nnn [100,1,2,3] # expand.hs problem expand expand.hs build runghc expand.hs test expand tesths template ulimit -t 2; ./tesths expand.hs '' #case :t expand case expand "code,s,d,@ing" case expand "program,s,#ed,#ing,'\''s" case expand "adrift" case expand "a,b,c,d,e,f" case expand "a,b,c,d,@x,@y,@z,#1,#2,#3" case expand "ab,#c,d,@e,f,::x" # pancakes.hs problem pancakes pancakes.hs build runghc pancakes.hs test pancakes tesths template echo "" | ghci -ignore-dot-ghci pancakes.hs 2>&1 | sed 's/^*Main> //' | sed 's/ *$//' #template echo "" #template ulimit -t 2; ./tesths pancakes.hs '' #case :t pancakes case pancakes [[3,1],[3,1,5]] case pancakes [[1,5],[1,1,1],[11,3,15],[3,3,3,3],[1]] case pancakes [[1],[1,1,1],[11,3,15],[3,3,3,3],[1]] case pancakes [[7,1,1,1,1,1],[5,7,7,7,7,5],[7,5,3,1,1,1],[5,7,7,7,7,5], [7,1,1,1,1,1],[1,3,3,5,5,7]] case pancakes [[1]] case pancakes [[7,5,3,1,3,5,7],[7,5,3,3,5,7],[7,5,5,7],[7,7]] case pancakes (map (\\\f -> [f]) [1,3..100]) case pancakes (map (\\\f -> replicate f f) [1,3..21]) case pancakes (map (\\\f -> concat $ replicate f [1]) [1,3..21]) case pancakes (map (\\\n -> [n,n+2..121]) [101,103..121]) # group.hs problem group group.hs # # check-hs attempts to provide a quick compile check build a3/check-hs group.hs test group template runghc group.hs 2>&1 #template ulimit -t 2; ./tesths group.hs '' case a3/group.1 case a3/group.2 case a3/group.3 case a3/group.4 case a3/group.5 case a3/group.6 case a3/group.7 problem avg avg.hs build a3/check-hs avg.hs test avg template runghc avg.hs 2>&1 case a3/avg.1 case -l a3/avg.1 case -h a3/avg.1 case a3/avg.2 case a3/avg.3 case -h a3/avg.3 case a3/avg.4 case -l a3/avg.4 case a3/avg.5 case -l a3/avg.5 case -h a3/avg.5 case a3/avg.7 case a3/avg.9 case a3/avg.10 case a3/avg.12 case -l a3/avg.12 case -h a3/avg.12 /* 0 case a3/avg.1 1 case -l a3/avg.1 2 case -h a3/avg.1 3 case a3/avg.2 4 case a3/avg.3 5 case -h a3/avg.3 6 case a3/avg.4 7 case -l a3/avg.4 8 case a3/avg.5 9 case -l a3/avg.5 case -h a3/avg.5 case a3/avg.7 case a3/avg.9 case a3/avg.10 case a3/avg.12 case -l a3/avg.12 case -h a3/avg.12 */ # mfilter.hs problem mfilter mfilter.hs build runghc mfilter.hs test mfilter tesths template ulimit -t 2; ./tesths mfilter.hs '' #case :type mfilter case mfilter [(3,7)] [1..10] case mfilter [(10,18), (2,5), (20,20)] [1..25] case mfilter [] [1..3] case mfilter [('\''0'\'','\''9'\'')] "Sat Feb 8 20:34:50 2014" case mfilter [('\''A'\'','\''Z'\''), ('\'' '\'','\'' '\'')] "Sat Feb :: " case mfilter [(5,20),(-100,0)] [1..30] case mfilter [(5,20),(-100,0)] [-10,-9..21]