1
1
#![ feature( arbitrary_self_types) ]
2
2
3
+ use anyhow:: Result ;
3
4
use turbo_tasks:: {
4
5
debug:: ValueDebug , test_helpers:: current_task_for_testing, ResolvedValue , ValueDefault , Vc ,
5
6
} ;
@@ -14,8 +15,8 @@ struct Wrapper(u32);
14
15
struct TransparentWrapper ( u32 ) ;
15
16
16
17
#[ tokio:: test]
17
- async fn test_store_and_read ( ) {
18
- run ( & REGISTRATION , async {
18
+ async fn test_store_and_read ( ) -> Result < ( ) > {
19
+ run ( & REGISTRATION , || async {
19
20
let a: Vc < u32 > = Vc :: local_cell ( 42 ) ;
20
21
assert_eq ! ( * a. await . unwrap( ) , 42 ) ;
21
22
@@ -24,13 +25,15 @@ async fn test_store_and_read() {
24
25
25
26
let c = TransparentWrapper ( 42 ) . local_cell ( ) ;
26
27
assert_eq ! ( * c. await . unwrap( ) , 42 ) ;
28
+
29
+ Ok ( ( ) )
27
30
} )
28
31
. await
29
32
}
30
33
31
34
#[ tokio:: test]
32
- async fn test_store_and_read_generic ( ) {
33
- run ( & REGISTRATION , async {
35
+ async fn test_store_and_read_generic ( ) -> Result < ( ) > {
36
+ run ( & REGISTRATION , || async {
34
37
// `Vc<Vec<Vc<T>>>` is stored as `Vc<Vec<Vc<()>>>` and requires special
35
38
// transmute handling
36
39
let cells: Vc < Vec < Vc < u32 > > > =
@@ -42,6 +45,8 @@ async fn test_store_and_read_generic() {
42
45
}
43
46
44
47
assert_eq ! ( output, vec![ 1 , 2 , 3 ] ) ;
48
+
49
+ Ok ( ( ) )
45
50
} )
46
51
. await
47
52
}
@@ -53,10 +58,12 @@ async fn returns_resolved_local_vc() -> Vc<u32> {
53
58
cell. resolve ( ) . await . unwrap ( )
54
59
}
55
60
61
+ #[ ignore]
56
62
#[ tokio:: test]
57
- async fn test_return_resolved ( ) {
58
- run ( & REGISTRATION , async {
63
+ async fn test_return_resolved ( ) -> Result < ( ) > {
64
+ run ( & REGISTRATION , || async {
59
65
assert_eq ! ( * returns_resolved_local_vc( ) . await . unwrap( ) , 42 ) ;
66
+ Ok ( ( ) )
60
67
} )
61
68
. await
62
69
}
@@ -65,8 +72,8 @@ async fn test_return_resolved() {
65
72
trait UnimplementedTrait { }
66
73
67
74
#[ tokio:: test]
68
- async fn test_try_resolve_sidecast ( ) {
69
- run ( & REGISTRATION , async {
75
+ async fn test_try_resolve_sidecast ( ) -> Result < ( ) > {
76
+ run ( & REGISTRATION , || async {
70
77
let trait_vc: Vc < Box < dyn ValueDebug > > = Vc :: upcast ( Vc :: < u32 > :: local_cell ( 42 ) ) ;
71
78
72
79
// `u32` is both a `ValueDebug` and a `ValueDefault`, so this sidecast is valid
@@ -80,13 +87,15 @@ async fn test_try_resolve_sidecast() {
80
87
. await
81
88
. unwrap ( ) ;
82
89
assert ! ( wrongly_sidecast_vc. is_none( ) ) ;
90
+
91
+ Ok ( ( ) )
83
92
} )
84
93
. await
85
94
}
86
95
87
96
#[ tokio:: test]
88
- async fn test_try_resolve_downcast_type ( ) {
89
- run ( & REGISTRATION , async {
97
+ async fn test_try_resolve_downcast_type ( ) -> Result < ( ) > {
98
+ run ( & REGISTRATION , || async {
90
99
let trait_vc: Vc < Box < dyn ValueDebug > > = Vc :: upcast ( Vc :: < u32 > :: local_cell ( 42 ) ) ;
91
100
92
101
let downcast_vc: Vc < u32 > = Vc :: try_resolve_downcast_type ( trait_vc)
@@ -98,16 +107,19 @@ async fn test_try_resolve_downcast_type() {
98
107
let wrongly_downcast_vc: Option < Vc < i64 > > =
99
108
Vc :: try_resolve_downcast_type ( trait_vc) . await . unwrap ( ) ;
100
109
assert ! ( wrongly_downcast_vc. is_none( ) ) ;
110
+
111
+ Ok ( ( ) )
101
112
} )
102
113
. await
103
114
}
104
115
105
116
#[ tokio:: test]
106
- async fn test_get_task_id ( ) {
107
- run ( & REGISTRATION , async {
117
+ async fn test_get_task_id ( ) -> Result < ( ) > {
118
+ run ( & REGISTRATION , || async {
108
119
// the task id as reported by the RawVc
109
120
let vc_task_id = Vc :: into_raw ( Vc :: < ( ) > :: local_cell ( ( ) ) ) . get_task_id ( ) ;
110
121
assert_eq ! ( vc_task_id, current_task_for_testing( ) ) ;
122
+ Ok ( ( ) )
111
123
} )
112
124
. await
113
125
}
@@ -139,25 +151,31 @@ async fn get_untracked_local_cell() -> Vc<Untracked> {
139
151
. unwrap ( )
140
152
}
141
153
154
+ #[ ignore]
142
155
#[ tokio:: test]
143
156
#[ should_panic( expected = "Local Vcs must only be accessed within their own task" ) ]
144
157
async fn test_panics_on_local_cell_escape_read ( ) {
145
- run ( & REGISTRATION , async {
158
+ run ( & REGISTRATION , || async {
146
159
get_untracked_local_cell ( )
147
160
. await
148
161
. unwrap ( )
149
162
. cell
150
163
. await
151
164
. unwrap ( ) ;
165
+ Ok ( ( ) )
152
166
} )
153
167
. await
168
+ . unwrap ( )
154
169
}
155
170
171
+ #[ ignore]
156
172
#[ tokio:: test]
157
173
#[ should_panic( expected = "Local Vcs must only be accessed within their own task" ) ]
158
174
async fn test_panics_on_local_cell_escape_get_task_id ( ) {
159
- run ( & REGISTRATION , async {
175
+ run ( & REGISTRATION , || async {
160
176
Vc :: into_raw ( get_untracked_local_cell ( ) . await . unwrap ( ) . cell ) . get_task_id ( ) ;
177
+ Ok ( ( ) )
161
178
} )
162
179
. await
180
+ . unwrap ( )
163
181
}
0 commit comments