File: SEBF.curry

package info (click to toggle)
curry-tools 1.0.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,492 kB
  • ctags: 121
  • sloc: makefile: 470; sh: 421
file content (31 lines) | stat: -rw-r--r-- 1,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
--------------------------------------------------------------------------
-- Some tests from Sebastian's tutorial on EasyCheck.

-- In order to write a test, we have to import the module Test.Prop:
import Test.Prop

--------------------------------------------------------------------------
-- Deterministic tests:

appendIsAssociative xs ys zs = (xs ++ ys) ++ zs -=- xs ++ (ys ++ zs)

reverseLeavesSingletonUntouched x = reverse [x] -=- [x]

reverseOfNonemptyIsNotNull x xs = reverse (x:xs) `is` (not . null)

reverseAntiDistributesOverAppend xs ys
  = reverse (xs++ys) -=- reverse ys ++ reverse xs

-- Testing non-deterministic operations:

insert :: a -> [a] -> [a]
insert x xs     = x : xs
insert x (y:ys) = y : insert x ys

insertIsNeverNull :: Int -> [Int] -> Prop
insertIsNeverNull x xs = insert x xs `isAlways` (not . null)

insertInsertsAsHead :: Int -> [Int] -> Prop
insertInsertsAsHead x xs = insert x xs ~> x:xs

--------------------------------------------------------------------------