@@ -8,14 +8,19 @@ struct Testcase
8
8
name:: String
9
9
dynamic_scope:: Any
10
10
fargs:: Tuple
11
+ kwargs:: Union{NamedTuple,Nothing}
11
12
expected_iteration_results:: Vector
12
13
end
13
14
14
15
function (case:: Testcase )()
15
16
testset = @testset " $(case. name) " begin
16
17
17
18
# Construct the task.
18
- t = TapedTask (case. dynamic_scope, case. fargs... )
19
+ if case. kwargs === nothing
20
+ t = TapedTask (case. dynamic_scope, case. fargs... )
21
+ else
22
+ t = TapedTask (case. dynamic_scope, case. fargs... ; case. kwargs... )
23
+ end
19
24
20
25
# Iterate through t. Record the results, and take a copy after each iteration.
21
26
iteration_results = []
@@ -42,52 +47,89 @@ function test_cases()
42
47
" single block" ,
43
48
nothing ,
44
49
(single_block, 5.0 ),
50
+ nothing ,
45
51
[sin (5.0 ), sin (sin (5.0 )), sin (sin (sin (5.0 ))), sin (sin (sin (sin (5.0 ))))],
46
52
),
47
- Testcase (" produce old" , nothing , (produce_old_value, 5.0 ), [sin (5.0 ), sin (5.0 )]),
48
- Testcase (" branch on old value l" , nothing , (branch_on_old_value, 2.0 ), [true , 2.0 ]),
49
53
Testcase (
50
- " branch on old value r" , nothing , (branch_on_old_value, - 1.0 ), [false , - 2.0 ]
54
+ " produce old" , nothing , (produce_old_value, 5.0 ), nothing , [sin (5.0 ), sin (5.0 )]
55
+ ),
56
+ Testcase (
57
+ " branch on old value l" ,
58
+ nothing ,
59
+ (branch_on_old_value, 2.0 ),
60
+ nothing ,
61
+ [true , 2.0 ],
62
+ ),
63
+ Testcase (
64
+ " branch on old value r" ,
65
+ nothing ,
66
+ (branch_on_old_value, - 1.0 ),
67
+ nothing ,
68
+ [false , - 2.0 ],
51
69
),
52
- Testcase (" no produce" , nothing , (no_produce_test, 5.0 , 4.0 ), []),
53
- Testcase (" new object" , nothing , (new_object_test, 5 , 4 ), [C (5 , 4 ), C (5 , 4 )]),
70
+ Testcase (" no produce" , nothing , (no_produce_test, 5.0 , 4.0 ), nothing , []),
54
71
Testcase (
55
- " branching test l " , nothing , (branching_test , 5.0 , 4.0 ), [ string ( sin ( 5.0 ) )]
72
+ " new object " , nothing , (new_object_test , 5 , 4 ), nothing , [ C ( 5 , 4 ), C ( 5 , 4 )]
56
73
),
57
74
Testcase (
58
- " branching test r" , nothing , (branching_test, 4.0 , 5.0 ), [sin (4.0 ) * cos (5.0 )]
75
+ " branching test l" ,
76
+ nothing ,
77
+ (branching_test, 5.0 , 4.0 ),
78
+ nothing ,
79
+ [string (sin (5.0 ))],
59
80
),
60
- Testcase (" unused argument test" , nothing , (unused_argument_test, 3 ), [1 ]),
61
- Testcase (" test with const" , nothing , (test_with_const,), [1 ]),
62
- Testcase (" while loop" , nothing , (while_loop,), collect (1 : 9 )),
81
+ Testcase (
82
+ " branching test r" ,
83
+ nothing ,
84
+ (branching_test, 4.0 , 5.0 ),
85
+ nothing ,
86
+ [sin (4.0 ) * cos (5.0 )],
87
+ ),
88
+ Testcase (" unused argument test" , nothing , (unused_argument_test, 3 ), nothing , [1 ]),
89
+ Testcase (" test with const" , nothing , (test_with_const,), nothing , [1 ]),
90
+ Testcase (" while loop" , nothing , (while_loop,), nothing , collect (1 : 9 )),
63
91
Testcase (
64
92
" foreigncall tester" ,
65
93
nothing ,
66
94
(foreigncall_tester, " hi" ),
95
+ nothing ,
67
96
[Ptr{UInt8}, Ptr{UInt8}],
68
97
),
69
- Testcase (" dynamic scope 1" , 5 , (dynamic_scope_tester_1,), [5 ]),
70
- Testcase (" dynamic scope 2" , 6 , (dynamic_scope_tester_1,), [6 ]),
71
- Testcase (" nested (static)" , nothing , (static_nested_outer,), [true , false ]),
98
+ Testcase (" dynamic scope 1" , 5 , (dynamic_scope_tester_1,), nothing , [5 ]),
99
+ Testcase (" dynamic scope 2" , 6 , (dynamic_scope_tester_1,), nothing , [6 ]),
100
+ Testcase (
101
+ " nested (static)" , nothing , (static_nested_outer,), nothing , [true , false ]
102
+ ),
72
103
Testcase (
73
104
" nested (static + used)" ,
74
105
nothing ,
75
106
(static_nested_outer_use_produced,),
107
+ nothing ,
76
108
[true , 1 ],
77
109
),
78
110
Testcase (
79
111
" nested (dynamic)" ,
80
112
nothing ,
81
113
(dynamic_nested_outer, Ref {Any} (nested_inner)),
114
+ nothing ,
82
115
[true , false ],
83
116
),
84
117
Testcase (
85
118
" nested (dynamic + used)" ,
86
119
nothing ,
87
120
(dynamic_nested_outer_use_produced, Ref {Any} (nested_inner)),
121
+ nothing ,
88
122
[true , 1 ],
89
123
),
90
- Testcase (" callable struct" , nothing , (CallableStruct (5 ), 4 ), [5 , 4 , 9 ]),
124
+ Testcase (" callable struct" , nothing , (CallableStruct (5 ), 4 ), nothing , [5 , 4 , 9 ]),
125
+ Testcase (
126
+ " kwarg tester 1" ,
127
+ nothing ,
128
+ (Core. kwcall, (; y= 5.0 ), kwarg_tester, 4.0 ),
129
+ nothing ,
130
+ [],
131
+ ),
132
+ Testcase (" kwargs tester 2" , nothing , (kwarg_tester, 4.0 ), (; y= 5.0 ), []),
91
133
]
92
134
end
93
135
@@ -222,4 +264,6 @@ function (c::CallableStruct)(y)
222
264
return nothing
223
265
end
224
266
267
+ kwarg_tester (x; y) = x + y
268
+
225
269
end
0 commit comments