Skip to content

Commit

Permalink
Merge pull request #43 from moodmosaic/move-nowarn-at-the-bottom
Browse files Browse the repository at this point in the history
Move #nowarn "40" compiler directive at the bottom,
  • Loading branch information
jacobstanley authored Nov 8, 2016
2 parents f894f09 + 8f3558b commit 5b32001
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions Jack/Script.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,6 @@ Property.print <| property {
return String.length xs <= 5
}

//
// Hutton's Razor
//

type Exp =
| Lit of int
| Add of Exp * Exp

let rec evalExp = function
| Lit x ->
x
| Add (x, y) ->
evalExp x + evalExp y

let shrinkExp = function
| Lit _ ->
[]
| Add (x, y) ->
[x; y]

#nowarn "40"
let rec genExp =
Gen.delay <| fun _ ->
Gen.shrink shrinkExp <|
Gen.choiceRec [
Lit <!> Gen.int
] [
Add <!> Gen.zip genExp genExp
]

Property.print <| property {
let! x = genExp
match x with
| Add (Add _, Add _) when evalExp x > 100 ->
return false
| _ ->
return true
}

//
// reverse (reverse xs) = xs, ∀xs :: [α] ― The standard "hello-world" property.
//
Expand Down Expand Up @@ -176,3 +137,42 @@ Gen.printSample <| gen {
let! addr = Gen.byte |> Gen.array' 4 4
return System.Net.IPAddress addr
}

//
// Hutton's Razor
//

type Exp =
| Lit of int
| Add of Exp * Exp

let rec evalExp = function
| Lit x ->
x
| Add (x, y) ->
evalExp x + evalExp y

let shrinkExp = function
| Lit _ ->
[]
| Add (x, y) ->
[x; y]

#nowarn "40"
let rec genExp =
Gen.delay <| fun _ ->
Gen.shrink shrinkExp <|
Gen.choiceRec [
Lit <!> Gen.int
] [
Add <!> Gen.zip genExp genExp
]

Property.print <| property {
let! x = genExp
match x with
| Add (Add _, Add _) when evalExp x > 100 ->
return false
| _ ->
return true
}

0 comments on commit 5b32001

Please sign in to comment.