11using DiffinDiffsBase: _f, _get, groupargs, _get_default,
22 _sharedby, _show_args, _args_kwargs, _parse!, pool, proceed
3- import DiffinDiffsBase: required, default, transformed, combinedargs
3+ import DiffinDiffsBase: required, default, transformed, combinedargs, copyargs
44
5- testvoidstep (a:: String ) = NamedTuple (), false
5+ testvoidstep (a:: String ) = NamedTuple ()
66const TestVoidStep = StatsStep{:TestVoidStep , typeof (testvoidstep)}
77required (:: TestVoidStep ) = (:a ,)
88
9- testregstep (a:: String , b:: String ) = (c= a* b,), false
9+ testregstep (a:: String , b:: String ) = (c= a* b,)
1010const TestRegStep = StatsStep{:TestRegStep , typeof (testregstep)}
1111default (:: TestRegStep ) = (a= " a" , b= " b" )
1212
13- testlaststep (a:: String , c:: String ) = (result= a* c,), false
13+ testlaststep (a:: String , c:: String ) = (result= a* c,)
1414const TestLastStep = StatsStep{:TestLastStep , typeof (testlaststep)}
1515default (:: TestLastStep ) = (a= " a" ,)
1616transformed (:: TestLastStep , ntargs:: NamedTuple ) = (ntargs. c,)
1717
18- testarraystep (a:: String ) = (result= [a],), false
19- const TestArrayStep = StatsStep{:TestArrayStep , typeof (testarraystep)}
20- default (:: TestArrayStep ) = (a= " a" ,)
21-
22- testcombinestep (a:: String , bs:: String... ) = (c= collect (bs),), true
18+ testcombinestep (a:: String , bs:: String... ) = (c= collect (bs),)
2319const TestCombineStep = StatsStep{:TestCombineStep , typeof (testcombinestep)}
2420default (:: TestCombineStep ) = (a= " a" ,)
2521combinedargs (:: TestCombineStep , ntargs) = [nt. b for nt in ntargs]
2622
27- testinvalidstep (a:: String , b:: String ) = b, false
28- const TestInvalidStep = StatsStep{:TestInvalidStep , typeof (testinvalidstep)}
29- default (:: TestInvalidStep ) = (a= " a" , b= " b" )
23+ testarraystep (a:: String , c:: Array ) = (result= c,)
24+ const TestArrayStep = StatsStep{:TestArrayStep , typeof (testarraystep)}
25+ required (:: TestArrayStep ) = (:a , :c )
26+ copyargs (:: TestArrayStep ) = (2 ,)
3027
31- const TestUnnamedStep = StatsStep{:TestUnnamedStep , typeof (testinvalidstep )}
28+ const TestUnnamedStep = StatsStep{:TestUnnamedStep , typeof (testregstep )}
3229
3330@testset " StatsStep" begin
3431 @testset " _get" begin
@@ -64,14 +61,14 @@ const TestUnnamedStep = StatsStep{:TestUnnamedStep, typeof(testinvalidstep)}
6461 @test TestLastStep ()((a= " a" , b= " a" , c= " ab" )) ==
6562 (a= " a" , b= " a" , c= " ab" , result= " aab" )
6663
67- @test TestArrayStep ()((a= " a" ,)) == (a= " a" , result= [" a" ])
6864 @test TestCombineStep ()((a= " a" , b= " b" )) == (a= " a" , b= " b" , c= [" b" ])
65+ c = [" c" ]
66+ ret = TestArrayStep ()((a= " a" , c= c,))
67+ @test ret. result === c
6968
7069 @test sprint (show, TestVoidStep ()) == " TestVoidStep"
7170 @test sprint (show, MIME (" text/plain" ), TestVoidStep ()) ==
7271 " TestVoidStep (StatsStep that calls testvoidstep)"
73-
74- @test_throws ErrorException TestInvalidStep ()()
7572 end
7673end
7774
@@ -86,8 +83,8 @@ const NP = TestProcedure{:NullProcedure,Tuple{}}
8683const np = NP ()
8784const CP = TestProcedure{:CombineProcedure ,Tuple{TestCombineStep,TestArrayStep}}
8885const cp = CP ()
89- const EP = TestProcedure{:InvalidProcedure ,Tuple{TestInvalidStep }}
90- const ep = EP ()
86+ const AP = TestProcedure{:ArrayProcedure ,Tuple{TestArrayStep }}
87+ const ap = AP ()
9188
9289@testset " AbstractStatsProcedure" begin
9390 @test length (rp) == 3
@@ -266,8 +263,10 @@ testformatter(nt::NamedTuple) = (haskey(nt, :name) ? nt.name : "", nt.p, (a=nt.a
266263 s5 = StatsSpec (" s5" , IP, (a= " a" , b= " b" ))
267264 s6 = StatsSpec (" s6" , CP, (a= " a" , b= " b1" ))
268265 s7 = StatsSpec (" s7" , CP, (a= " a" , b= " b2" ))
269- s8 = StatsSpec (" s8" , NP, NamedTuple ())
270- s9 = StatsSpec (" s9" , EP, (a= " a" , b= " b" ))
266+ c = [" c" ]
267+ s8 = StatsSpec (" s8" , AP, (a= " a" , c= c))
268+ s9 = StatsSpec (" s9" , AP, (a= " a1" , c= c))
269+ s10 = StatsSpec (" s10" , NP, NamedTuple ())
271270
272271 @test proceed ([s1]) == [" aab" ]
273272 @test proceed ([s1,s2], verbose= true ) == [" aab" , " aab" ]
@@ -290,19 +289,23 @@ testformatter(nt::NamedTuple) = (haskey(nt, :name) ? nt.name : "", nt.p, (a=nt.a
290289 @test proceed ([s1,s4], keepall= true ) ==
291290 [(a= " a" , b= " b" , c= " ab" , result= " aab" ), (a= " a" , b= " b" , c= " ab" )]
292291
293- @test proceed ([s6], keepall= true ) == [(a= " a" , b= " b1" , c= [" b1" ], result= [" a " ])]
292+ @test proceed ([s6], keepall= true ) == [(a= " a" , b= " b1" , c= [" b1" ], result= [" b1 " ])]
294293 ret = proceed ([s6,s7], keepall= true )
295- @test ret == [(a= " a" , b= " b1" , c= [" b1" , " b2" ], result= [" a " ]),
296- (a= " a" , b= " b2" , c= [" b1" , " b2" ], result= [" a " ])]
294+ @test ret == [(a= " a" , b= " b1" , c= [" b1" , " b2" ], result= [" b1 " , " b2 " ]),
295+ (a= " a" , b= " b2" , c= [" b1" , " b2" ], result= [" b1 " , " b2 " ])]
297296 @test ret[1 ]. c === ret[2 ]. c
298- @test ret[1 ]. result != = ret[2 ]. result
297+ @test ret[1 ]. result === ret[2 ]. result
298+
299+ ret = proceed ([s8], keepall= true )
300+ @test ret[1 ]. c === ret[1 ]. result
301+ ret = proceed ([s8,s9], keepall= true )
302+ @test ret[1 ]. c != = ret[1 ]. result
299303
300- @test proceed ([s8 ]) == [nothing ]
301- @test proceed ([s8 ], keepall= true ) == NamedTuple[NamedTuple ()]
302- @test proceed ([s8 ], keep= :result ) == NamedTuple[NamedTuple ()]
304+ @test proceed ([s10 ]) == [nothing ]
305+ @test proceed ([s10 ], keepall= true ) == NamedTuple[NamedTuple ()]
306+ @test proceed ([s10 ], keep= :result ) == NamedTuple[NamedTuple ()]
303307
304308 @test_throws ArgumentError proceed (StatsSpec[])
305- @test_throws ErrorException proceed ([s9])
306309end
307310
308311@testset " _parse!" begin
0 commit comments