-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtartu20151120.fsx
More file actions
61 lines (34 loc) · 1.13 KB
/
Copy pathtartu20151120.fsx
File metadata and controls
61 lines (34 loc) · 1.13 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// Examples from the Q&A session in Tartu on Friday, November 20th
//
//
#r @"..\packages\FsCheck.2.2.1\lib\net45\FsCheck.dll"
open FsCheck
// What about the property of a sum of elements of a list?
let rec sum xs =
match xs with
| [] -> 0
| x::xs' -> x + sum xs'
let listSumDependsOnAddedElement xs x =
((x >= 0) ==> (sum xs <= sum (x::xs))) .|.
((x < 0) ==> (sum xs > sum (x::xs)))
Check.Quick listSumDependsOnAddedElement
let checkSomeRomanNumberProperty s =
((s = "XIX") ==> true )
Check.Quick checkSomeRomanNumberProperty
Arb.generate<int>
let createStringFromChars (cs : char list) =
gen {
let! chars = Gen.arrayOf (Gen.elements cs)
return System.String.Concat(chars)
}
let testStringGen =
Prop.forAll (Arb.fromGen (createStringFromChars ['I';'X']))
(fun r -> checkSomeRomanNumberProperty r)
//let customConfig = { Config.Quick with MaxTest=100 }
//Check.One(customConfig, testStringGen)
Check.Quick testStringGen
let x = 4 + 5
let lx = lazy (4 + 5)
let y = lazy (printf "hi"; 5 + 6)
y.Value + 1