forked from dotnet/fsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlockTests.fs
More file actions
58 lines (47 loc) · 1.15 KB
/
BlockTests.fs
File metadata and controls
58 lines (47 loc) · 1.15 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
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.UnitTests
open Xunit
open FSharp.Test
open Internal.Utilities.Library
module BlockTests =
[<Fact>]
let ``Iter should work correctly``() =
let b = Block.init 5 id
let results = ResizeArray()
b
|> Block.iter (fun x ->
results.Add(x)
)
Assert.Equal(
[
0
1
2
3
4
],
results
)
[<Fact>]
let ``Map should work correctly``() =
let b = Block.init 5 id
let b2 = b |> Block.map (fun x -> x + 1)
Assert.Equal(
[
1
2
3
4
5
],
b2
)
[<Fact>]
let ``Fold should work correctly``() =
let b = Block.init 5 id
let result =
(0, b)
||> Block.fold (fun state n ->
state + n
)
Assert.Equal(10, result)