-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTestMath.fs
More file actions
121 lines (96 loc) · 2.53 KB
/
TestMath.fs
File metadata and controls
121 lines (96 loc) · 2.53 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
module Fable.Python.Tests.Math
open Fable.Python.Testing
open Fable.Python.Math
[<Fact>]
let ``test ceil works`` () =
math.ceil 2.3 |> equal 3
math.ceil 2.9 |> equal 3
math.ceil -1.5 |> equal -1
[<Fact>]
let ``test floor works`` () =
math.floor 2.3 |> equal 2
math.floor 2.9 |> equal 2
math.floor -1.5 |> equal -2
[<Fact>]
let ``test comb works`` () =
math.comb 5 2 |> equal 10
math.comb 10 3 |> equal 120
[<Fact>]
let ``test copysign works`` () =
math.copysign 1.0 -1 |> equal -1.0
math.copysign -1.0 1 |> equal 1.0
[<Fact>]
let ``test fabs works`` () =
math.fabs -5.0 |> equal 5.0
math.fabs 5.0 |> equal 5.0
[<Fact>]
let ``test factorial works`` () =
math.factorial 5.0 |> equal 120.0
math.factorial 0.0 |> equal 1.0
[<Fact>]
let ``test fmod works`` () =
math.fmod 10 3 |> equal 1
math.fmod 7 2 |> equal 1
[<Fact>]
let ``test gcd works`` () =
math.gcd (12, 8) |> equal 4
math.gcd (15, 25) |> equal 5
[<Fact>]
let ``test lcm works`` () =
math.lcm (4, 6) |> equal 12
math.lcm (3, 5) |> equal 15
[<Fact>]
let ``test isfinite works`` () =
math.isfinite 1.0 |> equal true
math.isfinite infinity |> equal false
math.isfinite nan |> equal false
[<Fact>]
let ``test isinf works`` () =
math.isinf infinity |> equal true
math.isinf (-infinity) |> equal true
math.isinf 1.0 |> equal false
[<Fact>]
let ``test isnan works`` () =
math.isnan nan |> equal true
math.isnan 1.0 |> equal false
[<Fact>]
let ``test exp works`` () =
math.exp 0.0 |> equal 1.0
math.exp 1.0 |> fun x -> (x > 2.718 && x < 2.719) |> equal true
[<Fact>]
let ``test log works`` () =
math.log 1.0 |> equal 0.0
math.log (math.exp 1.0) |> fun x -> (x > 0.999 && x < 1.001) |> equal true
[<Fact>]
let ``test log2 works`` () =
math.log2 8.0 |> equal 3.0
math.log2 1.0 |> equal 0.0
[<Fact>]
let ``test log10 works`` () =
math.log10 100.0 |> equal 2.0
math.log10 1.0 |> equal 0.0
[<Fact>]
let ``test pow works`` () =
math.pow 2.0 3.0 |> equal 8.0
math.pow 10.0 2.0 |> equal 100.0
[<Fact>]
let ``test sin works`` () =
math.sin 0.0 |> equal 0.0
[<Fact>]
let ``test cos works`` () =
math.cos 0.0 |> equal 1.0
[<Fact>]
let ``test tan works`` () =
math.tan 0.0 |> equal 0.0
[<Fact>]
let ``test asin works`` () =
math.asin 0.0 |> equal 0.0
[<Fact>]
let ``test acos works`` () =
math.acos 1.0 |> equal 0.0
[<Fact>]
let ``test atan works`` () =
math.atan 0.0 |> equal 0.0
[<Fact>]
let ``test atan2 works`` () =
math.atan2 0.0 1.0 |> equal 0.0