Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Test exception (#28)
- Loading branch information
Showing
4 changed files
with
18 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,36 @@ | ||
use Test::More; | ||
use Test::Exception; | ||
|
||
require Symbol::Approx::Sub; | ||
|
||
note('Hashref transformer'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(xform => {}); | ||
}; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid transformer/, 'Got the right exception'); | ||
} qr/^Invalid transformer/, 'Got the right exception'; | ||
|
||
note('Hashref transformer in an arrayref'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(xform => [{}]); | ||
}; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid transformer/, 'Got the right exception'); | ||
} qr/^Invalid transformer/, 'Got the right exception'; | ||
|
||
note('Hashref matcher'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(match => {}); | ||
}; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid matcher/, 'Got the right exception'); | ||
} qr/^Invalid matcher/, 'Got the right exception'; | ||
|
||
note('Arrayref matcher'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(match => []); | ||
}; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid matcher/, 'Got the right exception'); | ||
} qr/^Invalid matcher/, 'Got the right exception'; | ||
|
||
note('Hashref chooser'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(choose => {}); | ||
}; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid chooser/, 'Got the right exception'); | ||
} qr/^Invalid chooser/, 'Got the right exception'; | ||
|
||
note('Arrayref chooser'); | ||
eval { | ||
throws_ok { | ||
Symbol::Approx::Sub->import(choose => []); | ||
}; | ||
} qr/^Invalid chooser/, 'Got the right exception'; | ||
|
||
ok($@, 'Got an exception'); | ||
like($@, qr/^Invalid chooser/, 'Got the right exception'); | ||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters