You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/12/14 02:19:14 UTC
[lucy-commits] svn commit: r1214018 - /incubator/lucy/trunk/clownfish/perl/t/051-symbol.t
Author: marvin
Date: Wed Dec 14 01:19:14 2011
New Revision: 1214018
URL: http://svn.apache.org/viewvc?rev=1214018&view=rev
Log:
Remove subclassing from Symbol test.
Modified:
incubator/lucy/trunk/clownfish/perl/t/051-symbol.t
Modified: incubator/lucy/trunk/clownfish/perl/t/051-symbol.t
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/clownfish/perl/t/051-symbol.t?rev=1214018&r1=1214017&r2=1214018&view=diff
==============================================================================
--- incubator/lucy/trunk/clownfish/perl/t/051-symbol.t (original)
+++ incubator/lucy/trunk/clownfish/perl/t/051-symbol.t Wed Dec 14 01:19:14 2011
@@ -16,63 +16,56 @@
use strict;
use warnings;
-package ClownfishyThing;
-use base qw( Clownfish::Symbol );
-
-sub new {
- return shift->SUPER::new( micro_sym => 'sym', exposure => 'parcel', @_ );
-}
-
-package main;
use Test::More tests => 44;
+use Clownfish;
for (qw( foo FOO 1Foo Foo_Bar FOOBAR 1FOOBAR )) {
- eval { my $thing = ClownfishyThing->new( class_name => $_ ) };
+ eval { my $thing = new_symbol( class_name => $_ ) };
like( $@, qr/class_name/, "Reject invalid class name $_" );
my $bogus_middle = "Foo::" . $_ . "::Bar";
- eval { my $thing = ClownfishyThing->new( class_name => $bogus_middle ) };
+ eval { my $thing = new_symbol( class_name => $bogus_middle ) };
like( $@, qr/class_name/, "Reject invalid class name $bogus_middle" );
}
my @exposures = qw( public private parcel local );
for my $exposure (@exposures) {
- my $thing = ClownfishyThing->new( exposure => $exposure );
+ my $thing = new_symbol( exposure => $exposure );
ok( $thing->$exposure, "exposure $exposure" );
my @not_exposures = grep { $_ ne $exposure } @exposures;
ok( !$thing->$_, "$exposure means not $_" ) for @not_exposures;
}
-my $foo = ClownfishyThing->new( class_name => 'Foo' );
-my $foo_jr = ClownfishyThing->new( class_name => 'Foo::FooJr' );
+my $foo = new_symbol( class_name => 'Foo' );
+my $foo_jr = new_symbol( class_name => 'Foo::FooJr' );
ok( !$foo->equals($foo_jr), "different class_name spoils equals" );
is( $foo_jr->get_class_name, "Foo::FooJr", "get_class_name" );
is( $foo_jr->get_class_cnick, "FooJr", "derive class_cnick from class_name" );
-my $public_exposure = ClownfishyThing->new( exposure => 'public' );
-my $parcel_exposure = ClownfishyThing->new( exposure => 'parcel' );
+my $public_exposure = new_symbol( exposure => 'public' );
+my $parcel_exposure = new_symbol( exposure => 'parcel' );
ok( !$public_exposure->equals($parcel_exposure),
"different exposure spoils equals"
);
my $lucifer_parcel = Clownfish::Parcel->singleton( name => 'Lucifer' );
-my $lucifer = ClownfishyThing->new( parcel => 'Lucifer' );
+my $lucifer = new_symbol( parcel => 'Lucifer' );
ok( $lucifer_parcel == $lucifer->get_parcel, "derive parcel" );
is( $lucifer->get_prefix, "lucifer_", "get_prefix" );
is( $lucifer->get_Prefix, "Lucifer_", "get_Prefix" );
is( $lucifer->get_PREFIX, "LUCIFER_", "get_PREFIX" );
-my $luser = ClownfishyThing->new( parcel => 'Luser' );
+my $luser = new_symbol( parcel => 'Luser' );
ok( !$lucifer->equals($luser), "different parcel spoils equals" );
for ( qw( 1foo * 0 ), "\x{263a}" ) {
- eval { my $thing = ClownfishyThing->new( micro_sym => $_ ); };
+ eval { my $thing = new_symbol( micro_sym => $_ ); };
like( $@, qr/micro_sym/, "reject bad micro_sym" );
}
-my $ooga = ClownfishyThing->new( micro_sym => 'ooga' );
-my $booga = ClownfishyThing->new( micro_sym => 'booga' );
+my $ooga = new_symbol( micro_sym => 'ooga' );
+my $booga = new_symbol( micro_sym => 'booga' );
ok( !$ooga->equals($booga), "Different micro_sym spoils equals()" );
-my $eep = ClownfishyThing->new(
+my $eep = new_symbol(
parcel => 'Eep',
class_name => "Op::Ork",
micro_sym => 'ah_ah',
@@ -80,3 +73,11 @@ my $eep = ClownfishyThing->new(
is( $eep->short_sym, "Ork_ah_ah", "short_sym" );
is( $eep->full_sym, "eep_Ork_ah_ah", "full_sym" );
+sub new_symbol {
+ return Clownfish::Symbol->new(
+ micro_sym => 'sym',
+ exposure => 'parcel',
+ @_
+ );
+}
+