4 . a4/tests a4/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-7.6.3 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 # # 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; a4/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 template ulimit -t 2; a4/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 (\_ -> True) [tail,tail] #case filt not [] test fl template ulimit -t 2; a4/tesths warmup.hs '' case fl (\xs x -> (Data.Char.toUpper x):xs) "" "abc" case fl (\xs x -> (Data.Char.toLower x):xs) "" "AbC" case fl (+) 0 [1..10] case fl (\acc x -> if x == 2 then True else acc) False [1..10] case fl (\xs x -> if (head x) < 2 then (last x):xs else xs) [] (replicate 3 [1,2]) case fl (/) 1 [2,3,4,5] case fl (\a e -> (e,1):a) [] [init,tail] test fr template ulimit -t 2; a4/tesths warmup.hs '' case fr (\x y -> (Data.Char.ord x) + y) 0 "abc" case fr (+) 0 [1..1000000] case fr (\y ys -> ys ++ [y]) [] [1,2,3] case fr (\x acc -> if x==2 then True else acc) False [1..10] case fr (\x xs -> (Data.Char.toLower x):xs) "" "AbC" case fr (/) 1 [2,3] case fr (\e a -> (e,1):a) [] [init,tail] test myany template ulimit -t 2; a4/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 template ulimit -t 2; a4/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]] test zw template ulimit -t 2; a4/tesths warmup.hs '' case zw (+) [1..10] [1000000..] case zw (,) [1..10] [1000000..] case zw (\a b -> (a,Data.Char.chr b)) [1000000..] [32..47] case zw (\a b -> Data.Char.chr b:show a) [1000000..] [58..64] case zw (\x y -> [x,y]) [fst,snd] [snd,fst] # dezip.hs problem dezip dezip.hs build runghc-7.6.3 dezip.hs test dezip template ulimit -t 2; a4/tesths dezip.hs '' #case :type dezip case dezip [(1,10),(2,20),(3,30)] case dezip [("just","testing")] case dezip [("a",1),("b",2),("c",3),("d",4),("e",5),("f",6),("g",7),("h",8),("i",9),("j",10),("k",11),("l",12),("m",13),("n",14),("o",15),("p",16),("q",17),("r",18),("s",19),("t",20),("u",21),("v",22),("w",23),("x",24),("y",25),("z",26)] case dezip [] # repl.hs problem repl repl.hs build runghc-7.6.3 repl.hs test repl template ulimit -t 2; a4/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-7.6.3 doubler.hs test doubler template ulimit -t 2; a4/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-7.6.3 revwords.hs test revwords template ulimit -t 2; a4/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-7.6.3 cpfx.hs test cpfx template ulimit -t 2; a4/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-7.6.3 nnn.hs test nnn template ulimit -t 2; a4/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-7.6.3 expand.hs test expand template ulimit -t 2; a4/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-7.6.3 pancakes.hs test pancakes template echo "" | ghci-7.6.3 -ignore-dot-ghci pancakes.hs 2>&1 | sed 's/^*Main> //' | sed 's/ *$//' #template echo "" #template ulimit -t 2; a4/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 a4/check-hs group.hs test group template runghc-7.6.3 group.hs 2>&1 #template ulimit -t 2; a4/tesths group.hs '' case a4/group.1 case a4/group.2 case a4/group.3 case a4/group.4 case a4/group.5 case a4/group.6 case a4/group.7 problem avg avg.hs build a4/check-hs avg.hs test avg template runghc-7.6.3 avg.hs 2>&1 # # Note: MUST HAVE A SPACE in front of -l, etc. options so that tester doesn't consume the option! # case a4/avg.1 case -l a4/avg.1 case -h a4/avg.1 case a4/avg.2 case a4/avg.3 case -h a4/avg.3 case a4/avg.4 case -l a4/avg.4 case a4/avg.5 case -l a4/avg.5 case -h a4/avg.5 case a4/avg.7 case a4/avg.9 case a4/avg.10 case a4/avg.12 case -l a4/avg.12 case -h a4/avg.12 # rmRanges.hs problem rmRanges rmRanges.hs build runghc-7.6.3 rmRanges.hs test rmRanges template ulimit -t 2; a4/tesths rmRanges.hs '' #case :type rmRanges case rmRanges [(3,7)] [1..10] case rmRanges [(10,18), (2,5), (20,20)] [1..25] case rmRanges [] [1..3] case rmRanges [('\''0'\'','\''9'\'')] "Sat Feb 8 20:34:50 2014" case rmRanges [('\''A'\'','\''Z'\''), ('\'' '\'','\'' '\'')] "Sat Feb :: " case rmRanges [(5,20),(-100,0)] [1..30] case rmRanges [(5,20),(-100,0)] [-10,-9..21]