-
Notifications
You must be signed in to change notification settings - Fork 872
Expand file tree
/
Copy pathOverloadingMembers.fs
More file actions
237 lines (204 loc) · 11.3 KB
/
Copy pathOverloadingMembers.fs
File metadata and controls
237 lines (204 loc) · 11.3 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace Conformance.BasicGrammarElements
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module MemberDefinitions_OverloadingMembers =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"]
|> compileAndRun
// NOMONO,NoMT SOURCE=ConsumeOverloadGenericMethods.fs SCFLAGS="-r:lib.dll" PRECMD="\$CSC_PIPE /t:library /reference:System.Core.dll lib.cs" # ConsumeOverloadGenericMethods.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ConsumeOverloadGenericMethods.fs"|])>]
let ``ConsumeOverloadGenericMethods_fs`` compilation =
let lib =
CSharpFromPath (__SOURCE_DIRECTORY__ ++ "lib.cs")
|> withName "Library"
compilation
|> withReferences [lib]
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=diffNumArguments.fs # diffNumArguments.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"diffNumArguments.fs"|])>]
let ``diffNumArguments_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=E_InferredTypeNotUnique01.fs SCFLAGS="--test:ErrorRanges" # E_InferredTypeNotUnique01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InferredTypeNotUnique01.fs"|])>]
let ``E_InferredTypeNotUnique01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 438, Line 11, Col 17, Line 11, Col 20, "Duplicate method. The method 'Foo' has the same name and signature as another method in type 'SomeClass'.")
(Error 438, Line 7, Col 17, Line 7, Col 20, "Duplicate method. The method 'Foo' has the same name and signature as another method in type 'SomeClass'.")
]
// SOURCE=E_OperatorOverloading01.fs SCFLAGS="--test:ErrorRanges" # E_OperatorOverloading01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_OperatorOverloading01.fs"|])>]
let ``E_OperatorOverloading01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Warning 1173, Line 17, Col 40, Line 17, Col 41, "Infix operator member '+' has 1 initial argument(s). Expected a tuple of 2 arguments, e.g. static member (+) (x,y) = ...")
(Warning 1174, Line 17, Col 40, Line 17, Col 41, "Infix operator member '+' has extra curried arguments. Expected a tuple of 2 arguments, e.g. static member (+) (x,y) = ...")
(Warning 52, Line 17, Col 83, Line 17, Col 87, "The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed")
(Warning 52, Line 17, Col 90, Line 17, Col 94, "The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed")
(Warning 52, Line 17, Col 96, Line 17, Col 100, "The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed")
(Warning 52, Line 17, Col 103, Line 17, Col 107, "The value has been copied to ensure the original is not mutated by this operation or because the copy is implicit when returning a struct from a member and another member is then accessed")
(Error 43, Line 21, Col 13, Line 21, Col 14, "Method or object constructor 'op_Addition' not found")
]
// SOURCE=E_OverloadCurriedFunc.fs # E_OverloadCurriedFunc.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_OverloadCurriedFunc.fs"|])>]
let ``E_OverloadCurriedFunc_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 6, Col 7, Line 6, Col 17, "The type 'OverloadID' is not defined.")
(Error 39, Line 8, Col 7, Line 8, Col 17, "The type 'OverloadID' is not defined.")
(Error 39, Line 10, Col 7, Line 10, Col 17, "The type 'OverloadID' is not defined.")
(Error 39, Line 12, Col 7, Line 12, Col 17, "The type 'OverloadID' is not defined.")
(Error 816, Line 18, Col 1, Line 18, Col 33, "One or more of the overloads of this method has curried arguments. Consider redesigning these members to take arguments in tupled form.")
]
// SOURCE=E_OverloadMismatch.fs # E_OverloadMismatch.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_OverloadMismatch.fs"|])>]
let ``E_OverloadMismatch_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 366, Line 11, Col 13, Line 11, Col 17, "No implementation was given for 'abstract IFoo.Foo: TextReader -> 't'. Note that all interface members must be implemented and listed under an appropriate 'interface' declaration, e.g. 'interface ... with member ...'.")
]
// SOURCE=E_ReturnGenericUnit01.fs # E_ReturnGenericUnit01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ReturnGenericUnit01.fs"|])>]
let ``E_ReturnGenericUnit01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 17, Line 21, Col 17, Line 21, Col 18, "The member 'M: unit -> unit' does not have the correct type to override the corresponding abstract method.")
]
//// SOURCE=E_UnsolvableConstraints01.fs SCFLAGS="--test:ErrorRanges" # E_UnsolvableConstraints01.fs
//[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_UnsolvableConstraints01.fs"|])>]
//let ``E_UnsolvableConstraints01_fs`` compilation =
// compilation
// |> verifyCompile
// |> shouldFail
// |> withDiagnostics [
// ]
// SOURCE=InferenceForLambdaArgs.fs # InferenceForLambdaArgs.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"InferenceForLambdaArgs.fs"|])>]
let ``InferenceForLambdaArgs_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=NoOverloadIDSpecified.fs # NoOverloadIDSpecified.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NoOverloadIDSpecified.fs"|])>]
let ``NoOverloadIDSpecified_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=NoWarningWhenDoingDispatchSlotInference01.fs SCFLAGS="--warnaserror+" COMPILE_ONLY=1 # NoWarningWhenDoingDispatchSlotInference01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NoWarningWhenDoingDispatchSlotInference01.fs"|])>]
let ``NoWarningWhenDoingDispatchSlotInference01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=NoWarningWhenOverloadingInSubClass01.fs SCFLAGS="--warnaserror" # NoWarningWhenOverloadingInSubClass01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NoWarningWhenOverloadingInSubClass01.fs"|])>]
let ``NoWarningWhenOverloadingInSubClass01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=OnAllOverloads01.fs # OnAllOverloads01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OnAllOverloads01.fs"|])>]
let ``OnAllOverloads01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=OperatorOverloading01.fs # OperatorOverloading01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OperatorOverloading01.fs"|])>]
let ``OperatorOverloading01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=OperatorOverloading02.fs # OperatorOverloading02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OperatorOverloading02.fs"|])>]
let ``OperatorOverloading02_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=OperatorOverloading03.fs # OperatorOverloading03.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OperatorOverloading03.fs"|])>]
let ``OperatorOverloading03_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=OperatorOverloading04.fs # OperatorOverloading04.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OperatorOverloading04.fs"|])>]
let ``OperatorOverloading04_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// NoMT SOURCE=OverloadingAndExtensionMethodsForGenericTypes.fs # OverloadingAndExtensionMethodsForGenericTypes.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OverloadingAndExtensionMethodsForGenericTypes.fs"|])>]
let ``OverloadingAndExtensionMethodsForGenericTypes_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=reuseOverloadIDs.fs # reuseOverloadIDs.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"reuseOverloadIDs.fs"|])>]
let ``reuseOverloadIDs_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=SanityCheck.fs # SanityCheck.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"SanityCheck.fs"|])>]
let ``SanityCheck_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TieBreakerRule01a.fs # TieBreakerRule01a.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TieBreakerRule01a.fs"|])>]
let ``TieBreakerRule01a_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TieBreakerRule01b.fs # TieBreakerRule01b.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TieBreakerRule01b.fs"|])>]
let ``TieBreakerRule01b_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TieBreakerRule02.fs # TieBreakerRule02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TieBreakerRule02.fs"|])>]
let ``TieBreakerRule02_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TieBreakerRule03.fs # TieBreakerRule03.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TieBreakerRule03.fs"|])>]
let ``TieBreakerRule03_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TooGeneric.fs SCFLAGS="--define:TOO_GENERIC" # TooGeneric.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TooGeneric.fs"|])>]
let ``TooGeneric_fs`` compilation =
compilation
|> withDefines ["TOO_GENERIC"]
|> verifyCompileAndRun
|> shouldSucceed
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"OverloadResolutionUsingFunction.fs"|])>]
let ``OverloadResolutionUsingFunction_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed