extern crate mio;

use mio::net::TcpListener;
use mio::{Events, Interests, Poll, PollOpt, Token};
use std::time::Duration;

#[test]
fn run_once_with_nothing() {
    let mut events = Events::with_capacity(1024);
    let poll = Poll::new().unwrap();
    poll.poll(&mut events, Some(Duration::from_millis(100)))
        .unwrap();
}

#[test]
fn add_then_drop() {
    let mut events = Events::with_capacity(1024);
    let l = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap();
    let poll = Poll::new().unwrap();
    poll.register(
        &l,
        Token(1),
        Interests::readable() | Interests::writable(),
        PollOpt::edge(),
    )
    .unwrap();
    drop(l);
    poll.poll(&mut events, Some(Duration::from_millis(100)))
        .unwrap();
}
