-
Notifications
You must be signed in to change notification settings - Fork 790
/
StructTuples.fs
144 lines (107 loc) · 7.91 KB
/
StructTuples.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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
// Various tests for Microsoft.FSharp.Core type forwarding
namespace FSharp.Core.UnitTests.StructTuples
#if TUPLE_SAMPLE
open System
open FSharp.Core.UnitTests.LibraryTestFx
open NUnit.Framework
open TupleSample
[<TestFixture>]
type StructTuplesCSharpInterop() =
[<Test>]
member this.ValueTupleDirect () =
// Basic Tuple Two Values
let struct (one,two) = System.ValueTuple.Create(1,2)
Assert.IsTrue( ((one=1) && (two=2)) )
// Basic Tuple Three Values
let struct (one,two,three) = System.ValueTuple.Create(1, 2, 3)
Assert.IsTrue( (one=1) && (two=2) && (three=3) )
// Basic Tuple Four Values
let struct (one,two,three,four) = System.ValueTuple.Create(1, 2, 3, 4)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) )
// Basic Tuple Five Values
let struct (one,two,three,four,five) = System.ValueTuple.Create(1, 2, 3, 4, 5)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five=5))
// Basic Tuple six Values
let struct (one,two,three,four,five,six) = System.ValueTuple.Create(1, 2, 3, 4, 5, 6)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five=5) && (six=6) )
// Basic Tuple seven Values
let struct (one,two,three,four,five,six,seven) = System.ValueTuple.Create(1, 2, 3, 4, 5, 6, 7)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five=5) && (six=6) && (seven=7) )
// Basic Tuple eight Values
let struct (one,two,three,four,five,six,seven,eight) = System.ValueTuple.Create(1, 2, 3, 4, 5, 6, 7, 8)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five=5) && (six=6) && (seven=7) && (eight=8))
()
[<Test>]
member this.CSharpInteropTupleReturns () =
// Basic Tuple Two Values
let struct (one,two) = TupleReturns.GetTuple(1, 2)
Assert.IsTrue( ((one=1) && (two=2)) )
// Basic Tuple Three Values
let struct (one,two,three) = TupleReturns.GetTuple(1, 2, 3)
Assert.IsTrue( (one=1) && (two=2) && (three=3) )
// Basic Tuple Four Values
let struct (one,two,three,four) = TupleReturns.GetTuple(1, 2, 3, 4)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) )
// Basic Tuple Five Values
let struct (one,two,three,four,five) = TupleReturns.GetTuple(1, 2, 3, 4, 5)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) )
// Basic Tuple six Values
let struct (one,two,three,four,five,six) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) )
// Basic Tuple seven Values
let struct (one,two,three,four,five,six,seven) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) )
// Basic Tuple eight Values
let struct (one,two,three,four,five,six,seven,eight) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7, 8)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) )
// Basic Tuple nine Values
let struct (one,two,three,four,five,six,seven,eight,nine) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7, 8, 9)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9))
// Basic Tuple ten Values
let struct (one,two,three,four,five,six,seven,eight,nine,ten) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) )
// Basic Tuple fifteen Values + 7T + 7T + 1T
let struct (one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) && (eleven=11) && (twelve=12) && (thirteen=13) && (fourteen=14) && (fifteen=15) )
// Basic Tuple sixteen Values + 7T + 7T + 2T
let struct (one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen) = TupleReturns.GetTuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) && (eleven=11) && (twelve=12) && (thirteen=13) && (fourteen=14) && (fifteen=15) && (sixteen=16) )
()
[<Test>]
member this.CSharpInteropTupleArguments () =
// Basic Tuple Two Values
let struct (one,two) = TupleArguments.GetTuple( struct (1, 2) )
Assert.IsTrue( (one=1) && (two=2) )
// Basic Tuple Three Values
let struct (one,two,three) = TupleArguments.GetTuple( struct (1, 2, 3) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) )
// Basic Tuple Four Values
let struct (one,two,three,four) = TupleArguments.GetTuple( struct (1, 2, 3, 4) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) )
// Basic Tuple Five Values
let struct (one,two,three,four,five) = TupleArguments.GetTuple(struct (1, 2, 3, 4, 5) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) )
// Basic Tuple six Values
let struct (one,two,three,four,five,six) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) )
// Basic Tuple seven Values
let struct (one,two,three,four,five,six,seven) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) )
// Basic Tuple eight Values
let struct (one,two,three,four,five,six,seven,eight) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7, 8) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) )
// Basic Tuple nine Values
let struct (one,two,three,four,five,six,seven,eight,nine) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7, 8, 9) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9))
// Basic Tuple ten Values
let struct (one,two,three,four,five,six,seven,eight,nine,ten) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) )
// Basic Tuple fifteen Values + 7T + 7T + 1T
let struct (one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) && (eleven=11) && (twelve=12) && (thirteen=13) && (fourteen=14) && (fifteen=15) )
// Basic Tuple sixteen Values + 7T + 7T + 2T
let struct (one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen) = TupleArguments.GetTuple( struct (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) )
Assert.IsTrue( (one=1) && (two=2) && (three=3) && (four=4) && (five = 5) && (six=6) && (seven=7) && (eight=8) && (nine=9) && (ten=10) && (eleven=11) && (twelve=12) && (thirteen=13) && (fourteen=14) && (fifteen=15) && (sixteen=16) )
()
#endif