Commit c45d7d70 authored by Michael Hanus 's avatar Michael Hanus

Tests added

parent fcbf7b63
Pipeline #261 failed with stages
......@@ -18,5 +18,9 @@
"source": {
"git": "https://git.ps.informatik.uni-kiel.de/curry-packages/abstract-curry.git",
"tag": "$version"
},
"testsuite": {
"src-dir": "test",
"modules": [ "TestAbstractCurry" ]
}
}
-- Concatenating two lists:
-- (predefined as `++' in the standard prelude)
append :: [t] -> [t] -> [t]
append [] x = x
append (x:xs) ys = x : append xs ys
-- Reverse the order of elements in a list:
rev :: [t] -> [t]
rev [] = []
rev (x:xs) = append (rev xs) [x]
goal1 = append [1,2] [3,4]
goal2 = rev [1,2,3,4]
-- end of program
------------------------------------------------------------------------------
--- Some tests for AbstractCurry libraries.
---
--- To run all tests automatically by the currycheck tool, use the command:
--- "curry-check testAbstractCurry"
---
--- @author Michael Hanus
--- @version September 2017
------------------------------------------------------------------------------
import AbstractCurry.Files
import AbstractCurry.Pretty
import AbstractCurry.Types
import Directory
import Test.EasyCheck
--- Test for equality of an AbstractCurry program with the same program
--- after pretty printing and reading this AbstractCurry program:
readAndTestEqualFcy :: String -> IO Bool
readAndTestEqualFcy mod = do
prog1 <- readAbstractCurryStrict mod
let modcurry = mod ++ ".curry"
modbak = mod ++ ".BAK"
renameFile modcurry modbak
copyFile modbak modcurry
let modpp = mod ++ ".PP"
readCurry mod >>= writeFile modpp . showCProg
removeFile modcurry
renameFile modpp modcurry
prog2 <- readAbstractCurryStrict mod
removeFile modcurry
renameFile modbak modcurry
let abstractequal = prog1 == prog2
unless abstractequal $ do
putStrLn $ "Original AbstractCurry program: " ++ show prog1
putStrLn $ "Pretty printed AbstractCurry program: " ++ show prog2
return abstractequal
-- Strictly read a AbstractCurry program in order to avoid race conditions
-- due to copying/moving source files:
readAbstractCurryStrict :: String -> IO CurryProg
readAbstractCurryStrict mod = do
prog <- readCurry mod
id $!! prog `seq` return prog
testAbstractCurryPretty_rev =
(readAndTestEqualFcy "Rev") `returns` True
testAbstractCurryPretty_TestAbstractCurry =
(readAndTestEqualFcy "TestAbstractCurry") `returns` True
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment