Skip to content

Commit b388a14

Browse files
sokrabgw
authored andcommitted
add test case
1 parent cb30343 commit b388a14

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

turbopack/crates/turbo-tasks-testing/tests/collectibles.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@ async fn taking_collectibles_parallel() {
141141
.unwrap()
142142
}
143143

144+
#[tokio::test]
145+
async fn taking_collectibles_with_resolve() {
146+
run(&REGISTRATION, || async {
147+
let result_op = my_transitive_emitting_function_with_resolve("resolve".into());
148+
result_op.connect().strongly_consistent().await?;
149+
let list = result_op.take_collectibles::<Box<dyn ValueToString>>();
150+
assert_eq!(list.len(), 2);
151+
152+
anyhow::Ok(())
153+
})
154+
.await
155+
.unwrap()
156+
}
157+
144158
#[turbo_tasks::value(transparent)]
145159
struct Collectibles(AutoSet<ResolvedVc<Box<dyn ValueToString>>>);
146160

@@ -225,6 +239,18 @@ async fn my_emitting_function(_key: RcStr) -> Result<()> {
225239
Ok(())
226240
}
227241

242+
#[turbo_tasks::function]
243+
async fn my_transitive_emitting_function_with_thing(key: RcStr, _thing: Vc<Thing>) -> Result<()> {
244+
let _ = my_emitting_function(key);
245+
Ok(())
246+
}
247+
248+
#[turbo_tasks::function(operation)]
249+
async fn my_transitive_emitting_function_with_resolve(key: RcStr) -> Result<()> {
250+
let _ = my_transitive_emitting_function_with_thing(key, get_thing(0));
251+
Ok(())
252+
}
253+
228254
#[turbo_tasks::value(shared)]
229255
struct Thing(u32);
230256

@@ -241,3 +267,8 @@ impl ValueToString for Thing {
241267
Vc::cell(self.0.to_string().into())
242268
}
243269
}
270+
271+
#[turbo_tasks::function]
272+
fn get_thing(v: u32) -> Vc<Thing> {
273+
Thing::cell(Thing(v))
274+
}

0 commit comments

Comments
 (0)