示例#1
0
 function testAddInvalidElement()
 {
     $list = new ArrayList("string");
     $this->expectException("IllegalArgumentException");
     $list->add(1223);
     $this->assertFalse($list->contains("Hello there"));
 }
示例#2
0
 public function contains($value)
 {
     $this->validTypeThrow($value);
     return parent::contains($value);
 }
示例#3
0
 public function testContains()
 {
     // Remove the following lines when you implement this test.
     $this->assertTrue($this->object->contains(5));
     $this->assertFalse($this->object->contains(9999));
 }
示例#4
0
echo "Adding Larry using insertAt()\n";
Debug::dump($list->insertAt(0, $larry));
echo "Adding Larry using insertAt()\n";
Debug::dump($list->insertAt(4, $larry));
try {
    echo "Adding Larry using insertAt()\n";
    Debug::dump($list->insertAt(6, $larry));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// (array) IList
echo "(array):\n";
Debug::dump((array) $list);
// IList::contains
echo "Contains Jack?\n";
Debug::dump($list->contains($jack));
echo "Contains Mary?\n";
Debug::dump($list->contains($mary));
try {
    echo "Contains foo?\n";
    Debug::dump($list->contains($foo));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// IList::offsetExists
echo "Contains #-1?\n";
Debug::dump(isset($list[-1]));
echo "Contains #0?\n";
Debug::dump(isset($list[0]));
echo "Contains #5?\n";
Debug::dump(isset($list[5]));