-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chapter_01_Tests.fs
56 lines (47 loc) · 1.54 KB
/
Chapter_01_Tests.fs
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
module Chapter_01_Tests
open NUnit.Framework
open FsUnit
open Chapter_01
[<TestFixture>]
type ``Chapter 01 Tests``() =
[<Test>]
member x.``Exercise 1.1``() =
g 7 |> should equal 11
[<Test>]
member x.``Exercise 1.2``() =
h1 1. 1. |> should (equalWithin 0.01) (System.Math.Sqrt(2.))
h2 1. 1. |> should (equalWithin 0.01) (System.Math.Sqrt(2.))
[<Test>]
member x.``Exercise 1.3 gf``() =
gf 7 |> should equal 11
[<Test>]
member x.``Exercise 1.3 gh``() =
hf1 (1., 1.) |> should (equalWithin 0.01) (System.Math.Sqrt(2.))
hf1 (2., 2.) |> should (equalWithin 0.01) (System.Math.Sqrt(8.))
hf2 (1., 1.) |> should (equalWithin 0.01) (System.Math.Sqrt(2.))
hf2 (2., 2.) |> should (equalWithin 0.01) (System.Math.Sqrt(8.))
[<Test>]
member x.``Exercise 1.4``() =
f14 1 |> should equal 1
f14 2 |> should equal 3
f14 3 |> should equal 6
f14 4 |> should equal 10
[<Test>]
member x.``Exercise 1.5``() =
fib 0 |> should equal 0
fib 1 |> should equal 1
fib 2 |> should equal 1
fib 3 |> should equal 2
fib 4 |> should equal 3
fib 5 |> should equal 5
fib 6 |> should equal 8
fib 7 |> should equal 13
[<Test>]
member x.``Exercise 1.6``() =
sum(2, 2) |> should equal 9
sum(3, 2) |> should equal 12
[<Test>]
member x.``Exercise 1.7 Factorial``() =
fact 2 |> should equal 2
fact 3 |> should equal 6
fact 5 |> should equal 120