void test_query_ttyname() { IO* io = as<IO>(G(object)->get_const(state, "STDOUT")); if(isatty(io->to_fd())) { String* tty = try_as<String>(io->query(state, state->symbol("ttyname"))); // TODO: /dev/ttyxxx won't be portable to e.g. windoze TS_ASSERT(tty); } }
void test_connect_pipe() { IO* lhs = IO::allocate(state, G(io)); IO* rhs = IO::allocate(state, G(io)); TS_ASSERT(IO::connect_pipe(state, lhs, rhs)->true_p()); TS_ASSERT_EQUALS(Fixnum::from(0), lhs->lineno()); TS_ASSERT_EQUALS(Fixnum::from(0), rhs->lineno()); TS_ASSERT(kind_of<IOBuffer>(lhs->ibuffer())); TS_ASSERT(kind_of<IOBuffer>(rhs->ibuffer())); int acc_mode = fcntl(lhs->to_fd(), F_GETFL); TS_ASSERT(acc_mode >= 0); TS_ASSERT_EQUALS(Fixnum::from(acc_mode), lhs->mode()); acc_mode = fcntl(rhs->to_fd(), F_GETFL); TS_ASSERT(acc_mode >= 0); TS_ASSERT_EQUALS(Fixnum::from(acc_mode), rhs->mode()); lhs->close(state); rhs->close(state); }