From: Vincent Pit Date: Sat, 5 Jul 2008 11:58:28 +0000 (+0200) Subject: Remove yet another wrongly imported tests X-Git-Tag: v0.19~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=946c437f87be76053366473d0a2a9e349bf27861;p=perl%2Fmodules%2FVariable-Magic.git Remove yet another wrongly imported tests --- diff --git a/t/12-data.t b/t/12-data.t deleted file mode 100644 index 1e8b9eb..0000000 --- a/t/12-data.t +++ /dev/null @@ -1,56 +0,0 @@ -#!perl -T - -use strict; -use warnings; - -use Test::More tests => 19; - -use Variable::Magic qw/wizard getdata cast dispell/; - -my $c = 1; - -my $wiz = eval { - wizard data => sub { return { foo => $_[1] || 12, bar => $_[3] || 27 } }, - get => sub { $c += $_[1]->{foo}; $_[1]->{foo} = $c }, - set => sub { $c += $_[1]->{bar}; $_[1]->{bar} = $c } -}; -ok(!$@, "wizard creation error ($@)"); -ok(defined $wiz, 'wizard is defined'); -ok(ref $wiz eq 'SCALAR', 'wizard is a scalar ref'); - -my $a = 75; -my $res = eval { cast $a, $wiz }; -ok(!$@, "cast croaks ($@)"); -ok($res, 'cast invalid'); - -my $data = eval { getdata $a, $wiz }; -ok(!$@, "getdata croaks ($@)"); -ok($res, 'getdata invalid'); -ok($data && ref($data) eq 'HASH' - && exists $data->{foo} && $data->{foo} == 12 - && exists $data->{bar} && $data->{bar} == 27, - 'private data creation ok'); - -my $b = $a; -ok($c == 13, 'get magic : pass data'); -ok($data->{foo} == 13, 'get magic : data updated'); - -$a = 57; -ok($c == 40, 'set magic : pass data'); -ok($data->{bar} == 40, 'set magic : pass data'); - -$res = eval { dispell $a, $wiz }; -ok(!$@, "dispell croaks ($@)"); -ok($res, 'dispell invalid'); - -$res = eval { cast $a, $wiz, qw/z j t/ }; -ok(!$@, "cast with arguments croaks ($@)"); -ok($res, 'cast with arguments invalid'); - -$data = eval { getdata $a, $wiz }; -ok(!$@, "getdata croaks ($@)"); -ok($res, 'getdata invalid'); -ok($data && ref($data) eq 'HASH' - && exists $data->{foo} && $data->{foo} eq 'z' - && exists $data->{bar} && $data->{bar} eq 't', - 'private data creation with arguments ok'); diff --git a/t/13-sig.t b/t/13-sig.t deleted file mode 100644 index 6564d36..0000000 --- a/t/13-sig.t +++ /dev/null @@ -1,60 +0,0 @@ -#!perl -T - -use strict; -use warnings; - -use Test::More tests => 24; - -use Variable::Magic qw/wizard getsig cast dispell SIG_MIN/; - -my $sig = 300; - -my ($a, $b, $c, $d) = 1 .. 4; - -{ - my $wiz = eval { wizard sig => $sig }; - ok(!$@, "wizard creation error ($@)"); - ok(defined $wiz, 'wizard is defined'); - ok(ref $wiz eq 'SCALAR', 'wizard is a scalar ref'); - ok($sig == getsig $wiz, 'wizard signature is correct'); - - my $wiz2 = eval { wizard sig => $sig }; - ok(!$@, "wizard retrieve error ($@)"); - ok(defined $wiz2, 'retrieved wizard is defined'); - ok(ref $wiz2 eq 'SCALAR', 'retrieved wizard is a scalar ref'); - ok($sig == getsig $wiz2, 'retrieved wizard signature is correct'); - - my $a = 1; - my $res = eval { cast $a, $wiz }; - ok(!$@, "cast from wizard croaks ($@)"); - ok($res, 'cast from wizard invalid'); - - $res = eval { dispell $a, $wiz2 }; - ok(!$@, "dispell from retrieved wizard croaks ($@)"); - ok($res, 'dispell from retrieved wizard invalid'); - - $res = eval { cast $b, $sig }; - ok(!$@, "cast from integer croaks ($@)"); - ok($res, 'cast from integer invalid'); -} - -my $res = eval { cast $c, $sig + 0.1 }; -ok(!$@, "cast from float croaks ($@)"); -ok($res, 'cast from float invalid'); - -$res = eval { cast $d, sprintf "%u", $sig }; -ok(!$@, "cast from string croaks ($@)"); -ok($res, 'cast from string invalid'); - -$res = eval { dispell $b, $sig }; -ok(!$@, "dispell from integer croaks ($@)"); -ok($res, 'dispell from integer invalid'); - -$res = eval { dispell $c, $sig + 0.1 }; -ok(!$@, "dispell from float croaks ($@)"); -ok($res, 'dispell from float invalid'); - -$res = eval { dispell $d, sprintf "%u", $sig }; -ok(!$@, "dispell from string croaks ($@)"); -ok($res, 'dispell from string invalid'); - diff --git a/t/14-self.t b/t/14-self.t deleted file mode 100644 index 6f6d9a4..0000000 --- a/t/14-self.t +++ /dev/null @@ -1,53 +0,0 @@ -#!perl -T - -use strict; -use warnings; - -use Test::More tests => 16; - -use Variable::Magic qw/wizard cast dispell getdata getsig/; - -my $c = 0; - -{ - my $wiz = eval { - wizard data => sub { $_[0] }, - get => sub { ++$c }, - free => sub { --$c } - }; - ok(!$@, "wizard creation error ($@)"); - ok(defined $wiz, 'wizard is defined'); - ok(ref $wiz eq 'SCALAR', 'wizard is a scalar ref'); - - my $res = eval { cast $wiz, $wiz }; - ok(!$@, "cast on self croaks ($@)"); - ok($res, 'cast on self invalid'); - - my $w = $wiz; - ok($c == 1, 'magic works correctly on self'); - - $res = eval { dispell $wiz, $wiz }; - ok(!$@, "dispell on self croaks ($@)"); - ok($res, 'dispell on self invalid'); - - $w = $wiz; - ok($c == 1, 'magic is no longer invoked on self when dispelled'); - - $res = eval { cast $wiz, $wiz, $wiz }; - ok(!$@, "re-cast on self croaks ($@)"); - ok($res, 're-cast on self invalid'); - - $w = getdata $wiz, $wiz; - ok($c == 1, 'getdata on magical self doesn\'t trigger callbacks'); - # ok(getsig($w) == getsig($wiz), 'getdata returns the correct wizard'); - - $res = eval { dispell $wiz, $wiz }; - ok(!$@, "re-dispell on self croaks ($@)"); - ok($res, 're-dispell on self invalid'); - - $res = eval { cast $wiz, $wiz }; - ok(!$@, "re-re-cast on self croaks ($@)"); - ok($res, 're-re-cast on self invalid'); -} - -# ok($c == 0, 'magic destructor is called'); diff --git a/t/15-huf.t b/t/15-huf.t deleted file mode 100644 index 7d28277..0000000 --- a/t/15-huf.t +++ /dev/null @@ -1,51 +0,0 @@ -#!perl -T - -use strict; -use warnings; - -use Test::More; - -use Variable::Magic qw/wizard cast dispell VMG_UVAR/; - -if (!VMG_UVAR) { - plan skip_all => 'No nice uvar magic for this perl'; -} - -eval "use Hash::Util::FieldHash qw/fieldhash/"; -if ($@) { - plan skip_all => 'Hash::Util::FieldHash required for testing uvar interaction'; -} else { - plan tests => 12; -} - -fieldhash(my %h); - -bless \(my $obj = {}), 'Variable::Magic::Test::Mock'; -$h{$obj} = 5; - -my ($w, $c) = (undef, 0); - -eval { $w = wizard fetch => sub { ++$c }, store => sub { --$c } }; -ok(!$@, "wizard with uvar creation error ($@)"); -ok(defined $w, 'wizard with uvar is defined'); -ok(ref($w) eq 'SCALAR', 'wizard with uvar is a scalar ref'); - -my $res = eval { cast %h, $w }; -ok(!$@, "cast uvar magic on fieldhash croaks ($@)"); -ok($res, 'cast uvar magic on fieldhash invalid'); - -my $s = $h{$obj}; -ok($s == 5, 'fetch magic on fieldhash doesn\'t clobber'); -ok($c == 1, 'fetch magic on fieldhash'); - -$h{$obj} = 7; -ok($c == 0, 'store magic on fieldhash'); -ok($h{$obj} == 7, 'store magic on fieldhash doesn\'t clobber'); # $c == 1 - -$res = eval { dispell %h, $w }; -ok(!$@, "dispell uvar magic on fieldhash croaks ($@)"); -ok($res, 'dispell uvar magic on fieldhash invalid'); - -$h{$obj} = 11; -$s = $h{$obj}; -ok($s == 11, 'store/fetch on fieldhash after dispell still ok');