Fix tests

This commit is contained in:
John Kåre Alsaker 2017-07-22 04:20:46 +02:00
parent ae1856cb9e
commit be0a9b8958
4 changed files with 23 additions and 23 deletions

View File

@ -10,15 +10,15 @@
#![feature(generators, generator_trait)]
use std::ops::{State, Generator};
use std::ops::{GeneratorState, Generator};
fn finish<T>(mut amt: usize, mut t: T) -> T::Return
where T: Generator<Yield = ()>
{
loop {
match t.resume() {
State::Yielded(()) => amt = amt.checked_sub(1).unwrap(),
State::Complete(ret) => {
GeneratorState::Yielded(()) => amt = amt.checked_sub(1).unwrap(),
GeneratorState::Complete(ret) => {
assert_eq!(amt, 0);
return ret
}

View File

@ -10,7 +10,7 @@
#![feature(generators, generator_trait, conservative_impl_trait)]
use std::ops::{State, Generator};
use std::ops::{GeneratorState, Generator};
struct W<T>(T);
@ -19,8 +19,8 @@ impl<T: Generator<Return = ()>> Iterator for W<T> {
fn next(&mut self) -> Option<Self::Item> {
match self.0.resume() {
State::Complete(..) => None,
State::Yielded(v) => Some(v),
GeneratorState::Complete(..) => None,
GeneratorState::Yielded(v) => Some(v),
}
}
}

View File

@ -10,7 +10,7 @@
#![feature(generators, generator_trait)]
use std::ops::{State, Generator};
use std::ops::{GeneratorState, Generator};
use std::panic;
fn main() {
@ -22,7 +22,7 @@ fn main() {
};
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}

View File

@ -12,7 +12,7 @@
#![feature(generators, generator_trait)]
use std::ops::{State, Generator};
use std::ops::{GeneratorState, Generator};
use std::thread;
#[test]
@ -24,7 +24,7 @@ fn simple() {
};
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}
@ -40,7 +40,7 @@ fn return_capture() {
};
match foo.resume() {
State::Complete(ref s) if *s == "foo" => {}
GeneratorState::Complete(ref s) if *s == "foo" => {}
s => panic!("bad state: {:?}", s),
}
}
@ -52,11 +52,11 @@ fn simple_yield() {
};
match foo.resume() {
State::Yielded(()) => {}
GeneratorState::Yielded(()) => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}
@ -69,11 +69,11 @@ fn yield_capture() {
};
match foo.resume() {
State::Yielded(ref s) if *s == "foo" => {}
GeneratorState::Yielded(ref s) if *s == "foo" => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}
@ -86,11 +86,11 @@ fn simple_yield_value() {
};
match foo.resume() {
State::Yielded(ref s) if *s == "bar" => {}
GeneratorState::Yielded(ref s) if *s == "bar" => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(ref s) if *s == "foo" => {}
GeneratorState::Complete(ref s) if *s == "foo" => {}
s => panic!("bad state: {:?}", s),
}
}
@ -104,11 +104,11 @@ fn return_after_yield() {
};
match foo.resume() {
State::Yielded(()) => {}
GeneratorState::Yielded(()) => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(ref s) if *s == "foo" => {}
GeneratorState::Complete(ref s) if *s == "foo" => {}
s => panic!("bad state: {:?}", s),
}
}
@ -156,11 +156,11 @@ fn send_over_threads() {
let mut foo = || { yield };
thread::spawn(move || {
match foo.resume() {
State::Yielded(()) => {}
GeneratorState::Yielded(()) => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}).join().unwrap();
@ -169,11 +169,11 @@ fn send_over_threads() {
let mut foo = || { yield a };
thread::spawn(move || {
match foo.resume() {
State::Yielded(ref s) if *s == "a" => {}
GeneratorState::Yielded(ref s) if *s == "a" => {}
s => panic!("bad state: {:?}", s),
}
match foo.resume() {
State::Complete(()) => {}
GeneratorState::Complete(()) => {}
s => panic!("bad state: {:?}", s),
}
}).join().unwrap();