Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove the type constraints from the test, they are not needed

  • Loading branch information...
commit 28c8f3cc416ade774e848306bf78b07638a6ecbb 1 parent 57ab2d8
Stevan Little authored
Showing with 6 additions and 29 deletions.
  1. +3 −11 bench/instance_creation.pl
  2. +3 −18 bench/method_calling.pl
View
14 bench/instance_creation.pl
@@ -8,25 +8,19 @@
package Foo::Moose {
use Moose;
- has foo => (is => 'rw', isa => 'Str', default => 1);
+ has foo => (is => 'rw', default => 1);
has bar => (is => 'rw', default => 1);
}
package Foo::MooseImmutable {
use Moose;
- has foo => (is => 'rw', isa => 'Str', default => 1);
+ has foo => (is => 'rw', default => 1);
has bar => (is => 'rw', default => 1);
__PACKAGE__->meta->make_immutable;
}
-sub type {
- my ($attr, $type_name) = @_;
- my $type = Moose::Util::TypeConstraints::find_type_constraint( $type_name );
- $attr->bind('before:STORE_DATA' => sub { $type->assert_valid( ${ $_[2] } ) });
-}
-
class Foo::MOP {
- has $!foo is type('Str'), rw = 1;
+ has $!foo is rw = 1;
has $!bar is rw = 1;
}
@@ -42,8 +36,6 @@ package Foo::Raw {
sub foo {
my $self = shift;
if (@_) {
- my $tc = Moose::Util::TypeConstraints::find_type_constraint('Str');
- $tc->assert_valid($_[0]);
$self->{foo} = $_[0];
}
$self->{foo};
View
21 bench/method_calling.pl
@@ -8,27 +8,21 @@
package Foo::Moose {
use Moose;
- has foo => (is => 'rw', isa => 'Str', default => 1);
+ has foo => (is => 'rw', default => 1);
has bar => (is => 'rw', default => 1);
sub baz { 1 }
}
package Foo::MooseImmutable {
use Moose;
- has foo => (is => 'rw', isa => 'Str', default => 1);
+ has foo => (is => 'rw', default => 1);
has bar => (is => 'rw', default => 1);
sub baz { 1 }
__PACKAGE__->meta->make_immutable;
}
-sub type {
- my ($attr, $type_name) = @_;
- my $type = Moose::Util::TypeConstraints::find_type_constraint( $type_name );
- $attr->bind('before:STORE_DATA' => sub { $type->assert_valid( ${ $_[2] } ) });
-}
-
class Foo::MOP {
- has $!foo is type('Str'), rw = 1;
+ has $!foo is rw = 1;
has $!bar is rw = 1;
method baz { 1 }
}
@@ -45,8 +39,6 @@ package Foo::Raw {
sub foo {
my $self = shift;
if (@_) {
- my $tc = Moose::Util::TypeConstraints::find_type_constraint('Str');
- $tc->assert_valid($_[0]);
$self->{foo} = $_[0];
}
$self->{foo};
@@ -88,10 +80,3 @@ package Foo::Raw {
raw => sub { $raw->bar(2) },
});
-say "Writer with TC";
-cmpthese(-5, {
- Moose => sub { $moose->foo(2) },
- Moose_immutable => sub { $moose_immutable->foo(2) },
- mop => sub { $mop->foo(2) },
- raw => sub { $raw->foo(2) },
-});
Please sign in to comment.
Something went wrong with that request. Please try again.