on master help sign in
Merge pull request #388 from JanBessai/StrLenRegressionTest
a97a08bEdwin Brady
idris.cabal+3
@@ -135,6 +135,9 @@ Extra-source-files: lib/Makefile lib/*.idr lib/Prelude/*.idr
135 test/reg019/run
135 test/reg019/run
136 test/reg019/*.idr
136 test/reg019/*.idr
137 test/reg019/expected
137 test/reg019/expected
138+ test/reg020/run
139+ test/reg020/*.idr
140+ test/reg020/expected
138 test/test001/run
141 test/test001/run
139 test/test001/*.idr
142 test/test001/*.idr
140 test/test001/expected
143 test/test001/expected
src/IRTS/CodegenC.hs+2
@@ -364,6 +364,8 @@ doOp v (LSRem (ATInt (ITFixed ty))) [x, y] = bitOp v "SRem" ty [x, y]
364
364
365doOp v (LSExt (ITFixed from) ITBig) [x]
365doOp v (LSExt (ITFixed from) ITBig) [x]
366 = v ++ "MKBIGSI(vm, (" ++ signedTy from ++ ")" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
366 = v ++ "MKBIGSI(vm, (" ++ signedTy from ++ ")" ++ creg x ++ "->info.bits" ++ show (nativeTyWidth from) ++ ")"
367+doOp v (LZExt ITNative ITBig) [x]
368+ = v ++ "MKBIGSI(vm, GETINT(" ++ creg x ++ "))"
367doOp v (LSExt ITNative (ITFixed to)) [x]
369doOp v (LSExt ITNative (ITFixed to)) [x]
368 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
370 = v ++ "idris_b" ++ show (nativeTyWidth to) ++ "const(vm, GETINT(" ++ creg x ++ "))"
369doOp v (LSExt ITChar (ITFixed to)) [x]
371doOp v (LSExt ITChar (ITFixed to)) [x]
test/Makefile+1
@@ -25,6 +25,7 @@ test_js:
25 @perl ./runtest.pl reg017 --codegen node
25 @perl ./runtest.pl reg017 --codegen node
26 @perl ./runtest.pl reg018 --codegen node
26 @perl ./runtest.pl reg018 --codegen node
27 @perl ./runtest.pl reg019 --codegen node
27 @perl ./runtest.pl reg019 --codegen node
28+ @perl ./runtest.pl reg020 --codegen node
28 @perl ./runtest.pl test001 --codegen node
29 @perl ./runtest.pl test001 --codegen node
29 @perl ./runtest.pl test002 --codegen node
30 @perl ./runtest.pl test002 --codegen node
30 @perl ./runtest.pl test003 --codegen node
31 @perl ./runtest.pl test003 --codegen node
test/README+2
@@ -29,3 +29,5 @@ Tests:
29027: class constraints in using block
29027: class constraints in using block
30
30
31regxxx: various regression tests
31regxxx: 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