Commit 39cc52a4 authored by Michael Hanus 's avatar Michael Hanus

Small fixes to enable tests

parent 96d5f45a
......@@ -10,16 +10,16 @@ import Test.Prop
showInt i = ``format "%+.3d",i''
-- Bubble sort formulation with default rule as deterministic operation:
sort :: (Ord a, Show a) => [a] ->DET [a]
sort :: (Data a, Ord a, Show a) => [a] ->DET [a]
sort (xs++[x,y]++ys) | x>y = sort (xs++[y,x]++ys)
sort'default xs = xs
-- Precondition: we don't like to sort empty lists...
sort'pre :: (Ord a, Show a) => [a] -> Bool
sort'pre :: (Data a, Ord a, Show a) => [a] -> Bool
sort'pre xs = length xs > 0
-- Postcondition: input and output lists should have the same length
sort'post :: (Ord a, Show a) => [a] -> [a] -> Bool
sort'post :: (Data a, Ord a, Show a) => [a] -> [a] -> Bool
sort'post xs ys = length xs == length ys
sort7 = sort (map showInt [7,1,6,3,5,4,2]) -=- map (\d -> "+00"++show d) [1..7]
......
......@@ -6,11 +6,13 @@ import Test.Prop
-- A specification of sorting a list and an implementation based
-- on the quicksort algorithm
perm :: [a] -> [a]
perm [] = []
perm (x:xs) = insert (perm xs)
where insert ys = x:ys
insert (y:ys) = y : insert ys
sorted :: Ord a => [a] -> Bool
sorted [] = True
sorted [_] = True
sorted (x:y:ys) = x<=y && sorted (y:ys)
......
......@@ -7,7 +7,7 @@ import Test.Prop
-- they do not work on infinite lists due to restrictions on set functions.
-- take with default rule:
take :: Int -> [a] -> [a]
take :: Data a => Int -> [a] -> [a]
take n (x:xs) | n>0 = x : take (n-1) xs
take'default _ _ = []
......@@ -19,7 +19,7 @@ takeTest3 = take 3 [1,2] -=- [1,2]
-- zip3 with default rule (slight disadvantage: stricter than Prelude.zip3):
zip3 :: [a] -> [b] -> [c] -> [(a,b,c)]
zip3 :: (Data a, Data b, Data c) => [a] -> [b] -> [c] -> [(a,b,c)]
zip3 (x:xs) (y:ys) (z:zs) = (x,y,z) : zip3 xs ys zs
zip3'default _ _ _ = []
......
......@@ -4,7 +4,7 @@
import Test.Prop
-- Reverse a list if it has exactly two elements:
rev2 :: [a] -> [a]
rev2 :: Data a => [a] -> [a]
rev2 [x,y] = [y,x]
rev2'default xs = xs
......
......@@ -2,7 +2,7 @@
# script to test the examples for the SQL preprocessor:
# Root location of the Curry System specified by variable CURRYROOT
CURRYROOT=`$CURRYBIN :set v0 :set -time :add Distribution :eval "putStrLn installDir" :quit`
CURRYROOT=`$CURRYBIN :set v0 :set -time :add Curry.Compiler.Distribution :eval "putStrLn installDir" :quit`
CURRYBINDIR=$CURRYROOT/bin
if [ -x "$CURRYBINDIR/pakcs" ] ; then
......
......@@ -16,14 +16,19 @@
"contracts" : ">= 3.0.0, < 4.0.0",
"currycheck" : ">= 3.0.0, < 4.0.0",
"currypath" : ">= 3.0.0, < 4.0.0",
"directory" : ">= 3.0.0, < 4.0.0",
"filepath" : ">= 3.0.0, < 4.0.0",
"fl-parser" : ">= 3.0.0, < 4.0.0",
"flatcurry" : ">= 3.0.0, < 4.0.0",
"frontend-exec" : ">= 3.0.0, < 4.0.0",
"html2" : ">= 3.0.0, < 4.0.0",
"process" : ">= 3.0.0, < 4.0.0",
"printf" : ">= 3.0.0, < 4.0.0",
"read-legacy" : ">= 3.0.0, < 4.0.0",
"regexp" : ">= 3.0.0, < 4.0.0",
"searchtree" : ">= 3.0.0, < 4.0.0",
"setfunctions" : ">= 3.0.0, < 4.0.0",
"time" : ">= 3.0.0, < 4.0.0",
"wl-pprint" : ">= 3.0.0, < 4.0.0",
"xml" : ">= 3.0.0, < 4.0.0",
"easycheck" : ">= 3.0.0, < 4.0.0"
......@@ -43,15 +48,6 @@
{ "src-dir": "examples/IntegratedCode",
"modules": [ "testFormat", "testHtml", "testRegExps" ]
},
{ "src-dir": "examples/IntegratedSQLCode",
"options": "-v",
"script" : "test.sh"
},
{ "src-dir": "examples/Contracts",
"options": "--nospec --nodet --deftype=Int",
"modules": [ "BubbleSort", "BubbleSortFormat", "Coin",
"FibInfinite", "Quicksort" ]
},
{ "src-dir": "examples/DefaultRules",
"options": "-m40",
"modules": [ "BreakWhere", "BubbleSort", "ColorMap", "DutchFlag",
......
......@@ -11,19 +11,18 @@
--- > Declarative Languages (PADL 2012), pp. 33-47, Springer LNCS 7149, 2012
---
--- @author Michael Hanus
--- @version April 2019
--- @version December 2020
------------------------------------------------------------------------
module CPP.Contracts ( main, translateContracts )
where
import Control.Monad ( when, unless )
import Control.Monad ( when, unless )
import Curry.Compiler.Distribution ( installDir )
import Data.Char
import Language.Curry.Distribution ( installDir )
import System.Directory
import System.FilePath ( takeDirectory )
import Data.List
import Data.Maybe ( fromJust, isNothing )
import Data.Maybe ( fromJust, isNothing )
import System.Environment ( getArgs )
import AbstractCurry.Types
import AbstractCurry.Files
......@@ -37,7 +36,8 @@ import FlatCurry.Files ( readFlatCurry )
import qualified FlatCurry.Goodies as FCG
import System.CurryPath ( lookupModuleSourceInLoadPath, modNameToPath
, stripCurrySuffix )
import System.Environment ( getArgs )
import System.Directory
import System.FilePath ( takeDirectory )
import System.Process ( system )
-- in order to use the determinism analysis:
......
......@@ -36,15 +36,14 @@
--- see the example programs in the directory `examples/DefaultRules`).
---
--- @author Michael Hanus
--- @version October 2019
--- @version December 2020
-----------------------------------------------------------------------------
module CPP.DefaultRules ( translateDefaultRulesAndDetOps )
where
import Control.Monad ( when, unless )
import Language.Curry.Distribution ( curryCompiler )
import System.FilePath ( takeDirectory )
import Curry.Compiler.Distribution ( curryCompiler )
import Data.List ( partition )
import AbstractCurry.Types
......@@ -54,6 +53,7 @@ import AbstractCurry.Build
import AbstractCurry.Pretty
import DefaultRuleUsage
import System.CurryPath ( modNameToPath )
import System.FilePath ( takeDirectory )
import TheoremUsage ( determinismTheoremFor, existsProofFor
, getModuleProofFiles, isProofFileNameFor )
......
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