From e0d80eae738a788497b6271957e09919c9636a98 Mon Sep 17 00:00:00 2001 From: Kazuho Oku Date: Thu, 8 Oct 2009 20:02:32 +0900 Subject: [PATCH] add test, Makefile.PL --- Makefile.PL | 21 +++++++++++++++++++++ cppref | 29 ++++++++++++++++++++++++++++- t/00base.t | 13 +++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 Makefile.PL create mode 100644 t/00base.t diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..13ac6c7 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,21 @@ +use inc::Module::Install; + +name 'cppref'; +all_from 'cppref'; +readme_from 'cppref'; + +no_index 'orig'; + +configure_requires 'Module::Install::ReadmeFromPod'; +configure_requires 'File::Slurp'; +requires 'File::ShareDir'; + +install_script 'cppref'; +install_share 'doc'; + +auto_include; +auto_install; + +WriteAll; + +do 'tidy.pl'; diff --git a/cppref b/cppref index f618777..4020504 100755 --- a/cppref +++ b/cppref @@ -6,9 +6,11 @@ use File::Basename; use File::Find (); use File::ShareDir (); +our $VERSION = '0.01'; + my $doc_dir = "doc"; eval { - $doc_dir = File::ShareDir::dist_dir('cppref') . "/doc"; + $doc_dir = File::ShareDir::dist_dir('cppref'); }; my $name = shift @ARGV || 'start'; @@ -51,3 +53,28 @@ sub open_file { exec 'w3m', $fn; die "failed to exec w3m:$!"; } + +__END__ + +=head1 NAME + +cppref - man-style access to cppreference.com documents + +=head1 SYNOPSIS + + % cppref # prints top page + % cppref vector # prints vector docs + +=head1 AUTHOR + +Copyright (c) 2009 Kazuho Oku All rights reserved + +=head1 LICENSE + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +See http://www.perl.com/perl/misc/Artistic.html + +The documents are from http://www.cppreference.com/ (under Creative Commons Attribution 3.0 license). + +=cut diff --git a/t/00base.t b/t/00base.t new file mode 100644 index 0000000..1ee57be --- /dev/null +++ b/t/00base.t @@ -0,0 +1,13 @@ +use strict; +use warnings; + +use Test::More tests => 7; + +is(system("blib/script/cppref > /dev/null"), 0, 'top page'); +is(system("blib/script/cppref stl::vector::push_back > /dev/null"), 0, 'exact path'); +is(system("blib/script/cppref stl/vector/push_back > /dev/null"), 0, 'exact path using slashes'); +is(system("blib/script/cppref stl > /dev/null"), 0, 'dir'); +is(system("blib/script/cppref faq > /dev/null"), 0, 'search'); +is(system("blib/script/cppref hokhokhok > /dev/null 2>&1"), 256, 'not found'); +is(system("blib/script/cppref push_back > /dev/null 2>&1"), 512, 'multiple choices'); +