The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Build Status Coverage Status

NAME

Test::Synopsis::Expectation - Test SYNOPSIS code with expectations

SYNOPSIS

use Test::Synopsis::Expectation;

synopsis_ok('eg/sample.pod');
done_testing;

Following, SYNOPSIS of eg/sample.pod

my $num;
$num = 1; # => 1
++$num;   # => is 2

use PPI::Tokenizer;
my $tokenizer = PPI::Tokenizer->new(\'code'); # => isa 'PPI::Tokenizer'

my $str = 'Hello, I love you'; # => like qr/ove/

my $obj = {
    foo => ["bar", "baz"],
}; # => is_deeply { foo => ["bar", "baz"] }

my $bool = 1; # => success

DESCRIPTION

Test::Synopsis::Expectation is the test module to test the SYNOPSIS code with expectations. This module can check the SYNOPSIS is valid syntax or not, and tests whether the result is suitable for expected.

FUNCTIONS

NOTATION OF EXPECTATION

Comment that starts at # => then this module treats the comment as test statement.

ANNOTATIONS

RESTRICTION

Test case must be one line

The following is valid;

my $obj = {
    foo => ["bar", "baz"],
}; # => is_deeply { foo => ["bar", "baz"] }

However, the following is invalid;

my $obj = {
    foo => ["bar", "baz"],
}; # => is_deeply {
   #        foo => ["bar", "baz"]
   #    }

So test case must be one line.

Not put test cases inside of for(each)

# Example of not working
for (1..10) {
    my $foo = $_; # => 10
}

This example doesn't work. On the contrary, it will be error (Probably nobody uses such as this way... I think).

NOTES

yada-yada operator

This module ignores yada-yada operators that is in SYNOPSIS code. Thus, following code is runnable.

my $foo;
...
$foo = 1; # => 1

LICENSE

Copyright (C) moznion.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

AUTHOR

moznion moznion@gmail.com