Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00011fb

Browse files
committed
Add tests and fixes for Nullable ops
1 parent34d720b commit00011fb

File tree

7 files changed

+230
-185
lines changed

7 files changed

+230
-185
lines changed

‎src/fsharp/FSharp.Core/Linq.fs‎

Lines changed: 178 additions & 157 deletions
Large diffs are not rendered by default.

‎src/fsharp/FSharp.Core/Linq.fsi‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ namespace Microsoft.FSharp.Linq
107107
///<param name="value">The input value.</param>
108108
///<returns>The converted byte</returns>
109109
[<CompiledName("ToUInt8")>]
110-
val inline uint8:value:Nullable< ^T >->Nullable<uint8> when ^T:(static member op_Explicit:^T->byte)and default ^T:int
110+
val inline uint8:value:Nullable< ^T >->Nullable<uint8> when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
111111

112112
///<summary>Converts the argument to signed byte. This is a direct conversion for all
113113
///primitive numeric types. The operation requires an appropriate
@@ -124,7 +124,7 @@ namespace Microsoft.FSharp.Linq
124124
///<param name="value">The input value.</param>
125125
///<returns>The converted sbyte</returns>
126126
[<CompiledName("ToInt8")>]
127-
val inline int8:value:Nullable< ^T >->Nullable<int8> when ^T:(static member op_Explicit:^T->sbyte)and default ^T:int
127+
val inline int8:value:Nullable< ^T >->Nullable<int8> when ^T:(static member op_Explicit:^T->int8)and default ^T:int
128128

129129
///<summary>Converts the argument to signed 16-bit integer. This is a direct conversion for all
130130
///primitive numeric types. The operation requires an appropriate
@@ -193,17 +193,33 @@ namespace Microsoft.FSharp.Linq
193193
///static conversion method on the input type.</summary>
194194
///<param name="value">The input value.</param>
195195
///<returns>The converted float32</returns>
196-
[<CompiledName("ToSingle")>]
196+
[<CompiledName("ToFloat32")>]
197197
val inline float32:value:Nullable< ^T >->Nullable<float32> when ^T:(static member op_Explicit:^T->float32)and default ^T:int
198198

199199
///<summary>Converts the argument to 64-bit float. This is a direct conversion for all
200200
///primitive numeric types. The operation requires an appropriate
201201
///static conversion method on the input type.</summary>
202202
///<param name="value">The input value.</param>
203203
///<returns>The converted float</returns>
204-
[<CompiledName("ToDouble")>]
204+
[<CompiledName("ToFloat")>]
205205
val inline float:value:Nullable< ^T >->Nullable<float> when ^T:(static member op_Explicit:^T->float)and default ^T:int
206206

207+
///<summary>Converts the argument to 32-bit float. This is a direct conversion for all
208+
///primitive numeric types. The operation requires an appropriate
209+
///static conversion method on the input type.</summary>
210+
///<param name="value">The input value.</param>
211+
///<returns>The converted float32</returns>
212+
[<CompiledName("ToSingle")>]
213+
val inline single:value:Nullable< ^T >->Nullable<single> when ^T:(static member op_Explicit:^T->single)and default ^T:int
214+
215+
///<summary>Converts the argument to 64-bit float. This is a direct conversion for all
216+
///primitive numeric types. The operation requires an appropriate
217+
///static conversion method on the input type.</summary>
218+
///<param name="value">The input value.</param>
219+
///<returns>The converted float</returns>
220+
[<CompiledName("ToDouble")>]
221+
val inline double:value:Nullable< ^T >->Nullable<double> when ^T:(static member op_Explicit:^T->double)and default ^T:int
222+
207223
///<summary>Converts the argument to signed native integer. This is a direct conversion for all
208224
///primitive numeric types. Otherwise the operation requires an appropriate
209225
///static conversion method on the input type.</summary>
@@ -287,5 +303,5 @@ namespace Microsoft.FSharp.Linq.RuntimeHelpers
287303
///A runtime helper used to evaluate nested quotation literals.
288304
val SubstHelper:Expr*Var[]*obj[]->Expr<'T>
289305

290-
val internal(|SpecificCallToMethod|_|):System.RuntimeMethodHandle->(Expr->(Expr option*Type list*Expr list)option)
306+
val internal SpecificCallToMethod:System.RuntimeMethodHandle->(Expr->(Expr option*Type list*Expr list)option)
291307
#endif

‎src/fsharp/FSharp.Core/Query.fs‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -276,21 +276,21 @@ module Query =
276276

277277
// Match 'f x'
278278
let(|SpecificCall1|_|)q=
279-
let(|CallQ|_|)=(|SpecificCallToMethod|_|) q
279+
let(|CallQ|_|)= SpecificCallToMethod q
280280
function
281281
| CallQ(Some builderObj, tyargs,[arg1])-> Some(builderObj, tyargs, arg1)
282282
|_-> None
283283

284284
// Match 'f x y' or 'f (x,y)'
285285
let(|SpecificCall2|_|)q=
286-
let(|CallQ|_|)=(|SpecificCallToMethod|_|) q
286+
let(|CallQ|_|)= SpecificCallToMethod q
287287
function
288288
| CallQ(Some builderObj, tyargs,[arg1;arg2])-> Some(builderObj, tyargs, arg1, arg2)
289289
|_-> None
290290

291291
// Match 'f x y z' or 'f (x,y,z)'
292292
let(|SpecificCall3|_|)q=
293-
let(|CallQ|_|)=(|SpecificCallToMethod|_|) q
293+
let(|CallQ|_|)= SpecificCallToMethod q
294294
function
295295
| CallQ(Some builderObj, tyargs,[arg1;arg2;arg3])-> Some(builderObj, tyargs, arg1, arg2, arg3)
296296
|_-> None
@@ -993,15 +993,13 @@ module Query =
993993
| MacroReduction reduced-> Some(walk reduced)
994994
|_-> None)
995995

996-
let(|CallQueryBuilderRunQueryable|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder,v)-> b.Run(v)))
997-
// (typeof<QueryBuilder>.Assembly.GetType("Microsoft.FSharp.Linq.QueryRunExtensions.LowPriority").GetMethod("RunQueryAsValue").MethodHandle)
998-
let(|CallQueryBuilderRunValue|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b: QueryBuilder, v:Expr<'a>)-> b.Run(v)): 'a)// type annotations here help overload resolution
999-
// (typeof<QueryBuilder>.Assembly.GetType("Microsoft.FSharp.Linq.QueryRunExtensions.HighPriority").GetMethod("RunQueryAsEnumerable").MethodHandle)
1000-
let(|CallQueryBuilderRunEnumerable|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b: QueryBuilder, v:Expr<QuerySource<_, IEnumerable>>)-> b.Run(v)))// type annotations here help overload resolution
1001-
let(|CallQueryBuilderFor|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder,source:QuerySource<int,_>,body)-> b.For(source,body)))
996+
let(|CallQueryBuilderRunQueryable|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b:QueryBuilder,v)-> b.Run(v)))
997+
let(|CallQueryBuilderRunValue|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b: QueryBuilder, v:Expr<'a>)-> b.Run(v)): 'a)// type annotations here help overload resolution
998+
let(|CallQueryBuilderRunEnumerable|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b: QueryBuilder, v:Expr<QuerySource<_, IEnumerable>>)-> b.Run(v)))// type annotations here help overload resolution
999+
let(|CallQueryBuilderFor|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b:QueryBuilder,source:QuerySource<int,_>,body)-> b.For(source,body)))
10021000
let(|CallQueryBuilderYield|_|):Quotations.Expr->_=(|SpecificCall1|_|)(methodhandleof(fun(b:QueryBuilder,value)-> b.Yield value))
1003-
let(|CallQueryBuilderYieldFrom|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder,values)-> b.YieldFrom values))
1004-
let(|CallQueryBuilderZero|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder)-> b.Zero()))
1001+
let(|CallQueryBuilderYieldFrom|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b:QueryBuilder,values)-> b.YieldFrom values))
1002+
let(|CallQueryBuilderZero|_|):Quotations.Expr->_= SpecificCallToMethod(methodhandleof(fun(b:QueryBuilder)-> b.Zero()))
10051003
let(|CallQueryBuilderSourceIQueryable|_|):Quotations.Expr->_=(|SpecificCall1|_|)(methodhandleof(fun(b:QueryBuilder,value:IQueryable<_>)-> b.Source value))
10061004
let(|CallQueryBuilderSourceIEnumerable|_|):Quotations.Expr->_=(|SpecificCall1|_|)(methodhandleof(fun(b:QueryBuilder,value:IEnumerable<_>)-> b.Source value))
10071005

@@ -1038,11 +1036,11 @@ module Query =
10381036
let(|CallSkip|_|)=(|SpecificCall2|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2)-> query.Skip(arg1,arg2)))
10391037
let(|CallSkipWhile|_|)=(|SpecificCall2|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2)-> query.SkipWhile(arg1,arg2)))
10401038
#if SUPPORT_ZIP_IN_QUERIES
1041-
let(|CallZip|_|)=(|SpecificCallToMethod|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3)-> query.Zip(arg1,arg2,arg3)))
1039+
let(|CallZip|_|)= SpecificCallToMethod(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3)-> query.Zip(arg1,arg2,arg3)))
10421040
#endif
1043-
let(|CallJoin|_|)=(|SpecificCallToMethod|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.Join(arg1,arg2,arg3,arg4,arg5)))
1044-
let(|CallGroupJoin|_|)=(|SpecificCallToMethod|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.GroupJoin(arg1,arg2,arg3,arg4,arg5)))
1045-
let(|CallLeftOuterJoin|_|)=(|SpecificCallToMethod|_|)(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.LeftOuterJoin(arg1,arg2,arg3,arg4,arg5)))
1041+
let(|CallJoin|_|)= SpecificCallToMethod(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.Join(arg1,arg2,arg3,arg4,arg5)))
1042+
let(|CallGroupJoin|_|)= SpecificCallToMethod(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.GroupJoin(arg1,arg2,arg3,arg4,arg5)))
1043+
let(|CallLeftOuterJoin|_|)= SpecificCallToMethod(methodhandleof(fun(query:QueryBuilder,arg1,arg2,arg3,arg4,arg5)-> query.LeftOuterJoin(arg1,arg2,arg3,arg4,arg5)))
10461044
let(|CallAverageBy|_|)=(|SpecificCall2|_|)(methodhandleof(fun(query:QueryBuilder,arg1:QuerySource<double,_>,arg2:(double->double))-> query.AverageBy(arg1,arg2)))
10471045
let(|CallSumBy|_|)=(|SpecificCall2|_|)(methodhandleof(fun(query:QueryBuilder,arg1:QuerySource<double,_>,arg2:(double->double))-> query.SumBy(arg1,arg2)))
10481046

‎src/fsharp/FSharp.Core/fslib-extra-pervasives.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ module ExtraTopLevelOperators =
160160
[<CompiledName("ToDouble")>]
161161
let inlinedouble x= float x
162162

163-
[<CompiledName("ToUInt8")>]
163+
[<CompiledName("ToByte")>]
164164
let inlineuint8 x= byte x
165165

166-
[<CompiledName("ToInt8")>]
166+
[<CompiledName("ToSByte")>]
167167
let inlineint8 x= sbyte x
168168

169169
moduleChecked=

‎src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,19 @@ module ExtraTopLevelOperators =
8787
///<remarks>This is a direct conversion for all
8888
///primitive numeric types. For strings,the input is converted using <c>Double.Parse()</c> with InvariantCulture settings. Otherwise the operation requires and invokes a <c>ToDouble</c> method on the input type.</remarks>
8989
[<CompiledName("ToDouble")>]
90-
val inline double:value:^T->float when ^T:(static member op_Explicit:^T->double)and default ^T:int
90+
val inline double:value:^T->double when ^T:(static member op_Explicit:^T->double)and default ^T:int
9191

9292
///<summary>Converts the argument to byte.</summary>
9393
///<remarks>This is a direct conversion for all
9494
///primitive numeric types. For strings,the input is converted using <c>Byte.Parse()</c> on strings and otherwise requires a <c>ToByte</c> method on the input type.</remarks>
95-
[<CompiledName("ToUInt8")>]
96-
val inline uint8:value:^T->uint8 when ^T:(static member op_Explicit:^T->byte)and default ^T:int
95+
[<CompiledName("ToByte")>]
96+
val inline uint8:value:^T->uint8 when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
9797

9898
///<summary>Converts the argument to signed byte.</summary>
9999
///<remarks>This is a direct conversion for all
100100
///primitive numeric types. For strings,the input is converted using <c>SByte.Parse()</c> with InvariantCulture settings.
101101
///Otherwise the operation requires and invokes a <c>ToSByte</c> method on the input type.</remarks>
102-
[<CompiledName("ToInt8")>]
102+
[<CompiledName("ToSByte")>]
103103
val inline int8:value:^T->int8 when ^T:(static member op_Explicit:^T->int8)and default ^T:int
104104

105105

@@ -109,14 +109,14 @@ module ExtraTopLevelOperators =
109109
///<remarks>This is a direct,checked conversion for all
110110
///primitive numeric types. For strings,the input is converted using <c>Byte.Parse()</c> on strings and otherwise requires a <c>ToByte</c> method on the input type.</remarks>
111111
[<CompiledName("ToByte")>]
112-
val inline uint8:value:^T->byte when ^T:(static member op_Explicit:^T->byte)and default ^T:int
112+
val inline uint8:value:^T->byte when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
113113

114114
///<summary>Converts the argument to signed byte.</summary>
115115
///<remarks>This is a direct,checked conversion for all
116116
///primitive numeric types. For strings,the input is converted using <c>SByte.Parse()</c> with InvariantCulture settings.
117117
///Otherwise the operation requires and invokes a <c>ToSByte</c> method on the input type.</remarks>
118118
[<CompiledName("ToSByte")>]
119-
val inline int8:value:^T->sbyte when ^T:(static member op_Explicit:^T->sbyte)and default ^T:int
119+
val inline int8:value:^T->sbyte when ^T:(static member op_Explicit:^T->int8)and default ^T:int
120120

121121

122122
///<summary>Builds a read-only lookup table from a sequence of key/value pairs. The key objects are indexed using generic hashing and equality.</summary>

‎tests/fsharp/core/queriesLeafExpressionConvert/test.fsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,9 @@ module LeafExpressionEvaluationTests =
983983
openMicrosoft.FSharp.Data.UnitSystems.SI.UnitSymbols
984984

985985
checkEval"opp2oin209v3041"<@ Nullable.byte(Nullable2)@>(Nullable2uy)
986+
checkEval"opp2oin209v3041"<@ Nullable.uint8(Nullable2)@>(Nullable2uy)
986987
checkEval"opp2oin209v3042"<@ Nullable.sbyte(Nullable2)@>(Nullable2y)
988+
checkEval"opp2oin209v3042"<@ Nullable.int8(Nullable2)@>(Nullable2y)
987989
checkEval"opp2oin209v3043"<@ Nullable.uint16(Nullable2)@>(Nullable2us)
988990
checkEval"opp2oin209v3044"<@ Nullable.int16(Nullable2)@>(Nullable2s)
989991
checkEval"opp2oin209v3045"<@ Nullable.uint32(Nullable2s)@>(Nullable2u)
@@ -995,11 +997,14 @@ module LeafExpressionEvaluationTests =
995997
checkEval"opp2oin209v304w"<@ Nullable.enum(Nullable2): System.Nullable<System.DayOfWeek>@>(Nullable System.DayOfWeek.Tuesday)
996998

997999
checkEval"opp2oin209v304e"<@ Nullable.sbyte(Nullable2<kg>)@>(Nullable2y)
1000+
checkEval"opp2oin209v304e"<@ Nullable.int8(Nullable2<kg>)@>(Nullable2y)
9981001
checkEval"opp2oin209v304r"<@ Nullable.int16(Nullable2<kg>)@>(Nullable2s)
9991002
checkEval"opp2oin209v304t"<@ Nullable.int32(Nullable2s<kg>)@>(Nullable2)
10001003
checkEval"opp2oin209v304y"<@ Nullable.int64(Nullable2<kg>)@>(Nullable2L)
10011004
checkEval"opp2oin209v304u"<@ Nullable.float(Nullable2<kg>)@>(Nullable2.0)
1005+
checkEval"opp2oin209v304u"<@ Nullable.double(Nullable2<kg>)@>(Nullable2.0)
10021006
checkEval"opp2oin209v304i"<@ Nullable.float32(Nullable2<kg>)@>(Nullable2.0f)
1007+
checkEval"opp2oin209v304i"<@ Nullable.single(Nullable2<kg>)@>(Nullable2.0f)
10031008

10041009

10051010

‎tests/fsharp/core/queriesNullableOperators/test.fsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ module NullableConversions =
291291
openMicrosoft.FSharp.Data.UnitSystems.SI.UnitSymbols
292292

293293
check"opp2oin209v3041"(Nullable.byte(Nullable2))(Nullable2uy)
294+
check"opp2oin209v3041"(Nullable.uint8(Nullable2))(Nullable2uy)
294295
check"opp2oin209v3042"(Nullable.sbyte(Nullable2))(Nullable2y)
296+
check"opp2oin209v3042"(Nullable.int8(Nullable2))(Nullable2y)
295297
check"opp2oin209v3043"(Nullable.uint16(Nullable2))(Nullable2us)
296298
check"opp2oin209v3044"(Nullable.int16(Nullable2))(Nullable2s)
297299
check"opp2oin209v3045"(Nullable.uint32(Nullable2s))(Nullable2u)
@@ -303,11 +305,14 @@ module NullableConversions =
303305
check"opp2oin209v304w"(Nullable.enum(Nullable2): System.Nullable<System.DayOfWeek>)(Nullable System.DayOfWeek.Tuesday)
304306

305307
check"opp2oin209v304e"(Nullable.sbyte(Nullable2<kg>))(Nullable2y)
308+
check"opp2oin209v304e"(Nullable.int8(Nullable2<kg>))(Nullable2y)
306309
check"opp2oin209v304r"(Nullable.int16(Nullable2<kg>))(Nullable2s)
307310
check"opp2oin209v304t"(Nullable.int32(Nullable2s<kg>))(Nullable2)
308311
check"opp2oin209v304y"(Nullable.int64(Nullable2<kg>))(Nullable2L)
309312
check"opp2oin209v304u"(Nullable.float(Nullable2<kg>))(Nullable2.0)
313+
check"opp2oin209v304u"(Nullable.double(Nullable2<kg>))(Nullable2.0)
310314
check"opp2oin209v304i"(Nullable.float32(Nullable2<kg>))(Nullable2.0f)
315+
check"opp2oin209v304i"(Nullable.single(Nullable2<kg>))(Nullable2.0f)
311316

312317
letaa=
313318
ifnot failures.IsEmptythen(printfn"Test Failed, failures =%A" failures; exit1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp