11 use Test::More tests => 14;
17 sub TIESCALAR { bless [] }
18 sub FETCH { $c++ ? "next" : "first" }
21 # This test makes sure that we can't pull a fast one on study(). If we
22 # study() a tied variable, perl should know that the studying isn't
23 # valid on subsequent references, and should account for it.
25 for my $do_study qw( 0 1 ) {
32 pass( "Studying..." );
35 pass( "Not studying..." );
38 # When it was studied (or first_fetched), $x was "first", but is now "next", so
39 # should not match /f/.
40 ok( $x !~ /f/, qq{"next" doesn't match /f/} );
41 is( index( $x, 'f' ), -1, qq{"next" doesn't contain "f"} );
43 # Subsequent references to $x are "next", so should match /n/
44 ok( $x =~ /n/, qq{"next" matches /n/} );
45 is( index( $x, 'n' ), 0, qq{"next" contains "n" at pos 0} );
47 # The letter "t" is in both, but in different positions
48 ok( $x =~ /t/, qq{"next" matches /t/} );
49 is( index( $x, 't' ), 3, qq{"next" contains "t" at pos 3} );