|
1 | | -@testset "ctask" begin |
| 1 | +@testset "tapedtask" begin |
2 | 2 | # Test case 1: stack allocated objects are deep copied. |
3 | 3 | @testset "stack allocated objects" begin |
4 | 4 | function f() |
|
9 | 9 | end |
10 | 10 | end |
11 | 11 |
|
12 | | - ctask = CTask(f) |
13 | | - @test consume(ctask) == 0 |
14 | | - @test consume(ctask) == 1 |
15 | | - a = copy(ctask) |
| 12 | + ttask = TapedTask(f) |
| 13 | + @test consume(ttask) == 0 |
| 14 | + @test consume(ttask) == 1 |
| 15 | + a = copy(ttask) |
16 | 16 | @test consume(a) == 2 |
17 | 17 | @test consume(a) == 3 |
18 | | - @test consume(ctask) == 2 |
19 | | - @test consume(ctask) == 3 |
| 18 | + @test consume(ttask) == 2 |
| 19 | + @test consume(ttask) == 3 |
20 | 20 |
|
21 | 21 | @inferred Libtask.TapedFunction(f) |
22 | 22 | end |
|
31 | 31 | end |
32 | 32 | end |
33 | 33 |
|
34 | | - ctask = CTask(f) |
35 | | - @test consume(ctask) == 0 |
36 | | - @test consume(ctask) == 1 |
37 | | - a = copy(ctask) |
| 34 | + ttask = TapedTask(f) |
| 35 | + @test consume(ttask) == 0 |
| 36 | + @test consume(ttask) == 1 |
| 37 | + a = copy(ttask) |
38 | 38 | @test consume(a) == 2 |
39 | 39 | @test consume(a) == 3 |
40 | | - @test consume(ctask) == 4 |
41 | | - @test consume(ctask) == 5 |
42 | | - @test consume(ctask) == 6 |
43 | | - @test consume(ctask) == 7 |
| 40 | + @test consume(ttask) == 4 |
| 41 | + @test consume(ttask) == 5 |
| 42 | + @test consume(ttask) == 6 |
| 43 | + @test consume(ttask) == 7 |
44 | 44 | end |
45 | 45 |
|
46 | 46 | @testset "iteration" begin |
|
52 | 52 | end |
53 | 53 | end |
54 | 54 |
|
55 | | - ctask = CTask(f) |
| 55 | + ttask = TapedTask(f) |
56 | 56 |
|
57 | | - next = iterate(ctask) |
| 57 | + next = iterate(ttask) |
58 | 58 | @test next === (1, nothing) |
59 | 59 |
|
60 | 60 | val, state = next |
61 | | - next = iterate(ctask, state) |
| 61 | + next = iterate(ttask, state) |
62 | 62 | @test next === (2, nothing) |
63 | 63 |
|
64 | 64 | val, state = next |
65 | | - next = iterate(ctask, state) |
| 65 | + next = iterate(ttask, state) |
66 | 66 | @test next === (3, nothing) |
67 | 67 |
|
68 | | - a = collect(Iterators.take(ctask, 7)) |
| 68 | + a = collect(Iterators.take(ttask, 7)) |
69 | 69 | @test eltype(a) === Int |
70 | 70 | @test a == 4:10 |
71 | 71 | end |
|
82 | 82 | end |
83 | 83 | end |
84 | 84 |
|
85 | | - ctask = CTask(f) |
| 85 | + ttask = TapedTask(f) |
86 | 86 | try |
87 | | - consume(ctask) |
| 87 | + consume(ttask) |
88 | 88 | catch ex |
89 | 89 | @test ex isa MethodError |
90 | 90 | end |
91 | 91 | if VERSION >= v"1.5" |
92 | | - @test ctask.task.exception isa MethodError |
| 92 | + @test ttask.task.exception isa MethodError |
93 | 93 | end |
94 | 94 | end |
95 | 95 |
|
|
103 | 103 | end |
104 | 104 | end |
105 | 105 |
|
106 | | - ctask = CTask(f) |
| 106 | + ttask = TapedTask(f) |
107 | 107 | try |
108 | | - consume(ctask) |
| 108 | + consume(ttask) |
109 | 109 | catch ex |
110 | 110 | @test ex isa ErrorException |
111 | 111 | end |
112 | 112 | if VERSION >= v"1.5" |
113 | | - @test ctask.task.exception isa ErrorException |
| 113 | + @test ttask.task.exception isa ErrorException |
114 | 114 | end |
115 | 115 | end |
116 | 116 |
|
|
125 | 125 | end |
126 | 126 | end |
127 | 127 |
|
128 | | - ctask = CTask(f) |
| 128 | + ttask = TapedTask(f) |
129 | 129 | try |
130 | | - consume(ctask) |
| 130 | + consume(ttask) |
131 | 131 | catch ex |
132 | 132 | @test ex isa BoundsError |
133 | 133 | end |
134 | 134 | if VERSION >= v"1.5" |
135 | | - @test ctask.task.exception isa BoundsError |
| 135 | + @test ttask.task.exception isa BoundsError |
136 | 136 | end |
137 | 137 | end |
138 | 138 |
|
|
147 | 147 | end |
148 | 148 | end |
149 | 149 |
|
150 | | - ctask = CTask(f) |
151 | | - @test consume(ctask) == 2 |
| 150 | + ttask = TapedTask(f) |
| 151 | + @test consume(ttask) == 2 |
152 | 152 | try |
153 | | - consume(ctask) |
| 153 | + consume(ttask) |
154 | 154 | catch ex |
155 | 155 | @test ex isa BoundsError |
156 | 156 | end |
157 | 157 | if VERSION >= v"1.5" |
158 | | - @test ctask.task.exception isa BoundsError |
| 158 | + @test ttask.task.exception isa BoundsError |
159 | 159 | end |
160 | 160 | end |
161 | 161 |
|
|
170 | 170 | end |
171 | 171 | end |
172 | 172 |
|
173 | | - ctask = CTask(f) |
174 | | - @test consume(ctask) == 2 |
175 | | - ctask2 = copy(ctask) |
| 173 | + ttask = TapedTask(f) |
| 174 | + @test consume(ttask) == 2 |
| 175 | + ttask2 = copy(ttask) |
176 | 176 | try |
177 | | - consume(ctask2) |
| 177 | + consume(ttask2) |
178 | 178 | catch ex |
179 | 179 | @test ex isa BoundsError |
180 | 180 | end |
181 | | - @test ctask.task.exception === nothing |
| 181 | + @test ttask.task.exception === nothing |
182 | 182 | if VERSION >= v"1.5" |
183 | | - @test ctask2.task.exception isa BoundsError |
| 183 | + @test ttask2.task.exception isa BoundsError |
184 | 184 | end |
185 | 185 | end |
186 | 186 | end |
|
0 commit comments