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

Commitbdee98e

Browse files
committed
add tests for using ReflectedDefinition methods as first class values
1 parentbe48342 commitbdee98e

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed

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

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2418,7 +2418,6 @@ module QuotationOfResizeArrayIteration =
24182418
moduleTestAutoQuoteAtStaticMethodCalls=
24192419
openMicrosoft.FSharp.Quotations
24202420

2421-
24222421
typeC()=
24232422
static letcleanup(s:string)= s.Replace("","").Replace("\n","").Replace("\r","")
24242423
static memberPlot([<ReflectedDefinition>]x:Expr<'T>)=
@@ -2613,6 +2612,92 @@ module TestAutoQuoteAtInstanceMethodCalls =
26132612

26142613
testItAll()
26152614

2615+
moduleTestsForUsingReflectedDefinitionArgumentsAsFirstClassValues=
2616+
openMicrosoft.FSharp.Quotations
2617+
openSystem.Linq.Expressions
2618+
openSystem
2619+
2620+
typeFirstClassTests()=
2621+
static memberPlotRawExpr([<ReflectedDefinition>]x:Expr)= x.ToString()
2622+
static memberPlotExpr([<ReflectedDefinition>]x:Expr<'T>)= x.ToString()
2623+
static memberPlotExprOverloadedByType([<ReflectedDefinition>]x:Expr<int>)= x.ToString()
2624+
static memberPlotExprOverloadedByType([<ReflectedDefinition>]x:Expr<string>)= x.ToString()
2625+
static memberPlotExprOverloadedByShape(x:int)= x.ToString()
2626+
static memberPlotExprOverloadedByShape([<ReflectedDefinition>]x:Expr<int>)= x.ToString()
2627+
static memberPlotLinq(x:Expression<Func<int,'T>>)= x.ToString()
2628+
static memberPlotLinqOverloadedByType(x:Expression<Func<int,'T>>)= x.ToString()
2629+
static memberPlotLinqOverloadedByType(x:Expression<Func<string,'T>>)= x.ToString()
2630+
static memberPlotLinqOverloadedByShape(x:Func<int,'T>)= x.ToString()
2631+
static memberPlotLinqOverloadedByShape(x:Expression<Func<int,'T>>)= x.ToString()
2632+
2633+
//open Microsoft.FSharp.Quotations
2634+
//let f (x:Expr<'T>) = x.ToString()
2635+
2636+
(FirstClassTests.PlotLinq: Expression<Func<int,int>>-> string)// doesn't quote implicit var
2637+
(FirstClassTests.PlotLinq:(int-> int)-> string)// doesn't quote implicit var
2638+
2639+
letcallLinqWithoutAutoConv(ef:Expression<Func<int,int>>)= FirstClassTests.PlotLinq ef
2640+
letcallLinqWithAutoConv(f:int->int)= FirstClassTests.PlotLinq(fun x-> f x)// needs eta-expansion
2641+
2642+
letcallLinqOverloadedByTypeWithoutAutoConvInt(ef:Expression<Func<int,int>>)= FirstClassTests.PlotLinqOverloadedByType ef
2643+
letcallLinqOverloadedByTypeWithoutAutoConvString(ef:Expression<Func<string,int>>)= FirstClassTests.PlotLinqOverloadedByType ef
2644+
letcallLinqOverloadedByTypeWithAutoConvInt(f:int->int)= FirstClassTests.PlotLinqOverloadedByType(fun x-> f x)
2645+
letcallLinqOverloadedByTypeWithAutoConvString(f:string->int)= FirstClassTests.PlotLinqOverloadedByType(fun x-> f x)
2646+
2647+
letcallLinqOverloadedByShapeWithoutAutoConv(ef:Expression<Func<int,int>>)= FirstClassTests.PlotLinqOverloadedByShape ef
2648+
// EXPECTED AND CONSISTENT: let callLinqOverloadedByShapeWithAutoConv (f: int -> int) = C.PlotLinqOverloadedByShape (fun x -> f x)
2649+
2650+
letcallExprWithoutAutoConv(ef:Expr<int>)= FirstClassTests.PlotExpr<@%ef@>
2651+
letcallExprWithAutoConv(ef:int)= FirstClassTests.PlotExpr ef
2652+
2653+
letcallExprOverloadedWithoutAutoConvA(ef:Expr<int>)= FirstClassTests.PlotExprOverloadedByType<@%ef@>
2654+
letcallExprOverloadedWithoutAutoConvB(ef:Expr<int>)= FirstClassTests.PlotExprOverloadedByType ef
2655+
letcallExprOverloadedWithAutoConv(ef:int)= FirstClassTests.PlotExprOverloadedByType ef
2656+
2657+
letcallExprOverloadedByShapeWithoutAutoConvA(ef:Expr<int>)= FirstClassTests.PlotExprOverloadedByShape<@%ef@>
2658+
letcallExprOverloadedByShapeWithoutAutoConvB(ef:Expr<int>)= FirstClassTests.PlotExprOverloadedByShape ef
2659+
// EXPECTED AND CONSISTENT: let callExprOverloadedByShapeWithAutoConv (ef: int) = C.PlotExprOverloadedByShape ef
2660+
2661+
(FirstClassTests.PlotLinq:(int-> int)-> string)// auto- - though not very useful
2662+
(FirstClassTests.PlotLinq: Expression<Func<int,int>>-> string)// doesn't auto-quote implicit var
2663+
(FirstClassTests.PlotLinqOverloadedByType:(int-> int)-> string)// auto- - though not very useful
2664+
(FirstClassTests.PlotLinqOverloadedByType:(int-> string)-> string)// auto- - though not very useful
2665+
(FirstClassTests.PlotLinqOverloadedByType: Expression<Func<int,int>>-> string)// doesn't auto-quote implicit var
2666+
(FirstClassTests.PlotLinqOverloadedByShape: Expression<Func<int,int>>-> string)// doesn't auto-quote implicit var
2667+
// EXPECTED AND CONSISTENT: (C.PlotLinqOverloadedByShape : (int -> int) -> string) // auto- - though not very useful
2668+
2669+
(FirstClassTests.PlotRawExpr: Expr-> string)// doesn't auto-quote implicit var
2670+
(FirstClassTests.PlotRawExpr: obj-> string)// does auto-quote implicit var
2671+
(FirstClassTests.PlotExpr: Expr<int>-> string)// doesn't auto-quote implicit var
2672+
(FirstClassTests.PlotExpr: int-> string)// does auto-quote implicit var
2673+
(FirstClassTests.PlotExprOverloadedByType: Expr<int>-> string)// doesn't auto-quote implicit var
2674+
(FirstClassTests.PlotExprOverloadedByType: int-> string)// does auto-quote implicit var
2675+
(FirstClassTests.PlotExprOverloadedByType: string-> string)// does auto-quote implicit var
2676+
(FirstClassTests.PlotExprOverloadedByShape: Expr<int>-> string)// doesn't auto-quote implicit var
2677+
// EXPECTED AND CONSISTENT: (C.PlotExprOverloadedByShape : int -> string) // does auto-quote implicit var
2678+
2679+
2680+
FirstClassTests.PlotExpr1
2681+
FirstClassTests.PlotExpr<@1@>
2682+
FirstClassTests.PlotExprOverloadedByType1
2683+
FirstClassTests.PlotExprOverloadedByType<@1@>
2684+
FirstClassTests.PlotExprOverloadedByType"a"
2685+
FirstClassTests.PlotExprOverloadedByType<@"a"@>
2686+
// EXPECTED AND CONSISTENT: 1 |> FirstClassTests.PlotExprOverloadedByShape
2687+
FirstClassTests.PlotExprOverloadedByShape<@1@>
2688+
2689+
2690+
1|> FirstClassTests.PlotExpr
2691+
<@1@>|> FirstClassTests.PlotExpr
2692+
1|> FirstClassTests.PlotExprOverloadedByType
2693+
<@1@>|> FirstClassTests.PlotExprOverloadedByType
2694+
"a"|> FirstClassTests.PlotExprOverloadedByType
2695+
<@"a"@>|> FirstClassTests.PlotExprOverloadedByType
2696+
// EXPECTED AND CONSISTENT: 1 |> FirstClassTests.PlotExprOverloadedByShape
2697+
<@1@>|> FirstClassTests.PlotExprOverloadedByShape
2698+
2699+
2700+
26162701
letaa=
26172702
ifnot failures.IsEmptythen(printfn"Test Failed, failures =%A" failures; exit1)
26182703
else(stdout.WriteLine"Test Passed";

‎tests/test.lst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Core06fsharp\core\queriesOverIQueryable
6666
Core06..\testsprivate\fsharp\core\queriesOverIQueryableLinqToEntities
6767
Core06..\testsprivate\fsharp\core\queriesOverIQueryableLinqToSql
6868
Core06fsharp\core\queriesOverOData
69-
Core06,Quotationsfsharp\core\quotes
69+
Core06,CoreQuotesfsharp\core\quotes
7070
Core06fsharp\core\quotesDebugInfo
7171
Core06fsharp\core\quotesInMultipleModules
7272
Core07fsharp\core\reflect

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp