/**
  * Capture output
  *
  * @param   lang.Runnable r
  * @param   array<string, string> initial
  * @return  array<string, string>
  */
 public static function capture(Runnable $r, $initial = array())
 {
     self::$streams = $initial;
     stream_wrapper_unregister('php');
     stream_wrapper_register('php', __CLASS__);
     try {
         $r->run();
     } catch (Exception $e) {
     }
     ensure($e);
     stream_wrapper_restore('php');
     if ($e) {
         throw $e;
     }
     return self::$streams;
 }
 public function input()
 {
     $r = ChannelWrapper::capture(newinstance('lang.Runnable', array(), '{
     public function run() {
       $i= new ChannelInputStream("input");
       $o= new ChannelOutputStream("stdout");
       while ($i->available()) {
         $o->write($i->read());
       }
     }
   }'), array('input' => '+OK Piped input'));
     $this->assertEquals('+OK Piped input', $r['stdout']);
 }