function test_all_containers() { $data_arr = array(1, 2, 3); test_container(array()); test_container($data_arr); test_container(new \HH\ImmVector(array())); test_container(new \HH\ImmVector($data_arr)); test_container(new \HH\Vector(array())); test_container(new \HH\Vector($data_arr)); test_container(\HH\Pair::hacklib_new(1, 2)); test_container(new \HH\ImmSet(array())); test_container(new \HH\ImmSet($data_arr)); test_container(new \HH\Set(array())); test_container(new \HH\Set($data_arr)); test_container(\HH\ImmMap::hacklib_new(array(), array())); test_container(new \HH\ImmMap($data_arr)); test_container(\HH\Map::hacklib_new(array(), array())); test_container(new \HH\Map($data_arr)); test_container(new Foo()); }
$t = gettype($i); echo "({$t}) {$i} : {$out}\n"; } $i = $m->getIterator(); $i->next(); $i->next(); $i->next(); $i->next(); try { $i->current(); echo "should not see this"; } catch (InvalidOperationException $e) { echo $e->getMessage() . "\n"; } } $immMap = \HH\ImmMap::hacklib_new(array("25", 9, "9"), array("Galadriel", true, new Foo())); $map = \HH\Map::hacklib_new(array("25", 9, "keyai"), array("zinc", 99, array(2 => 2))); verify_map($immMap); verify_map($map); $i = $map->getIterator(); $map[\hacklib_id("25")] = "copper"; echo "key is " . $i->key() . "\n"; $map[\hacklib_id("logo")] = "basic"; try { $i->key(); echo "should not see this"; } catch (InvalidOperationException $e) { echo $e->getMessage() . "\n"; } $map = $map->add(\HH\Pair::hacklib_new("tweedledee", "tweedledum")); foreach ($map as $i => $mal) {
{ echo $name . " : " . (\hacklib_cast_as_boolean($c) ? " TRUE " : " FALSE ") . "\n"; } $o1 = 10; $o2 = "10"; print_res("straightforward equality", 10 == "10"); print_res("simple equality", \hacklib_equals($o1, $o2)); print_res("simple inequality", \hacklib_not_equals($o1, $o2)); print_res("vec and immvec", \hacklib_equals(new \HH\Vector(array()), new \HH\ImmVector(array()))); $m1 = \HH\Map::hacklib_new(array("t", 1), array("tt", 2)); $m2 = \HH\Map::hacklib_new(array(1, "t"), array(2, "tt")); print_res("map key order", \hacklib_equals($m1, $m2)); $p1 = \HH\Pair::hacklib_new(1, 2); $p2 = \HH\Pair::hacklib_new(1, 2); $p1->getIterator(); print_res("collections with additional state", \hacklib_equals($p1, $p2)); print_res("Pairs can be unequal", \hacklib_not_equals(\HH\Pair::hacklib_new("high", "tea"), \HH\Pair::hacklib_new("high", "tee"))); print_res("Vector uses ==", \hacklib_equals(new \HH\Vector(array(1)), new \HH\ImmVector(array("1")))); print_res("Even if Empty", \hacklib_equals(new \HH\Vector(array()), new \HH\ImmVector(array()))); print_res("Number of Items", \hacklib_equals(new \HH\Set(array(1)), new \HH\Set(array(1, 2)))); print_res("Sets use === on keys", \hacklib_equals(new \HH\Set(array(1)), new \HH\Set(array("1")))); print_res("Sets can equal ImmSets", \hacklib_equals(new \HH\Set(array("a", 1)), new \HH\ImmSet(array(1, "a")))); print_res("Maps do both", \hacklib_equals(\HH\Map::hacklib_new(array("1", 1), array("zork", "mindy")), \HH\Map::hacklib_new(array(1, "1"), array("mindy", "zork")))); print_res("Maps can equal ImmMaps", \hacklib_equals(\HH\ImmMap::hacklib_new(array("o", 1), array("mork", 1)), \HH\Map::hacklib_new(array(1, "o"), array(1, "mork")))); print_res("Check for false", \hacklib_equals(new \HH\Vector(array()), false)); print_res("Check for true", \hacklib_equals(true, new \HH\Vector(array()))); print_res("Using not equals", \hacklib_not_equals(\HH\Map::hacklib_new(array(), array()), true)); print_res("Nested Comparison True", \hacklib_equals(new \HH\Vector(array(\HH\Map::hacklib_new(array(1), array("zoom")), new \HH\Vector(array("33")))), new \HH\Vector(array(\HH\Map::hacklib_new(array(1), array("zoom")), new \HH\ImmVector(array(33)))))); print_res("Nested Comparison False", \hacklib_equals(new \HH\Vector(array(\HH\Map::hacklib_new(array(1), array("zoom")), new \HH\Set(array("33")))), new \HH\Vector(array(\HH\Map::hacklib_new(array(1), array("zoom")), new \HH\Set(array(33)))))); print_res("Compare with null", \hacklib_equals(null, new \HH\Vector(array()))); print_res("Compare values that are null", \hacklib_equals(new \HH\Vector(array(false)), new \HH\Vector(array(null))));