sub is_valid_slot {
my ($self, $slot_name) = @_;
- exists $self->{'@!slots'}->{$slot_name} ? 1 : 0;
+ exists $self->{'@!slots'}->{$slot_name};
}
# operations on created instances
sub get_slot_value {
my ($self, $instance, $slot_name) = @_;
- $self->is_slot_initialized($instance, $slot_name) ? $instance->{$slot_name} : undef;
+ $instance->{$slot_name};
}
sub set_slot_value {
sub is_slot_initialized {
my ($self, $instance, $slot_name, $value) = @_;
- exists $instance->{$slot_name} ? 1 : 0;
+ exists $instance->{$slot_name};
}
sub weaken_slot_value {
sub inline_get_slot_value {
my ($self, $instance, $slot_name) = @_;
- 'exists ' . $self->inline_slot_access($instance, $slot_name) .
- ' ? ' . $self->inline_slot_access($instance, $slot_name) . ' : undef'
+ $self->inline_slot_access($instance, $slot_name);
}
sub inline_set_slot_value {
}
sub inline_is_slot_initialized {
my ($self, $instance, $slot_name) = @_;
- "exists " . $self->inline_slot_access($instance, $slot_name) . " ? 1 : 0";
+ "exists " . $self->inline_slot_access($instance, $slot_name);
}
sub inline_weaken_slot_value {
my $value = '$value';
is($C->inline_get_slot_value($instance, $slot_name),
- 'exists $self->{"foo"} ? $self->{"foo"} : undef',
+ '$self->{"foo"}',
'... got the right code for get_slot_value');
is($C->inline_set_slot_value($instance, $slot_name, $value),
'... got the right code for initialize_slot');
is($C->inline_is_slot_initialized($instance, $slot_name),
- 'exists $self->{"foo"} ? 1 : 0',
+ 'exists $self->{"foo"}',
'... got the right code for get_slot_value');
is($C->inline_weaken_slot_value($instance, $slot_name),
my $value = '[]';
is($C->inline_get_slot_value($instance, $slot_name),
- 'exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef',
+ '$_[0]->{$attr_name}',
'... got the right code for get_slot_value');
is($C->inline_set_slot_value($instance, $slot_name, $value),
'... got the right code for initialize_slot');
is($C->inline_is_slot_initialized($instance, $slot_name),
- 'exists $_[0]->{$attr_name} ? 1 : 0',
+ 'exists $_[0]->{$attr_name}',
'... got the right code for get_slot_value');
is($C->inline_weaken_slot_value($instance, $slot_name),
is($accessor_string,
q|sub {
$_[0]->{$attr_name} = $_[1] if scalar @_ == 2;
-exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef;
+$_[0]->{$attr_name};
}|,
'... got the right code string for accessor');
is($reader_string,
q|sub {
-exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef;
+$_[0]->{$attr_name};
}|,
'... got the right code string for reader');