on master help sign in
Regression test for StrLen.
commiteff62f44166ad82e70b9859a43c594e473cb09c4 authorJan Bessai <Jan.Bessai@tu-dortmund.de> dateThu 11 Jul 2013, 19:17 (13 years ago) parent6165c1d
6 files changed+58
idris.cabal+3 test/Makefile+1 test/README+2 test/reg020/expected+7 test/reg020/reg020.idr+41 test/reg020/run+4
idris.cabal+3
@@ -135,6 +135,9 @@ Extra-source-files: lib/Makefile lib/*.idr lib/Prelude/*.idr
135135 test/reg019/run
136136 test/reg019/*.idr
137137 test/reg019/expected
138+ test/reg020/run
139+ test/reg020/*.idr
140+ test/reg020/expected
138141 test/test001/run
139142 test/test001/*.idr
140143 test/test001/expected
test/Makefile+1
@@ -25,6 +25,7 @@ test_js:
2525 @perl ./runtest.pl reg017 --codegen node
2626 @perl ./runtest.pl reg018 --codegen node
2727 @perl ./runtest.pl reg019 --codegen node
28+ @perl ./runtest.pl reg020 --codegen node
2829 @perl ./runtest.pl test001 --codegen node
2930 @perl ./runtest.pl test002 --codegen node
3031 @perl ./runtest.pl test003 --codegen node
test/README+2
@@ -29,3 +29,5 @@ Tests:
2929027: class constraints in using block
3030
3131regxxx: various regression tests
32+reg020: working strlen
33+
test/reg020/expectednew file+7
@@ -0,0 +1,7 @@
1+length of: '' is: 0
2+length of: 'hello world!' is: 12
3+length of: ' ' is: 1
4+length of: ' ' is: 1
5+length of: '
6+' is: 1
7+length of all matches sum of all lengths: True
test/reg020/reg020.idrnew file+41
@@ -0,0 +1,41 @@
1+module Main
2+
3+emptyString : String
4+emptyString = ""
5+
6+helloWorld : String
7+helloWorld = "hello world!"
8+
9+spaceOnly : String
10+spaceOnly = " "
11+
12+tabOnly : String
13+tabOnly = "\t"
14+
15+linebreakOnly : String
16+linebreakOnly = "\n"
17+
18+all : Vect String 5
19+all =
20+ [ emptyString
21+ , helloWorld
22+ , spaceOnly
23+ , tabOnly
24+ , linebreakOnly
25+ ]
26+
27+lengthAll : Nat
28+lengthAll = Strings.length $ foldl (++) (head all) (tail all)
29+
30+sumOfAllLengths : Nat
31+sumOfAllLengths = foldl (\ l, s => l + (Strings.length s)) (Strings.length $ head all) (tail all)
32+
33+
34+main : IO ()
35+main = do putStrLn $ "length of: '" ++ emptyString ++ "' is: " ++ (show $ length emptyString)
36+ putStrLn $ "length of: '" ++ helloWorld ++ "' is: " ++ (show $ length helloWorld)
37+ putStrLn $ "length of: '" ++ spaceOnly ++ "' is: " ++ (show $ length spaceOnly)
38+ putStrLn $ "length of: '" ++ tabOnly ++ "' is: " ++ (show $ length tabOnly)
39+ putStrLn $ "length of: '" ++ linebreakOnly ++ "' is: " ++ (show $ length linebreakOnly)
40+ putStrLn $ "length of all matches sum of all lengths: " ++ (show $ lengthAll == sumOfAllLengths)
41+
test/reg020/runnew file+4
@@ -0,0 +1,4 @@
1+#!/bin/bash
2+idris $@ reg020.idr -o reg020
3+./reg020
4+rm -f reg020 *.ibc