Skip to content

Commit 3f4872f

Browse files
committed
test: Test yielding in crust functions
1 parent a393fb3 commit 3f4872f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/run-pass/crust-yield.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
native mod rustrt {
2+
fn rust_dbg_call(cb: *u8,
3+
data: ctypes::uintptr_t) -> ctypes::uintptr_t;
4+
}
5+
6+
crust fn cb(data: ctypes::uintptr_t) -> ctypes::uintptr_t {
7+
if data == 1u {
8+
data
9+
} else {
10+
count(data - 1u) + count(data - 1u)
11+
}
12+
}
13+
14+
fn count(n: uint) -> uint {
15+
task::yield();
16+
rustrt::rust_dbg_call(cb, n)
17+
}
18+
19+
fn main() {
20+
iter::repeat(10u) {||
21+
task::spawn {||
22+
let result = count(5u);
23+
#debug("result = %?", result);
24+
assert result == 16u;
25+
};
26+
}
27+
}

0 commit comments

Comments
 (0)