public function boxResource() { $fd = Streams::readableFd(new MemoryInputStream('test')); try { Primitive::boxed($fd); } catch (IllegalArgumentException $expected) { // OK } ensure($expected); fclose($fd); // Necessary, PHP will segfault otherwise if ($expected) { return; } $this->fail('Expected exception not caught', NULL, 'lang.IllegalArgumentException'); }