{"id":16304843,"url":"https://github.com/moznion/test-synopsis-expectation","last_synced_at":"2025-10-25T14:30:27.250Z","repository":{"id":12290706,"uuid":"14918230","full_name":"moznion/Test-Synopsis-Expectation","owner":"moznion","description":"Test SYNOPSIS code with expectations","archived":false,"fork":false,"pushed_at":"2014-12-16T02:27:56.000Z","size":312,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-31T07:34:18.786Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://metacpan.org/release/Test-Synopsis-Expectation","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moznion.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-04T08:22:53.000Z","updated_at":"2014-12-16T02:27:54.000Z","dependencies_parsed_at":"2022-09-02T21:51:12.103Z","dependency_job_id":null,"html_url":"https://github.com/moznion/Test-Synopsis-Expectation","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2FTest-Synopsis-Expectation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2FTest-Synopsis-Expectation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2FTest-Synopsis-Expectation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2FTest-Synopsis-Expectation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moznion","download_url":"https://codeload.github.com/moznion/Test-Synopsis-Expectation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238155435,"owners_count":19425712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T21:04:57.423Z","updated_at":"2025-10-25T14:30:26.911Z","avatar_url":"https://github.com/moznion.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/moznion/Test-Synopsis-Expectation.svg?branch=master)](https://travis-ci.org/moznion/Test-Synopsis-Expectation) [![Coverage Status](https://img.shields.io/coveralls/moznion/Test-Synopsis-Expectation/master.svg)](https://coveralls.io/r/moznion/Test-Synopsis-Expectation?branch=master)\n# NAME\n\nTest::Synopsis::Expectation - Test that SYNOPSIS code produces expected results\n\n# SYNOPSIS\n\n    use Test::Synopsis::Expectation;\n\n    synopsis_ok('eg/sample.pod');\n    done_testing;\n\nFollowing, SYNOPSIS of `eg/sample.pod`\n\n    my $num;\n    $num = 1; # =\u003e 1\n    ++$num;   # =\u003e is 2\n\n    use PPI::Tokenizer;\n    my $tokenizer = PPI::Tokenizer-\u003enew(\\'code'); # =\u003e isa 'PPI::Tokenizer'\n\n    my $str = 'Hello, I love you'; # =\u003e like qr/ove/\n\n    my $obj = {\n        foo =\u003e [\"bar\", \"baz\"],\n    }; # =\u003e is_deeply { foo =\u003e [\"bar\", \"baz\"] }\n\n    my $bool = 1; # =\u003e success\n\n# DESCRIPTION\n\nThis module checks that a module's SYNOPSIS section is syntactically correct,\nand will also check that it produces the expected results,\nbased on annotations you add in comments.\n\n# FUNCTIONS\n\n- synopsis\\_ok($files)\n\n    This function tests SYNOPSIS codes of each files.\n    This function expects file names as an argument as ARRAYREF or SCALAR.\n    (This function is exported)\n\n- all\\_synopsis\\_ok()\n\n    This function tests SYNOPSIS codes of the all of library files.\n    This function uses `MANIFEST` to list up the target files of testing.\n    (This function is exported)\n\n- prepare($code\\_str)\n\n    Register the executable codes to prepare for evaluation.\n\n    If you use like;\n\n        use Test::Synopsis::Expectation;\n        Test::Synopsis::Expectation::prepare('my $foo = 1;');\n        synopsis_ok('path/to/target.pm');\n        done_testing;\n\n        ### Following, SYNOPSIS of `target.pm`\n        $foo; # =\u003e 1\n\n    Then, SYNOPSIS of `target.pm` is the same as;\n\n        my $foo = 1;\n        $foo; # =\u003e 1\n\n    (This function is not exported)\n\n- set\\_ignorings\n\n    Set the procedures which would like to ignore.\n\n        use Test::Synopsis::Expectation;\n        Test::Synopsis::Expectation::set_ignorings(['++$num;']);\n        synopsis_ok(*DATA);\n        done_testing;\n\n        __DATA__\n        =head1 SYNOPSIS\n\n            my $num;\n            $num = 1; # =\u003e 1\n            ++$num;\n            $num; # =\u003e 1\n\n    In the above example, `++$num;` will be ignored.\n\n# NOTATION OF EXPECTATION\n\nComment that starts at `# =\u003e` then this module treats the comment as test statement.\n\n- # =\u003e is\n\n        my $foo = 1; # =\u003e is 1\n\n    This way is equivalent to the next.\n\n        my $foo = 1;\n        is $foo, 1;\n\n    This carries out the same behavior as `Test::More::is`.\n\n- # =\u003e\n\n        my $foo = 1; # =\u003e 1\n\n    This notation is the same as `# =\u003e is`\n\n- # =\u003e isa\n\n        use Foo::Bar;\n        my $instance = Foo::Bar-\u003enew; # =\u003e isa 'Foo::Bar'\n\n    This way is equivalent to the next.\n\n        use Foo::Bar;\n        my $instance = Foo::Bar-\u003enew;\n        isa_ok $instance, 'Foo::Bar';\n\n    This carries out the same behavior as `Test::More::isa_ok`.\n\n- # =\u003e like\n\n        my $str = 'Hello, I love you'; # =\u003e like qr/ove/\n\n    This way is equivalent to the next.\n\n        my $str = 'Hello, I love you';\n        like $str, qr/ove/;\n\n    This carries out the same behavior as `Test::More::like`.\n\n- # =\u003e is\\_deeply\n\n        my $obj = {\n            foo =\u003e [\"bar\", \"baz\"],\n        }; # =\u003e is_deeply { foo =\u003e [\"bar\", \"baz\"] }\n\n    This way is equivalent to the next.\n\n        my $obj = {\n            foo =\u003e [\"bar\", \"baz\"],\n        };\n        is_deeply $obj, { foo =\u003e [\"bar\", \"baz\"] };\n\n    This carries out the same behavior as `Test::More::is_deeply`.\n\n- # =\u003e success\n\n        my $bool = 1;\n        $bool; # =\u003e success\n\n    This way checks value as boolean.\n    If target value of testing is 0 then this test will fail. Otherwise, it will pass.\n\n# ANNOTATIONS\n\n- =for test\\_synopsis\\_expectation\\_no\\_test\n\n    The code block behind this annotation will not be tested.\n\n            my $sum;\n            $sum = 1; # =\u003e 1\n\n        =for test_synopsis_expectation_no_test\n\n            my $sum;\n            $sum = 1; # =\u003e 2\n\n    In this example, the first code block will be tested, but the second will not.\n\n# RESTRICTION\n\n## Test case must be one line\n\nThe following is valid;\n\n    my $obj = {\n        foo =\u003e [\"bar\", \"baz\"],\n    }; # =\u003e is_deeply { foo =\u003e [\"bar\", \"baz\"] }\n\nHowever, the following is invalid;\n\n    my $obj = {\n        foo =\u003e [\"bar\", \"baz\"],\n    }; # =\u003e is_deeply {\n       #        foo =\u003e [\"bar\", \"baz\"]\n       #    }\n\nSo test case must be one line.\n\n## Not put test cases inside of for(each)\n\n    # Example of not working\n    for (1..10) {\n        my $foo = $_; # =\u003e 10\n    }\n\nThis example doesn't work. On the contrary, it will be error (Probably nobody uses such as this way... I think).\n\n# NOTES\n\n## yada-yada operator\n\nThis module ignores yada-yada operators that is in SYNOPSIS code.\nThus, following code is runnable.\n\n    my $foo;\n    ...\n    $foo = 1; # =\u003e 1\n\n# SEE ALSO\n\n[Test::Synopsis](https://metacpan.org/pod/Test::Synopsis) - simpler module, which just checks the syntax of your SYNOPSIS section.\n\n[Dist::Zilla::Plugin::Test::Synopsis](https://metacpan.org/pod/Dist::Zilla::Plugin::Test::Synopsis) - a plugin for [Dist::Zilla](https://metacpan.org/pod/Dist::Zilla) users, which adds a release test\nto your distribution, based on [Test::Synopsis](https://metacpan.org/pod/Test::Synopsis).\n\n# REPOSITORY\n\n[https://github.com/moznion/Test-Synopsis-Expectation](https://github.com/moznion/Test-Synopsis-Expectation)\n\n# LICENSE\n\nCopyright (C) moznion.\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n\n# AUTHOR\n\nmoznion \u003cmoznion@gmail.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Ftest-synopsis-expectation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoznion%2Ftest-synopsis-expectation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Ftest-synopsis-expectation/lists"}