Skip to content

Commit

Permalink
New tests (#9)
Browse files Browse the repository at this point in the history
* Improved tests
  • Loading branch information
davorg authored Oct 6, 2016
1 parent 9042f73 commit 5abdb04
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 27 deletions.
6 changes: 4 additions & 2 deletions t/anon.t
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 5abdb04

Please sign in to comment.