Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tests #9

Merged
merged 13 commits into from Oct 6, 2016
Merged
6 changes: 4 additions & 2 deletions t/anon.t
@@ -1,4 +1,4 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => undef,
match => sub { shift;
Expand All @@ -11,4 +11,6 @@ sub aa { 'aa' }

sub bb { 'bb' }

ok(b() eq 'aa');
is(b(), 'aa');

done_testing();
6 changes: 4 additions & 2 deletions t/arr_str_xform.t
@@ -1,8 +1,10 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => [ 'Text::Soundex' ]);


sub a_a { 'aa' }

ok(aa() eq 'aa');
is(aa(), 'aa');

done_testing();
6 changes: 4 additions & 2 deletions t/arr_xform.t
@@ -1,9 +1,11 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => [ sub { map { s/[^a-z]//ig; $_ } @_ },
sub { map { lc } @_ } ]);


sub a_a { 'aa' }

ok(AA() eq 'aa');
is(AA(), 'aa');

done_testing;
10 changes: 6 additions & 4 deletions t/basic.t
@@ -1,14 +1,16 @@
use Test::More tests => 4;
use Test::More;

use_ok('Symbol::Approx::Sub');

sub aa { 'aa' }

sub bb { 'bb' }

ok(a() eq 'aa');
is(a(), 'aa');

ok(b() eq 'bb');
is(b(), 'bb');

eval "c()";
eval { c() };
ok($@);

done_testing;
6 changes: 4 additions & 2 deletions t/code_xform.t
@@ -1,7 +1,9 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => sub { map { s/[^A-Za-z]//g; $_ } @_ });

sub a_a { 'aa' }

ok(aa() eq 'aa');
is(aa(), 'aa');

done_testing;
4 changes: 3 additions & 1 deletion t/hash_xform.t
@@ -1,4 +1,4 @@
use Test::More tests => 2;
use Test::More;

use Symbol::Approx::Sub;

Expand All @@ -7,3 +7,5 @@ ok($@);

eval { Symbol::Approx::Sub->import(xform => [{}]) };
ok($@);

done_testing;
6 changes: 4 additions & 2 deletions t/package.t
@@ -1,6 +1,6 @@
package x;

use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => undef,
match => sub { my ($sub, @subs) = @_;
Expand All @@ -12,4 +12,6 @@ use Symbol::Approx::Sub (xform => undef,

sub oof {'yep'};

ok(foo() eq 'yep');
is(foo(), 'yep');

done_testing;
16 changes: 10 additions & 6 deletions t/packages.t
@@ -1,16 +1,20 @@
use Test::More tests => 3;
use Test::More;

package x;
package Foo;

use Symbol::Approx::Sub (xform => 'Text::Soundex');
Test::More::ok(bar() eq 'yep');
Test::More::is(bar(), 'yep');
sub baar {'yep'}
sub qux {12}

package y;
package Bar;
use Symbol::Approx::Sub (canon => undef,
match => sub {shift; return 0 .. $#_});
Test::More::ok(&x::quux()==12);
Test::More::ok(&y::quux()==23);
Test::More::is(Foo::quux(), 12);
Test::More::is(Bar::quux(), 23);

sub flurble {23}

package main;

done_testing;
6 changes: 4 additions & 2 deletions t/ref.t
@@ -1,4 +1,4 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub(xform => undef,
match => \&always_bb);
Expand All @@ -17,4 +17,6 @@ sub aa { 'aa' }

sub bb { 'bb' }

ok(a() eq 'bb');
is(a(), 'bb');

done_testing;
6 changes: 4 additions & 2 deletions t/str_choose.t
@@ -1,8 +1,10 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (choose => 'String::Equal');


sub aa { 'aa' }

ok(a() eq 'aa');
is(a(), 'aa');

done_testing;
6 changes: 4 additions & 2 deletions t/str_xform.t
@@ -1,8 +1,10 @@
use Test::More tests => 1;
use Test::More;

use Symbol::Approx::Sub (xform => 'Text::Soundex');


sub a_a { 'aa' }

ok(aa() eq 'aa');
is(aa(), 'aa');

done_testing;