Test::...eption(3pm)

πŸŽ€ NAME πŸŽ€

Test::Unit::Assertion::Exception β€” an assertion bestie that checks whether a thing got raised πŸ”₯

Yes queen, you're reading Test::...eption(3pm), and it's exactly what it says on the tin: an assertion class for exceptions that got thrown. No cap. πŸ’…


✨ SYNOPSIS ✨

require Test::Unit::Assertion::Exception;

my $assert_raised =
  Test::Unit::Assertion::Exception->new('MyException');

# This should succeed
$assert_eq->do_assertion(sub { MyException->throw() });

# This should fail
$assert_eq->do_assertion(sub { });

okay so like β€” look at those two do_assertion calls πŸ‘€. First one throws MyException so it's a vibe check pass βœ…. Second one just... does nothing, no exception, so it's a fail πŸ’€. Literally the whole point of the thing.


πŸ’– DESCRIPTION πŸ’–

So the SYNOPSIS is out here showing you how to use Test::Unit::Assertion::Exception all by yourself, directly, main character style πŸ‘‘ β€” and you can, it's a free country β€” but the actually sensible move, the one the cool kids do, is to use it indirectly via Test::Unit::Test::assert_raises(), which goes ahead and instantiates a Test::Unit::Assertion::Exception for you. So you don't have to do the manual labour, slay. 🫢

ngl, that's the whole description. It's a short page but it ate. ✨


🌸 AUTHOR 🌸

Copyright (c) 2001 Piers Cawley <pdcawley@iterative-software.com>.

All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ“œ (yes bestie, same terms as Perl itself, iconic licensing behaviour 🧚)


πŸ¦‹ SEE ALSO πŸ¦‹

  • Test::Unit::TestCase
  • Test::Unit::Assertion

πŸ“ lowkey reminder: this page is not the main event. Go read those two above if you wanna understand the whole ecosystem, iykyk.

That's the whole page, bestie!! Written by the lovely folks over at User Contributed Perl Documentation, sitting pretty in perl v5.40.1, dated 2026-04-05, and filed under Test::...eption(3pm). Go forth and assert your exceptions πŸ’–βœ¨πŸ’…

πŸ“¦ where this page comes from