diff --git a/META.json b/META.json index 2642872..4c49375 100644 --- a/META.json +++ b/META.json @@ -1,10 +1,10 @@ { - "abstract" : "It's new $module", + "abstract" : "assert keyword for Perl", "author" : [ "kobaken " ], "dynamic_config" : 0, - "generated_by" : "Minilla/v3.1.24, CPAN::Meta::Converter version 2.150010", + "generated_by" : "Minilla/v3.1.25, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], diff --git a/README.md b/README.md index 45464d2..cdd4726 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,30 @@ [![Actions Status](https://github.com/kfly8/Syntax-Keyword-Assert/actions/workflows/test.yml/badge.svg)](https://github.com/kfly8/Syntax-Keyword-Assert/actions) # NAME -Syntax::Keyword::Assert - It's new $module +Syntax::Keyword::Assert - assert keyword for Perl # SYNOPSIS use Syntax::Keyword::Assert; + sub hello($name) { + assert { defined $name }; + say "Hello, $name!"; + } + + hello("Alice"); # => Hello, Alice! + hello(); # => Dies when STRICT_MODE is enabled + # DESCRIPTION -Syntax::Keyword::Assert is ... +This module provides a syntax plugin that introduces an **assert** keyword to Perl. +It dies when the block returns false and `STRICT` mode is enabled. When `STRICT` mode is disabled, the block is ignored at compile time. The syntax is simple, `assert BLOCK`. + +`STRICT` mode is controlled by [Devel::StrictMode](https://metacpan.org/pod/Devel%3A%3AStrictMode). + +# SEE ALSO + +[PerlX::Assert](https://metacpan.org/pod/PerlX%3A%3AAssert), [Devel::Assert](https://metacpan.org/pod/Devel%3A%3AAssert), [Carp::Assert](https://metacpan.org/pod/Carp%3A%3AAssert) # LICENSE diff --git a/lib/Syntax/Keyword/Assert.pm b/lib/Syntax/Keyword/Assert.pm index 7dc2429..14360ec 100644 --- a/lib/Syntax/Keyword/Assert.pm +++ b/lib/Syntax/Keyword/Assert.pm @@ -49,15 +49,30 @@ __END__ =head1 NAME -Syntax::Keyword::Assert - It's new $module +Syntax::Keyword::Assert - assert keyword for Perl =head1 SYNOPSIS use Syntax::Keyword::Assert; + sub hello($name) { + assert { defined $name }; + say "Hello, $name!"; + } + + hello("Alice"); # => Hello, Alice! + hello(); # => Dies when STRICT_MODE is enabled + =head1 DESCRIPTION -Syntax::Keyword::Assert is ... +This module provides a syntax plugin that introduces an B keyword to Perl. +It dies when the block returns false and C mode is enabled. When C mode is disabled, the block is ignored at compile time. The syntax is simple, C. + +C mode is controlled by L. + +=head1 SEE ALSO + +L, L, L =head1 LICENSE