Skip to content

Commit 29d8300

Browse files
committed
core::rt: Move uv idle tests to idle mod
1 parent a246e8f commit 29d8300

File tree

2 files changed

+62
-54
lines changed

2 files changed

+62
-54
lines changed

src/libcore/rt/uv/idle.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,65 @@ impl NativeHandle<*uvll::uv_idle_t> for IdleWatcher {
8989
match self { &IdleWatcher(ptr) => ptr }
9090
}
9191
}
92+
93+
#[cfg(test)]
94+
mod test {
95+
96+
use rt::uv::Loop;
97+
use super::*;
98+
use unstable::run_in_bare_thread;
99+
100+
#[test]
101+
#[ignore(reason = "valgrind - loop destroyed before watcher?")]
102+
fn idle_new_then_close() {
103+
do run_in_bare_thread {
104+
let mut loop_ = Loop::new();
105+
let idle_watcher = { IdleWatcher::new(&mut loop_) };
106+
idle_watcher.close(||());
107+
}
108+
}
109+
110+
#[test]
111+
fn idle_smoke_test() {
112+
do run_in_bare_thread {
113+
let mut loop_ = Loop::new();
114+
let mut idle_watcher = { IdleWatcher::new(&mut loop_) };
115+
let mut count = 10;
116+
let count_ptr: *mut int = &mut count;
117+
do idle_watcher.start |idle_watcher, status| {
118+
let mut idle_watcher = idle_watcher;
119+
assert!(status.is_none());
120+
if unsafe { *count_ptr == 10 } {
121+
idle_watcher.stop();
122+
idle_watcher.close(||());
123+
} else {
124+
unsafe { *count_ptr = *count_ptr + 1; }
125+
}
126+
}
127+
loop_.run();
128+
loop_.close();
129+
assert_eq!(count, 10);
130+
}
131+
}
132+
133+
#[test]
134+
fn idle_start_stop_start() {
135+
do run_in_bare_thread {
136+
let mut loop_ = Loop::new();
137+
let mut idle_watcher = { IdleWatcher::new(&mut loop_) };
138+
do idle_watcher.start |idle_watcher, status| {
139+
let mut idle_watcher = idle_watcher;
140+
assert!(status.is_none());
141+
idle_watcher.stop();
142+
do idle_watcher.start |idle_watcher, status| {
143+
assert!(status.is_none());
144+
let mut idle_watcher = idle_watcher;
145+
idle_watcher.stop();
146+
idle_watcher.close(||());
147+
}
148+
}
149+
loop_.run();
150+
loop_.close();
151+
}
152+
}
153+
}

src/libcore/rt/uv/mod.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -364,57 +364,3 @@ fn loop_smoke_test() {
364364
loop_.close();
365365
}
366366
}
367-
368-
#[test]
369-
#[ignore(reason = "valgrind - loop destroyed before watcher?")]
370-
fn idle_new_then_close() {
371-
do run_in_bare_thread {
372-
let mut loop_ = Loop::new();
373-
let idle_watcher = { IdleWatcher::new(&mut loop_) };
374-
idle_watcher.close(||());
375-
}
376-
}
377-
378-
#[test]
379-
fn idle_smoke_test() {
380-
do run_in_bare_thread {
381-
let mut loop_ = Loop::new();
382-
let mut idle_watcher = { IdleWatcher::new(&mut loop_) };
383-
let mut count = 10;
384-
let count_ptr: *mut int = &mut count;
385-
do idle_watcher.start |idle_watcher, status| {
386-
let mut idle_watcher = idle_watcher;
387-
assert!(status.is_none());
388-
if unsafe { *count_ptr == 10 } {
389-
idle_watcher.stop();
390-
idle_watcher.close(||());
391-
} else {
392-
unsafe { *count_ptr = *count_ptr + 1; }
393-
}
394-
}
395-
loop_.run();
396-
loop_.close();
397-
assert_eq!(count, 10);
398-
}
399-
}
400-
401-
#[test]
402-
fn idle_start_stop_start() {
403-
do run_in_bare_thread {
404-
let mut loop_ = Loop::new();
405-
let mut idle_watcher = { IdleWatcher::new(&mut loop_) };
406-
do idle_watcher.start |idle_watcher, status| {
407-
let mut idle_watcher = idle_watcher;
408-
assert!(status.is_none());
409-
idle_watcher.stop();
410-
do idle_watcher.start |idle_watcher, status| {
411-
assert!(status.is_none());
412-
let mut idle_watcher = idle_watcher;
413-
idle_watcher.stop();
414-
idle_watcher.close(||());
415-
}
416-
}
417-
loop_.run();
418-
loop_.close();
419-
}
420-
}

0 commit comments

Comments
 (0)