# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test;
BEGIN { plan tests => 511 };
use Tie::GHash;
ok(1); # If we made it this far, we're ok.

#########################

# Insert your test code below, the Test module is use()ed here so read
# its man page ( perldoc Test ) for help writing this test script.

{
  tie my %hash, 'Tie::GHash';
  ok(1);
}

ok(1);

tie my %h, 'Tie::GHash';

$h{"foo"} = "red";
ok(1);
ok(defined $h{"foo"});
ok($h{"foo"}, "red");

$h{"foo"} = "blue";
ok($h{"foo"}, "blue");

$h{"foo"} = "red-blue";
ok($h{"foo"}, "red-blue");

ok(not defined $h{"bar"});
my $colour = "green";
$h{"bar"} = $colour;
ok($h{"bar"}, "green");
$colour = "yellow";
ok($h{"bar"}, "green");

foreach my $i (1..100) {
  $h{"quux"} = $i;
  ok($h{"quux"}, $i);
}

foreach my $i (1..100) {
  $h{"quux"} = $i;
  ok($h{"quux"}, $i);
  delete $h{"quux"};
  ok(not defined $h{"quux"});
}

foreach my $i (1..100) {
  $h{$i} = $i * 2;
  ok($h{$i}, $i * 2);
}

foreach my $i (1..100) {
  my $j = $i + 1;
  $h{"foo: $i"} = $j;
  ok($h{"foo: $i"}, $j);
}

#tie my %h2, 'Tie::GHash';
#my $name = "foobar";
#ok($h2->size, 0);
#foreach my $i (1..100) {
#  $h2->insert($name++, $i * 2);
#  ok($h2->size, $i);
#}




