Skip to content

Commit

Permalink
Interpreter tests (#3747)
Browse files Browse the repository at this point in the history
* Test I/O and file operations.
  • Loading branch information
ctford authored and Ahmad Salim Al-Sibahi committed Apr 18, 2017
1 parent 502ad1f commit 515ac42
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions test/TestData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ testFamiliesData = [
-- ( 5, ANY ),
( 6, ANY ),
( 7, ANY )]),
("interpret", "Interpret",
[ ( 1, ANY ),
( 2, ANY )]),
("io", "IO monad",
[ ( 1, C_CG ),
( 2, ANY ),
Expand Down
6 changes: 6 additions & 0 deletions test/interpret001/double-echo.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main

main : IO ()
main = do l <- getLine
let ll = l ++ l
putStrLn ll
2 changes: 2 additions & 0 deletions test/interpret001/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
testtest
MkIO (\w => prim_io_pure ()) : IO' (MkFFI C_Types String String) ()
2 changes: 2 additions & 0 deletions test/interpret001/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:x main
test
3 changes: 3 additions & 0 deletions test/interpret001/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
${IDRIS:-idris} $@ --quiet --port none --nocolour double-echo.idr < input
rm -f *.ibc
4 changes: 4 additions & 0 deletions test/interpret002/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
File Not Found
MkIO (\w => prim_io_pure ()) : IO' (MkFFI C_Types String String) ()
"readable"
MkIO (\w => prim_io_pure ()) : IO' (MkFFI C_Types String String) ()
6 changes: 6 additions & 0 deletions test/interpret002/file-error.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Main

echo : String -> IO ()
echo name = do Right contents <- readFile name
| Left error => printLn error
printLn contents
2 changes: 2 additions & 0 deletions test/interpret002/input
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:x echo "not a file"
:x echo "readable.txt"
1 change: 1 addition & 0 deletions test/interpret002/readable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
readable
3 changes: 3 additions & 0 deletions test/interpret002/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
${IDRIS:-idris} $@ --quiet --port none --nocolour file-error.idr < input
rm -f *.ibc

0 comments on commit 515ac42

Please sign in to comment.