1 # Testing magical scalars (using tied scalar)
2 # Note that XSUBs do not handle magical scalars automatically.
18 Foo->meta->add_attribute('bar' =>
23 Foo->meta->add_attribute('baz' =>
27 Foo->meta->make_immutable();
31 tie my $foo, 'Tie::StdScalar', Foo->new(bar => 100, baz => 200);
33 is $foo->get_bar, 100, 'reader with tied self';
34 is $foo->baz, 200, 'accessor/r with tied self';
39 is $foo->get_bar, 300, 'writer with tied self';
40 is $foo->baz, 400, 'accessor/w with tied self';
46 tie my $value, 'Tie::StdScalar', 42;
48 $foo->set_bar($value);
51 is $foo->get_bar, 42, 'reader/writer with tied value';
52 is $foo->baz, 42, 'accessor with tied value';
56 my $x = tie my $value, 'Tie::StdScalar', 'Class::MOP';
58 is( exception { Class::MOP::load_class($value) }, undef, 'load_class(tied scalar)' );
61 $x->STORE('Class::MOP'); # reset
64 ok Class::MOP::is_class_loaded($value);
65 }, undef, 'is_class_loaded(tied scalar)' );
68 $x->STORE(\&Class::MOP::get_code_info); # reset
71 is_deeply [Class::MOP::get_code_info($value)], [qw(Class::MOP get_code_info)], 'get_code_info(tied scalar)';