File tree Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Expand file tree Collapse file tree 1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -171,8 +171,17 @@ So the properties of FizzBuzz is:
171
171
### Custom types
172
172
173
173
``` fsharp
174
- type MultipleOfOnly3 =
175
- [<Property>]
174
+ type MultiplyOfOnly3 = MultiplyOfOnly3 of int with
175
+ static member op_Explicit(MultiplyOfOnly3 i) = i
176
+
177
+ type MultiplyOfOnly3Modifier =
178
+ static member MultiplyOfOnly3() =
179
+ ArbMap.defaults
180
+ |> ArbMap.generate<int32>
181
+ |> Gen.filter (fun i -> i > 0 && i % 3 = 0 && not (i % 5 = 0))
182
+ |> Arb.fromGen
183
+
184
+ [<Property(Arbitrary = [| typeof<MultiplyOfOnly3Modifier> |])>]
176
185
let ```test multiply of three``` (x: MultiplyOfOnly3) =
177
186
test <@ FizzBuzz.fizzBuzz x = "Fizz" @>
178
187
```
@@ -184,12 +193,14 @@ let ```test multiply of three``` (x: MultiplyOfOnly3) =
184
193
185
194
``` fsharp
186
195
[<Property>]
187
- let ``Only divisible by three`` () =
188
- Arb.generate<int32>
189
- |> Gen.filter (fun i -> i % 3 = 0 && not (i % 5 = 0))
190
- |> Arb.fromGen
191
- |> Prop.forAll <| fun i ->
192
- FizzBuzz.fizzBuzz i = "Fizz"
196
+ let ``test multiply of three`` () =
197
+ let gen = ArbMap.defaults
198
+ |> ArbMap.generate<int32>
199
+ |> Gen.filter (fun i -> i % 3 = 0 && not (i % 5 = 0))
200
+ |> Arb.fromGen
201
+ Prop.forAll gen (fun x ->
202
+ test <@ FizzBuzz.fizzBuzz x = "Fizz" @>
203
+ )
193
204
```
194
205
195
206
---
You can’t perform that action at this time.
0 commit comments