ktats****@users*****
ktats****@users*****
2011年 1月 29日 (土) 00:08:27 JST
Index: docs/modules/Test-Simple-0.96/lib/Test/More.pod diff -u docs/modules/Test-Simple-0.96/lib/Test/More.pod:1.2 docs/modules/Test-Simple-0.96/lib/Test/More.pod:1.3 --- docs/modules/Test-Simple-0.96/lib/Test/More.pod:1.2 Thu Jan 27 01:58:25 2011 +++ docs/modules/Test-Simple-0.96/lib/Test/More.pod Sat Jan 29 00:08:27 2011 @@ -59,13 +59,18 @@ =head1 説æ +=begin original + B<STOP!> If you're just getting started writing tests, have a look at L<Test::Simple> first. This is a drop in replacement for Test::Simple which you can switch to once you get the hang of basic testing. +=end original + B<å¾ ã£ã!>ãããä»åãã¦ããã¹ããæ¸ããã¨ãã¦ããã®ãªããTest::Simpleãã¾ãè¦ã¦ãã ããã Test::Moreã¯ãåºæ¬çãªãã¹ãã®ã³ããå¾ã¦ãç½®ãæãå¯è½ãªTest::Simpleã®å·®è¾¼å¼ã®ç½®æã§ãã +=begin original The purpose of this module is to provide a wide range of testing utilities. Various ways to say "ok" with better diagnostics, @@ -73,6 +78,8 @@ data structures. While you can do almost anything with a simple C<ok()> function, it doesn't provide good diagnostic output. +=end original + ãã®ã¢ã¸ã¥ã¼ã«ã®ç®çã¯ãå¤§å¹ ãªãã¹ãã¦ã¼ãã£ãªãã£ãæä¾ãããã¨ã§ãã ãããã診æã§ãokãã¨ç¤ºãæ¹æ³ãç¨æãããããã¹ããç°¡åã«ã¹ããããããã å°æ¥çãªå®è£ ããã¹ãããããè¤éãªãã¼ã¿æ§é ãæ¯è¼ãããããæ§ã ãªæ©è½ãããã¾ãã @@ -80,23 +87,35 @@ =head2 è¨ç»ãä¸ç·ã«æ¥ããªããããã大äºã«ãã +=begin original + Before anything else, you need a testing plan. This basically declares how many tests your script is going to run to protect against premature failure. +=end original + ä»ã®ä½ããåã«ããã¹ãã®è¨ç»ãå¿ è¦ã§ãã scriptãè¡ããã¨ãã¦ãããã¹ããããã¤ã§ãããã¨ãããã®åºæ¬çãªå®£è¨ã¯ãåå§çãªå¤±æã«å¯¾ããä¿è·ã«ãªãã¾ãã +=begin original + The preferred way to do this is to declare a plan when you C<use Test::More>. +=end original + ãã®ä¿è·ãè¡ã好ã¾ããæ¹æ³ã¯ãC<use Test::More> ãæ¸ãæã«ãè¨ç»ã宣è¨ãããã¨ã§ãã use Test::More tests => 23; +=begin original + There are cases when you will not know beforehand how many tests your script is going to run. In this case, you can declare your tests at the end. +=end original + scriptãè¡ããã¨ãã¦ãããã¹ããããã¤ããããäºåã«ç¥ããªããããªãã¾ããªã±ã¼ã¹ãããã¾ãã ããããã±ã¼ã¹ã§ã¯ãæå¾ã«ãã¹ãã宣è¨ãããã¨ãã§ãã¾ãã @@ -107,47 +126,71 @@ done_testing( $number_of_tests_run ); +=begin original + Sometimes you really don't know how many tests were run, or it's too difficult to calculate. In which case you can leave off $number_of_tests_run. +=end original + ããã¤ã®ãã¹ããå®è¡ããããæ¬å½ã«åãããªãæããè¨ç®ããã®ã大å¤ãªæã«ä½¿ãã¾ãã ãã®ãããªã±ã¼ã¹ã§ã¯ã$number_of_tests_runãçããã¨ãã§ãã¾ãã +=begin original + In some cases, you'll want to completely skip an entire testing script. +=end original + ããã¤ãã®ã±ã¼ã¹ã§ã¯ããããã¹ãscriptå ¨ã¦ãå®å ¨ã«ã¹ããããããã§ãããã use Test::More skip_all => $skip_reason; +=begin original + Your script will declare a skip with the reason why you skipped and exit immediately with a zero (success). See L<Test::Harness> for details. +=end original + scriptãããªãã¹ãããããã®ãã®çç±ã宣è¨ããã¨ãå³åº§ã«0(æå)ã§çµäºãã¾ãã 詳細ã«ã¤ãã¦ã¯L<Test::Harness>ãã¿ã¦ãã ããã +=begin original + If you want to control what functions Test::More will export, you have to use the 'import' option. For example, to import everything but 'fail', you'd do: +=end original + Test::Moreãã¨ã¯ã¹ãã¼ãããé¢æ°ãã³ã³ããã¼ã«ããããã°ã 'import'ãªãã·ã§ã³ã使ãå¿ è¦ãããã¾ãã ãã¨ãã°ã'fail'ãé¤ãã¦ãå ¨ã¦ãã¤ã³ãã¼ãããããªãã次ã®ããã«ãã¾ãï¼ use Test::More tests => 23, import => ['!fail']; +=begin original + Alternatively, you can use the plan() function. Useful for when you have to calculate the number of tests. +=end original + 代ããã«ãplan() é¢æ°ã使ããã¨ãåºæ¥ã¾ãã ãã¹ãã®æ°ãè¨ç®ããªããã°ãªããªããªããæçã§ãã use Test::More; plan tests => keys %Stuff * 3; +=begin original + or for deciding between running the tests at all: +=end original + ã¾ãã¯ããã¹ããèµ°ããã¦ããéã«æ±ºããããã«ã¯ï¼ use Test::More; @@ -167,24 +210,35 @@ done_testing(); done_testing($number_of_tests); +=begin original + If you don't know how many tests you're going to run, you can issue the plan when you're done running tests. +=end original + å®è¡ãããã¨ãã¦ãããã¹ããããã¤ãããããªãå ´åããã¹ãã®å®è¡ãçµããã¨ãã« è¨ç»ãçºè¡¨ããããã¨ãã§ãã¾ãã +=begin original $number_of_tests is the same as plan(), it's the number of tests you expected to run. You can omit this, in which case the number of tests you ran doesn't matter, just the fact that your tests ran to conclusion. +=end original + $number_of_tests ã¯ãplan()ã¨åãã§ããå®è¡ãããã¨ãã¦ãããã¹ãã®æ°ã§ãã ãããçç¥ãããã¨ãã§ãã¾ãããã®å ´åããã¹ãã®æ°ã¯åé¡ã«ãã¾ããã æå¾ã¾ã§ãã¹ããå®è¡ãããããåé¡ã«ãã¾ãã +=begin original + This is safer than and replaces the "no_plan" plan. +=end original + "no_plan"ãªè¨ç»ããå®å ¨ã§ã"no_plan"ãç½®ãæãããã®ã§ãã =back @@ -194,15 +248,18 @@ =head2 ãã¹ãã®åå +=begin original + By convention, each test is assigned a number in order. This is largely done automatically for you. However, it's often very useful to assign a name to each test. Which would you rather see: +=end original + 便å®ã®ããã«ãããããã®ãã¹ãã¯ãé çªã«çªå·ãå²ãæ¯ããã¦ãã¾ãã ããã¯ã主ã«èªåçã«è¡ããã¾ããã§ããããã¹ãã«ååãå²ãå½ã¦ãã¨ã ã¨ã¦ãæçãªãã¨ãããããã¾ããã©ã¡ããããã§ãããã: - ok 4 not ok 5 ok 6 @@ -213,32 +270,48 @@ not ok 5 - simple exponential ok 6 - force == mass * acceleration +=begin original + The later gives you some idea of what failed. It also makes it easier to find the test in your script, simply search for "simple exponential". +=end original + å¾è ã¯ãä½ã失æãããã®æããããä¸ãã¦ããã¾ãã ã¾ããscriptä¸ã®ãã¹ããè¦ã¤ãããããªãããç°¡åãªææ°é¢æ°ãã楽ã«æ¢ãã¾ãã +=begin original + All test functions take a name argument. It's optional, but highly suggested that you use it. +=end original + å ¨ã¦ã®ãã¹ãã®é¢æ°ã¯ãååãå¼æ°ã«ã¨ãã¾ããååã®å¼æ°ã¯ããªãã·ã§ãã«ã§ã¯ããã¾ããã 使ããã¨ãå¼·ãæ¨å¥¨ããã¦ãã¾ãã =head2 I'm ok, you're not ok. +=begin original + The basic purpose of this module is to print out either "ok #" or "not ok #" depending on if a given test succeeded or failed. Everything else is just gravy. +=end original + ãã®ã¢ã¸ã¥ã¼ã«ã®åºæ¬çãªç®çã¯ãä¸ãããã¹ããã失æããããæåãããã§ã ãok çªå·ããããnot ok çªå·ãã®ã©ã¡ãããåºåãããã¨ã§ããä»ã®å ¨ã¦ã¯ããã ã®ãã¾ãã§ãã +=begin original + All of the following print "ok" or "not ok" depending on if the test succeeded or failed. They all also return true or false, respectively. +=end original + ãã®ä¸ã«æ¸ãã¦ãããã®ã¯å ¨ã¦ããã¹ããæåããã失æãããã©ããã«ãã£ã¦ããokãããnot okãã表示ãã¾ãã ãããã¯ãå ¨ã¦ãããããçãå½ãè¿ãã¾ãã @@ -248,10 +321,14 @@ ok($got eq $expected, $test_name); +=begin original + This simply evaluates any expression (C<$got eq $expected> is just a simple example) and uses that to determine if the test succeeded or failed. A true expression passes, a false one fails. Very simple. +=end original + ããã¯åç´ã«ãã©ããªå¼ãè©ä¾¡ãã¾ã(C<$got eq $expected>ã¯ãã ã®ç°¡åãªä¾ã§ã)ã ããã¦ããã¹ããæåãããã©ããã決ããã®ã«ä½¿ãã¾ãã çã®å¼ã¯åæ ¼ããå½ã®å¼ã¯å¤±æã§ããã¨ã¦ãç°¡åã§ãã @@ -265,26 +342,38 @@ (è¦ããã: "This is ok.") +=begin original + $test_name is a very short description of the test that will be printed out. It makes it very easy to find a test in your script when it fails and gives others an idea of your intentions. $test_name is optional, but we B<very> strongly encourage its use. +=end original + C<$test_name>ã¯ãã¨ã¦ãçããã¹ãã®èª¬æã§ãå®è¡æã«åºåããã¾ãã $test_nameã¯ããã¹ãã失æããå ´åã«ãscriptä¸ã®ãã¹ããã¨ã¦ãè¦ã¤ãããããã¾ãã ããã«ãä»ã®äººã«ãããªãã®æå³ããèããä¼ãã¾ãã$test_nameã¯ãã¯ããªãã·ã§ãã«ã§ããã 使ããã¨ãå¼·ãå§ãããã¦ãã¾ãã +=begin original + Should an ok() fail, it will produce some diagnostics: +=end original + ä¸ä¸ãok()ã失æããå ´åãã¡ãã£ã¨ãã診æãæä¾ãã¾ã: not ok 18 - sufficient mucus # Failed test 'sufficient mucus' # in foo.t at line 42. +=begin original + This is the same as Test::Simple's ok() routine. +=end original + ããã¯ãTest::Simpleã®C<ok()> ã«ã¼ãã³ã¨åãã§ãã =item B<is> @@ -294,10 +383,14 @@ is ( $got, $expected, $test_name ); isnt( $got, $expected, $test_name ); +=begin original + Similar to ok(), is() and isnt() compare their two arguments with C<eq> and C<ne> respectively and use the result of that to determine if the test succeeded or failed. So these: +=end original + ok() 㨠is() 㨠isnt() ã®é¡ä¼¼ç¹ã¯ãäºã¤ã®å¼æ°ãããããC<eq> 㨠C<ne>ã§æ¯è¼ãã ãã®çµæã使ã£ã¦ããã¹ããæåãããã失æãããã決ãããã¨ã§ããããã§ããããã¯ï¼ @@ -314,11 +407,15 @@ (è¦ããã: "This is that." "This isn't that.") +=begin original + So why use these? They produce better diagnostics on failure. ok() cannot know what you are testing for (beyond the name), but is() and isnt() know what the test was and why it failed. For example this test: +=end original + ã©ããã¦ãããã使ãã®ã§ãããï¼ is() 㨠isnt() ã¯ã失æã«é¢ãã¦ããããã診æãã ãã¾ãã ok()ã¯ã(åå以ä¸ã«ã¯)ä½ã®ããã«ãã¹ãããã¦ããã®ãç¥ããã¨ãåºæ¥ã¾ãããã is()ã¨isnt()ã¯ããã¹ããä½ã§ããã¹ãããªã失æããããç¥ã£ã¦ãã¾ãã @@ -327,8 +424,12 @@ my $foo = 'waffle'; my $bar = 'yarblokos'; is( $foo, $bar, 'Is foo the same as bar?' ); +=begin original + Will produce something like this: +=end original + ãã®ãããªãã®ãåºåãã¾ã: not ok 17 - Is foo the same as bar? @@ -337,14 +438,22 @@ # got: 'waffle' # expected: 'yarblokos' +=begin original + So you can figure out what went wrong without rerunning the test. +=end original + ããã§ããã¹ããå度走ãããã«ä½ãééã£ãã®ããå¤æã§ãã¾ãã +=begin original + You are encouraged to use is() and isnt() over ok() where possible, however do not be tempted to use them to find out if something is true or false! +=end original + å¯è½ãªããis() 㨠isnt()ãok()ã®ä»£ããã«ä½¿ããã¨ãå§ãã¾ãã ã§ãããä½ãããçã§ãããå½ã§ããããè¦ã¤ãåºãããã«ã is() 㨠isnt() ã使ããã¨ãã¦ã¯ããã¾ãã! @@ -352,20 +461,28 @@ # XXX BAD! is( exists $brooklyn{tree}, 1, 'A tree grows in Brooklyn' ); +=begin original + This does not check if C<exists $brooklyn{tree}> is true, it checks if it returns 1. Very different. Similar caveats exist for false and 0. In these cases, use ok(). +=end original + ãã®ã³ã¼ãã¯ãC<exsits $brooklyn{tree}> ãçã§ãããã©ããããã§ãã¯ãã¾ããã ãã®ã³ã¼ãã¯ã1ãè¿ããã©ããããã§ãã¯ãã¾ãããããã¯ã¾ã£ããéãã¾ãã ä¼¼ããããªè¦åã¯ãå½ ã¨ 0 ã«ãå¨ãã¾ããããããã±ã¼ã¹ã§ã¯ãok() ã使ãã¾ãã ok( exists $brooklyn{tree}, 'A tree grows in Brooklyn' ); +=begin original + A simple call to isnt() usually does not provide a strong test but there are cases when you cannot say much more about a value than that it is different from some other value: +=end original + åç´ã« isnt() ãå¼ã³åºãã®ã¯ãæ®éãå¼·ããã¹ããæä¾ãã¾ããã å¤ã«ã¤ãã¦ä»ã®å¤ããéã£ã¦ãããã¨ããå¤ã«ã¤ãã¦è¨ããªããããªæã«ã é©ãã¦ãã¾ãã @@ -378,9 +495,13 @@ isnt $obj, $clone, "clone() produces a different object"; +=begin original + For those grammatical pedants out there, there's an C<isn't()> function which is an alias of isnt(). +=end original + ææ³å¦è ã¶ã人ã®ããã«ãæ¸ãã¦ããã¨ãC<isn't()> é¢æ°ã¯ isnt()é¢æ°ã® ã¨ã¤ãªã¢ã¹ã¨ãã¦åå¨ãã¦ã¾ãã @@ -388,8 +509,12 @@ like( $got, qr/expected/, $test_name ); +=begin original + Similar to ok(), like() matches $got against the regex C<qr/expected/>. +=end original + ok() ã¨ä¼¼ã¦ãã¾ãããlike() ã¯ã å¼æ°ã®$gotãæ£è¦è¡¨ç¾ã®C<qr/expected/>ã«ãããããã¾ãã ãã®ããã«: @@ -402,24 +527,36 @@ (è¦ããã "This is like that".) +=begin original + The second argument is a regular expression. It may be given as a regex reference (i.e. C<qr//>) or (for better compatibility with older perls) as a string that looks like a regex (alternative delimiters are currently not supported): +=end original + äºçªç®ã®å¼æ°ã¯æ£è¦è¡¨ç¾ã§ããæ£è¦è¡¨ç¾ã®ãªãã¡ã¬ã³ã¹ (ãã¨ãã°ãC<qr//>)ãã(å¤ãPerlã¨ãããäºææ§ãæããããªã) æ£è¦è¡¨ç¾ã«è¦ããæåå(äºè æä¸ã®åºåãã¯ãç¾å¨ãµãã¼ãããã¦ãã¾ãã)ã¨ãã¦ä¸ãããã¾ãã like( $got, '/expected/', 'this is like that' ); +=begin original + Regex options may be placed on the end (C<'/expected/i'>). +=end original + æ£è¦è¡¨ç¾ã®ãªãã·ã§ã³ã¯çµããã«ç½®ããã¾ã (C<'/expected/i'>)ã +=begin original + Its advantages over ok() are similar to that of is() and isnt(). Better diagnostics on failure. +=end original + ok()ã¨æ¯ã¹ãã¨ãã®å©ç¹ã¯ãis() 㨠isnt()ã®å©ç¹ã«ä¼¼ã¦ãã¾ãã 失æã«é¢ãã¦ããã診æãã¾ãã @@ -427,9 +564,13 @@ unlike( $got, qr/expected/, $test_name ); +=begin original + Works exactly as like(), only it checks if $got B<does not> match the given pattern. +=end original + like()ã®ããã«åãã¾ããã $got ãä¸ãããã¿ã¼ã³ã«ãããB<ããªã>ãã¨ã ãã ãã§ãã¯ãã¾ãã @@ -437,9 +578,13 @@ cmp_ok( $got, $op, $expected, $test_name ); +=begin original + Halfway between ok() and is() lies cmp_ok(). This allows you to compare two arguments using any binary perl operator. +=end original + ok() 㨠is() ã®ä¸éã« cmp_ok()ãããã¾ãã ããã¯ããã¹ã¦ã®ãã¤ããªã®Perlã®æ¼ç®åã使ã£ã¦ãäºã¤ã®å¼æ°ãæ¯è¼ãããã¨ã許ãã¾ãã @@ -453,9 +598,13 @@ cmp_ok( $got, '&&', $expected, 'this && that' ); ...etc... +=begin original + Its advantage over ok() is when the test fails you'll know what $got and $expected were: +=end original + ok()ã¨æ¯ã¹ãã¨ãã® cmp_ok ã® å©ç¹ã¯ããã¹ãã失æããã¨ãã«ã $got 㨠$expected ãä½ããããããã¨ã§ãã @@ -465,16 +614,24 @@ # && # undef +=begin original + It's also useful in those cases where you are comparing numbers and is()'s use of C<eq> will interfere: +=end original + cmp_ok ã¯ãæ°ãæ¯è¼ããéããis() ã eq ã¨ãã¦ä½¿ããã¨ããå¹²æ¸ããéã«ãæçã§ããã: cmp_ok( $big_hairy_number, '==', $another_big_hairy_number ); +=begin original + It's especially useful when comparing greater-than or smaller-than relation between values: +=end original + 2ã¤ã®å¤ã®å¤§å°ã®æ¯è¼ã«ä½¿ãã¨ãé常ã«ä¾¿å©ã§ãã cmp_ok( $some_value, '<=', $upper_limit ); @@ -486,15 +643,23 @@ can_ok($module, @methods); can_ok($object, @methods); +=begin original + Checks to make sure the $module or $object can do these @methods (works with functions, too). +=end original + $module ã $object ã è¤æ°ã®ã¡ã½ãã(ã¾ãã¯ãé¢æ°)@methodsãå®è¡ã§ãããããã§ãã¯ãã¾ãã can_ok('Foo', qw(this that whatever)); +=begin original + is almost exactly like saying: +=end original + ä¸ã®è¡¨ç¾ã¯ãå®éã¯ã以ä¸ã®ãããªæå³ã§ã: ok( Foo->can('this') && @@ -502,15 +667,23 @@ Foo->can('whatever') ); +=begin original + only without all the typing and with a better interface. Handy for quickly testing an interface. +=end original + ãã¹ã¦ãã¿ã¤ãããªãã¦ãããããããã¤ã³ã¿ã¼ãã§ã¼ã¹ã§ãã ç´ æ©ããã¹ãã®ããã®ãæãããªã¤ã³ã¿ã¼ãã§ã¼ã¹ã§ãã +=begin original + No matter how many @methods you check, a single can_ok() call counts as one test. If you desire otherwise, use: +=end original + ããã¤ã® @methods ããããããã§ãã¯ãããã¨ã¯ã大ãããã¨ã§ã¯ããã¾ããã ä¸ã¤ã® can_ok() ã¯ä¸ã¤ã®ãã¹ãã¨ãã¦ãã«ã¦ã³ãããã¾ãã å¥ã®æ¹æ³ã§ããããããªãã次ã®ããã«ä½¿ãã¾ã: @@ -526,29 +699,45 @@ isa_ok($subclass, $class, $object_name); isa_ok($ref, $type, $ref_name); +=begin original + Checks to see if the given C<< $object->isa($class) >>. Also checks to make sure the object was defined in the first place. Handy for this sort of thing: +=end original + C<< $object->isa($class) >>ãä¸ãããã¦ãããã©ãããè¦ãããã®ãã§ãã¯ã ãªãã¸ã§ã¯ããæåã®å ´æã§å®ç¾©ããã¦ããã確ãããããã®ãã§ãã¯ã§ãããã¾ãã my $obj = Some::Module->new; isa_ok( $obj, 'Some::Module' ); +=begin original + where you'd otherwise have to write +=end original + 代ããã«æ¬¡ã®ããã«æ¸ãã¾ãï¼ my $obj = Some::Module->new; ok( defined $obj && $obj->isa('Some::Module') ); +=begin original + to safeguard against your test script blowing up. +=end original + ãã¹ãscriptããå¹ã£é£ã¶ã®ãé²ãããã®ã»ã¼ãã¬ã¼ãã§ãã +=begin original + You can also test a class, to make sure that it has the right ancestor: +=end original + ã¯ã©ã¹ããã¹ãã§ãã¾ããæ£ããå ç¥ã確ããã¾ãã isa_ok( 'Vole', 'Rodent' ); @@ -559,10 +748,14 @@ isa_ok( $array_ref, 'ARRAY' ); +=begin original + The diagnostics of this test normally just refer to 'the object'. If you'd like them to be more specific, you can supply an $object_name (for example 'Test customer'). +=end original + ãã®ãã¹ãã®è¨ºæã¯ãé常ããã ã'ãã®ãªãã¸ã§ã¯ã'ã®ãªãã¡ã¬ã³ã¹ã§ãã ãããããã£ã¨ç¹å®ããããªãã$object_name (ãã¨ãã°ã'Test customer')ãä¾çµ¦ã§ãã¾ãã @@ -573,26 +766,42 @@ my $obj = new_ok( $class => \@args ); my $obj = new_ok( $class => \@args, $object_name ); +=begin original + A convenience function which combines creating an object and calling isa_ok() on that object. +=end original + ãªãã¸ã§ã¯ããä½ãã ãã®ãªãã¸ã§ã¯ãã§ãisa_ok() ã®å¼ã³åºãããã£ã¤ãã 便å©ãªé¢æ°ã§ãã +=begin original + It is basically equivalent to: +=end original + ããã¯ã次ã®ãã®ã¨åºæ¬çã«åãã§ã: my $obj = $class->new(@args); isa_ok $obj, $class, $object_name; +=begin original + If @args is not given, an empty list will be used. +=end original + @argsãä¸ããããªããã°ã空ã®ãªã¹ãã使ããã¾ãã +=begin original + This function only works on new() and it assumes new() will return just a single object which isa C<$class>. +=end original + ãã®é¢æ°ã¯ã new() ã§ã®ã¿åããnew()ããC<$class>㨠isa ã§ãã ä¸ã¤ã®ãªãã¸ã§ã¯ããè¿ããã¨ãæ³å®ãã¦ãã¾ãã @@ -603,16 +812,24 @@ subtest $name => \&code; +=begin original + subtest() runs the &code as its own little test with its own plan and its own result. The main test counts this as a single test using the result of the whole subtest to determine if its ok or not ok. +=end original + subtest() &code ãããèªèº«ã®è¨ç»ã¨çµæããã¤ããèªèº«å°ããªãã¹ãã¨ãã¦ãå®è¡ãã¾ãã ã¡ã¤ã³ã®ãã¹ãã¯ä¸ã¤ã®ãã¹ãã¨ãã¦ã«ã¦ã³ããã¾ãã ãµããã¹ãå ¨ä½ã®çµæã使ã£ã¦ãok ã not ok ã決å®ãã¾ãã +=begin original + For example... +=end original + ä¾ãã°... use Test::More tests => 3; @@ -628,8 +845,12 @@ pass("Third test"); +=begin original + This would produce. +=end original + 以ä¸ã®ããã«åºåããã¾ãã 1..3 @@ -640,9 +861,13 @@ ok 2 - An example subtest ok 3 - Third test +=begin original + A subtest may call "skip_all". No tests will be run, but the subtest is considered a skip. +=end original + subtestã¯ã"skip_all"ãå¼ãã§ããã¾ãã¾ããããã¹ãã¯å®è¡ããã¾ãããã subtest 㯠skip ãããã¨èãããã¾ãã @@ -651,14 +876,22 @@ pass('this test will never be run'); }; +=begin original + Returns true if the subtest passed, false otherwise. +=end original + subtestãéãã°ãçãè¿ããä»ã¯å½ãè¿ãã¾ãã +=begin original + Due to how subtests work, you may omit a plan if you desire. This adds an implicit C<done_testing()> to the end of your subtest. The following two subtests are equivalent: +=end original + ãµããã¹ããã©ã®ããã«åãããã«ãã£ã¦ãæããªãè¨ç»ãçããã¨ãã§ãã¾ãã C<done_testing()> ãæã«è¡ãããµããã¹ããçµãããã¾ãã以ä¸ã®2ã¤ã® ãµããã¹ãã¯åãã§ã: @@ -686,32 +919,43 @@ pass($test_name); fail($test_name); +=begin original + Sometimes you just want to say that the tests have passed. Usually the case is you've got some complicated condition that is difficult to wedge into an ok(). In this case, you can simply use pass() (to declare the test ok) or fail (for not ok). They are synonyms for ok(1) and ok(0). +=end original + æã«ã¯ããã ããã¹ãããã¹ããã¨ç¤ºãããã§ãããã æ®éããã®ã±ã¼ã¹ã¯ãok()ã«ãæ¼ãè¾¼ããã¨ãé£ããè¤éãªæ¡ä»¶ã«ãªã£ã¦ãã¾ãã ããããå ´åãåç´ã«pass()(ãã¹ããokã§ããã¨å®£è¨ããããã«)ããfail(not ok ã®ããã«) ãã使ãã¾ãããããã¯ãok(1)ã¨ãok(0)ã®åæèªã§ãã +=begin original + Use these very, very, very sparingly. +=end original + pass() 㨠fail() ã使ããã¨ã¯ã²ããã¼ã«æ éã«å¤æãã¦ãã ããã =cut =back - =head2 Module tests +=begin original + You usually want to test if the module you're testing loads ok, rather than just vomiting if its load fails. For such purposes we have C<use_ok> and C<require_ok>. +=end original + æ®éããã¹ããã¦ããã¢ã¸ã¥ã¼ã«ã®ãã¼ãã失æãããã©ãããåãã ããããã ãããã ok ããã¼ããããã©ããããã¹ãããããã¨ã§ãããã ãã®ãããªç®çã®ããã«ãC<use_ok>ã¨ãC<require_ok>ãããã¾ãã @@ -723,37 +967,57 @@ BEGIN { use_ok($module); } BEGIN { use_ok($module, @imports); } +=begin original + These simply use the given $module and test to make sure the load happened ok. It's recommended that you run use_ok() inside a BEGIN block so its functions are exported at compile-time and prototypes are properly honored. +=end original + ãããã¯ãåç´ã«ãä¸ãããã $module ã使ãã ãã¼ãã ok ãããã確ãããããã®ãã¹ããããã ãã§ãã BEGIN ãããã¯å ã§ãuse_ok() ãèµ°ããããã¨ãæ¨å¥¨ãã¾ãã ããã«ããããã®é¢æ°ã¯ãã³ã³ãã¤ã«æã«exportããããããã¿ã¤ããé©åã«åãåãã¾ãã +=begin original + If @imports are given, they are passed through to the use. So this: +=end original + @import ãä¸ãããå ´åãuse ã®éã«æ¸¡ããã¾ãã次ã®ããã« : BEGIN { use_ok('Some::Module', qw(foo bar)) } +=begin original + is like doing this: +=end original + 次ã®ããã«ããã®ã¨åãã§ãï¼ use Some::Module qw(foo bar); +=begin original + Version numbers can be checked like so: +=end original + ãã¼ã¸ã§ã³ã¯æ¬¡ã®ããã«ãã§ãã¯ã§ãã¾ã: # Just like "use Some::Module 1.02" BEGIN { use_ok('Some::Module', 1.02) } +=begin original + Don't try to do this: +=end original + 次ã®ããã«ãããã¨ãã¦ã¯ããã¾ããï¼ BEGIN { @@ -763,8 +1027,12 @@ ...happening at compile time... } +=begin original + because the notion of "compile-time" is relative. Instead, you want: +=end original + "compile-time"ã®è¨è¿°ãé¢ä¿ããããã§ãã代ããã«ã次ã®ããã«ãã¾ãããã BEGIN { use_ok('Some::Module') } @@ -777,8 +1045,12 @@ require_ok($module); require_ok($file); +=begin original + Like use_ok(), except it requires the $module or $file. +=end original + use_ok() ã«ä¼¼ã¦ãã¾ããããã㯠$module ã $file ãå¿ è¦ã¨ãã¾ãã @@ -789,16 +1061,24 @@ =head2 è¤éãªãã¼ã¿æ§é +=begin original + Not everything is a simple eq check or regex. There are times you need to see if two data structures are equivalent. For these instances Test::More provides a handful of useful functions. +=end original + å ¨ã¦ããåç´ãªeq ãã§ãã¯ããæ£è¦è¡¨ç¾ ã§ã¯ããã¾ããã ãã¨ãã°ãäºã¤ã®é åãã¤ã³ã¼ã«ã§ãããã©ãããè¦ãå¿ è¦ãããã¨ããããã¾ãã ãããã£ãä¾ã®ããã«ãTest::Moreã¯ãã¡ãã£ã¨ããæçãªé¢æ°ãæä¾ãã¦ãã¾ãã +=begin original + B<NOTE> I'm not quite sure what will happen with filehandles. +=end original + B<注æ>ãã¡ã¤ã«ãã³ãã«ã«ã¤ãã¦èµ·ãããã¨ã«ã¤ãã¦ããã¾ã確信ãããã¾ããã =over 4 @@ -807,34 +1087,50 @@ is_deeply( $got, $expected, $test_name ); +=begin original + Similar to is(), except that if $got and $expected are references, it does a deep comparison walking each data structure to see if they are equivalent. If the two structures are different, it will display the place where they start differing. +=end original + is()ã¨ä¼¼ã¦ãã¾ããã$got 㨠$expectedãããªãã¡ã¬ã³ã¹ã§ãã ããããã®ãã¼ã¿ã®æ§é ãè¦ã¦ã¾ãããããããããã¤ã³ã¼ã«ãã©ãããæ·±ãæ¯è¼ããã¾ãã äºã¤ã®æ§é ãéã£ã¦ããã°ãäºã¤ãéãå§ããå ´æã示ãã¾ãã +=begin original + is_deeply() compares the dereferenced values of references, the references themselves (except for their type) are ignored. This means aspects such as blessing and ties are not considered "different". +=end original + is_deeply() ã¯ããªãã¡ã¬ã³ã¹ã®å¤ã®éããæ¯è¼ãã¾ãã ãªãã¡ã¬ã³ã¹ããèªèº«(ãã®åãã®ãã)ã¯ç¡è¦ããã¾ãã ã¤ã¾ããblessã tie ã®ãããªå´é¢ã¯ã"éã"ã¨èãããã¾ããã +=begin original + is_deeply() currently has very limited handling of function reference and globs. It merely checks if they have the same referent. This may improve in the future. +=end original + is_deeply() ã¯ãä»ã®ã¨ãããé¢æ°ãªãã¡ã¬ã³ã¹ã¨globã®ãã³ããªã³ã°ã¯ é常ã«éå®çã§ããåç´ã«ãåã referent ãæã£ã¦ãããããã§ãã¯ãã¾ãã å°æ¥æ¹åãããããããã¾ããã +=begin original + L<Test::Differences> and L<Test::Deep> provide more in-depth functionality along these lines. +=end original + L<Test::Differences>ã¨L<Test::Deep>ã¯ããããå¾¹åºçãªæ©è½æ§ãæä¾ãã¦ãã¾ãã =cut @@ -844,11 +1140,15 @@ =head2 è¤æ°ã®è¨ºæ +=begin original + If you pick the right test function, you'll usually get a good idea of what went wrong when it failed. But sometimes it doesn't work out that way. So here we have ways for you to write your own diagnostic messages which are safer than just C<print STDERR>. +=end original + æ£ãããã¹ãé¢æ°ãé¸ãã ãªãããµã¤ãããã®ãã¹ãé¢æ°ã失æããå ´åã«ã ä½ãééã£ã¦ãããã«ã¤ãã¦ããæ å ±ãå¾ããã¨ãã§ããã§ããããã§ãããæã«ã ãããã風ã«ã¯ããã¾ãåããªããã¨ãããã¾ãã @@ -861,26 +1161,42 @@ diag(@diagnostic_message); +=begin original + Prints a diagnostic message which is guaranteed not to interfere with test output. Like C<print> @diagnostic_message is simply concatenated together. +=end original + ãã¹ãã®åºåã«å¹²æ¸ããªãã¨ä¿è¨¼ããã¦ãã診æã¡ãã»ã¼ã¸ãåºåãã¾ãã C<print> ã®ããã«ã@diagnostic_message ãåç´ã«ä¸ç·ã«ã¤ãªãã¾ãã +=begin original + Returns false, so as to preserve failure. +=end original + 失æã®ã¾ã¾ã«ããããã«ãå½ãè¿ãã¾ãã +=begin original + Handy for this sort of thing: +=end original + 次ã®ãããªå ´åã«ãæããã§ãï¼ ok( grep(/foo/, @users), "There's a foo user" ) or diag("Since there's no foo, check that /etc/bar is set up right"); +=begin original + which would produce: +=end original + 次ã®ããã«ãªãã¾ãï¼ not ok 42 - There's a foo user @@ -888,15 +1204,23 @@ # in foo.t at line 52. # Since there's no foo, check that /etc/bar is set up right. +=begin original + You might remember C<ok() or diag()> with the mnemonic C<open() or die()>. +=end original + C<ok() or diag()>ããC<open() or die()> ã®ããã«è¦ããã¨è¦ããããã§ãããã - + +=begin original + B<NOTE> The exact formatting of the diagnostic output is still changing, but it is guaranteed that whatever you throw at it it won't interfere with the test. +=end original + B<注æ> 診æã®åºåã®ããã®ãã©ã¼ãããã¯ãã¾ã ã¾ã æµåçã§ãã ããããããã«ä½ã渡ãã¦ããã¹ãã«å¹²æ¸ããªããã¨ã¯ä¿è¨¼ããã¦ãã¾ãã @@ -904,35 +1228,52 @@ note(@diagnostic_message); +=begin original + Like diag(), except the message will not be seen when the test is run in a harness. It will only be visible in the verbose TAP stream. +=end original + diag()ã¨ä¼¼ã¦ãã¾ããï¼harnessã§ãã¹ããåãã¦ããå ´åã«ã¯ã表示ããã¾ããã åé·ãªTAPã¹ããªã¼ã ã§ã®ã¿ãè¦ããã¾ãã + +=begin original + Handy for putting in notes which might be useful for debugging, but don't indicate a problem. +=end original + ãããã°ã«æç¨ãªã¡ã¢ãããã®ã«æããã§ããï¼åé¡ãææããã®ã« 使ã£ã¦ã¯ããã¾ããã note("Tempfile is $tempfile"); - =cut =item B<explain> my @dump = explain @diagnostic_message; + +=begin original + Will dump the contents of any references in a human readable format. Usually you want to pass this into C<note> or C<diag>. +=end original + 人ãèªã¿ããããã©ã¼ãããã§ããªãã¡ã¬ã³ã¹ã®å 容ããã³ããã¾ãã C<not> ã C<diag>ã«ä¸ãããã¨æãã§ãããã +=begin original + Handy for things like... +=end original + 次ã®ãããªå ´åã«ãæããã§ãï¼ is_deeply($have, $want) || diag explain $have; @@ -950,6 +1291,8 @@ =head2 æ¡ä»¶ãã¹ã +=begin original + Sometimes running a test under certain conditions will cause the test script to die. A certain function or method isn't implemented (such as fork() on MacOS), some resource isn't available (like a @@ -957,6 +1300,8 @@ necessary to skip tests, or declare that they are supposed to fail but will work in the future (a todo test). +=end original + ããæ¡ä»¶ä¸ã§ãã¹ããåãããã¨ã«ãã£ã¦ããã¹ãã¹ã¯ãªãããæ»ã¬æãããã¾ãã (MacOSã§ã®fork()ã®ãããª)ç¹å®ã®é¢æ°ãã¡ã½ããã¯å®è£ ããã¦ããªãã£ããã (ãããæ¥ç¶ã®ãããª)ããã¤ãã®ãªã½ã¼ã¹ãå©ç¨ã§ããªãã£ããã @@ -965,15 +1310,23 @@ ããã§ãªããã°ã失æãããã¨ãäºæ³ãããããã©ã å°æ¥çã«åã(a todo test)ã§ãããã¨ãããã¨ã宣è¨ããªããã°ãªãã¾ããã +=begin original + For more details on the mechanics of skip and todo tests see L<Test::Harness>. +=end original + skip 㨠todo ãã¹ãã®æ©æ§ã®è©³ç´°ã¯ãC<Test::Harness>ãè¦ã¦ä¸ããã +=begin original + The way Test::More handles this is with a named block. Basically, a block of tests which can be skipped over or made todo. It's best if I just show you... +=end original + ååã®ã¤ãããããã¯ã¨ä¸ç·ã«ããTest::More ãã³ãã«ã®ä½¿ãæ¹ã åºæ¬çã«ãã¹ãã®ãããã¯ã¯ãã¹ããããããããtodo ã«ãããã§ãã ãã ã³ã¼ããè¦ããã®ãæåã§ããã⦠@@ -988,10 +1341,14 @@ ...normal testing code goes here... } +=begin original + This declares a block of tests that might be skipped, $how_many tests there are, $why and under what $condition to skip them. An example is the easiest way to illustrate: +=end original + ããã¯ãã¹ããããããã¹ãã®ãããã¯ã宣è¨ãã¾ãã $how_many ã¯ãã¹ãã®æ°ã $why ã¯çç±ã$conditionã¯ã ã©ãããæ¡ä»¶ã§ããããã®ãã¹ããã¹ãããããã®ããæå³ãã¾ãã @@ -1010,32 +1367,48 @@ is( $lint->errors, 0, "No errors found in HTML" ); } +=begin original + If the user does not have HTML::Lint installed, the whole block of code I<won't be run at all>. Test::More will output special ok's which Test::Harness interprets as skipped, but passing, tests. +=end original + ã¦ã¼ã¶ããHTML::Lint ãã¤ã³ã¹ãã¼ã«ãã¦ããªããã°ãå ¨ã¦ã®ãããã¯ã³ã¼ãã¯ã I<ã¾ã£ããå®è¡ãããªãã§ããã>ã Test::Moreã¯ãç¹å¥ãª ok() ãåºåãã Test::Harnes ã¯ããã¹ããã¹ãããããããåæ ¼ããã¨è§£éãã¾ãã +=begin original + It's important that $how_many accurately reflects the number of tests in the SKIP block so the # of tests run will match up with your plan. If your plan is C<no_plan> $how_many is optional and will default to 1. +=end original + ãã¹ãã®æ°ããè¨ç»ã«ãããããããã«ã $how_many ãæ£ããSKIP ãããã¯ã®ä¸ã®ãã¹ãã®æ°ãåæ ãããã¨ã¯éè¦ã§ãã If your plan is C<no_plan> $how_many is optional and will default to 1. +=begin original + It's perfectly safe to nest SKIP blocks. Each SKIP block must have the label C<SKIP>, or Test::More can't work its magic. +=end original + ãã¹ãããSKIPãããã¯ã¯å®å ¨ã«å®å ¨ã§ããããããã®SKIPãããã¯ã«ã¯ã C<SKIP>ã©ãã«ããªããã°ãªãã¾ãããããããªãã¨ãTest::Moreã¯ããã®éæ³ããã¾ã使ãã¾ããã +=begin original + You don't skip tests which are failing because there's a bug in your program, or for which you don't yet have code written. For that you use TODO. Read on. +=end original + 失æãããã¹ããã¹ããããã¦ã¯ããã¾ããã失æããã®ã¯ãããã°ã©ã ã«ãã°ãããããã§ããã ããã§ãªããã°ãã¾ã ã³ã¼ããæ¸ãã¦ããªãããã§ãã TODO ã®ä½¿ãæ¹ãæ¸ãã®ã§ãèªã¿ç¶ãã¦ãã ããã @@ -1048,9 +1421,13 @@ ...ãµã¤ãã®ãã¹ãã³ã¼ããããã«ç¶ãã¦ãã ãã... } +=begin original + Declares a block of tests you expect to fail and $why. Perhaps it's because you haven't fixed a bug or haven't finished a new feature: +=end original + 失æããã¨äºæ¸¬ãã¦ãããã¹ãã¨ã$why ã®ãããã¯ã宣è¨ãã¾ãã ãã¶ãããã°ãã¾ã ç´ãã¦ããªãããæ°ããæ©è½ãä½ãçµãã¦ããªãã®ã§ãããã @@ -1065,6 +1442,8 @@ is( $spoon, 'bent', "Spoon bending, that's original" ); } +=begin original + With a todo block, the tests inside are expected to fail. Test::More will run the tests normally, but print out special flags indicating they are "todo". Test::Harness will interpret failures as being ok. @@ -1072,25 +1451,35 @@ You then know the thing you had todo is done and can remove the TODO flag. +=end original + todoãããã¯ã§ã¯ããã®ä¸ã®ãã¹ãã¯ã失æããã¨äºæããã¾ããTest::More ã¯ã æ®éã«ãã¹ããè¡ãã¾ãããç¹å¥ãªãã©ã°ãåºåããããã®ãã¹ãããtodoãã§ãããã¨ã示ãã¾ãã Test::Harness ã¯ããã®å¤±æã ok ã§ããã¨è§£éãã¾ãã ãªãã§ãæåã«ããäºæããªãæåã¨ãå ±åãã¾ãã todoã解æ¶ãããã¨åãã£ãããTODOãã©ã°ãå¤ããã¨ãåºæ¥ã¾ãã +=begin original + The nice part about todo tests, as opposed to simply commenting out a block of tests, is it's like having a programmatic todo list. You know how much work is left to be done, you're aware of what bugs there are, and you'll know immediately when they're fixed. +=end original + todo ãã¹ãã®è¯ãã¨ããã¯ããã¹ãã®ãããã¯ãåç´ã«ã³ã¡ã³ãã¢ã¦ããããã¨ã§ã¯ãªãã ããã°ã©ãçãªtodoãªã¹ãã§ããããã«ãªããã¨ã§ãã ã©ããããããã¹ãä»äºãæ®ã£ã¦ããã®ãåããããã©ã®ãããªãã°ãããã®ããæ°ä»ãã¾ãã ã¾ãããããã®ãã¹ããä¿®æ£ãããå ´åãå³åº§ã«èå¥ãããã¨ãåºæ¥ãã§ãããã +=begin original + Once a todo test starts succeeding, simply move it outside the block. When the block is empty, delete it. +=end original + ä¸åº¦ãtodoãã¹ããæåãå§ããã¨ãåç´ã«ããããã¯ã®å¤å´ã«todoãã¹ãã移ãã¾ãã ãããã¯ã空ãªããåé¤ãã¾ãã @@ -1102,12 +1491,16 @@ ...normal testing code... } +=begin original + With todo tests, it's best to have the tests actually run. That way you'll know when they start passing. Sometimes this isn't possible. Often a failing test will cause the whole program to die or hang, even inside an C<eval BLOCK> with and using C<alarm>. In these extreme cases you have no choice but to skip over the broken tests entirely. +=end original + todo ãã¹ãã§ã¯ãå®éã«ãã¹ãããªãã¹ãèµ°ããããã¨ãã¾ãã ãã®ããã«ããããã®ãã¹ãããã¤ééãå§ããããç¥ãã§ãããã ãããããã¨ããå¯è½ã§ãªãæãããã¾ãã @@ -1115,30 +1508,42 @@ C<eval BLOCK>ã®å å´ã§ãC<alarm>ã使ã£ã¦ãã ãã®ãããªæ¥µç«¯ãªã±ã¼ã¹ã§ã¯ãå£ãããã¹ããå®å ¨ã«ã¹ããããã以å¤ã«ã¯ãé¸æã®ä½å°ã¯ããã¾ããã +=begin original + The syntax and behavior is similar to a C<SKIP: BLOCK> except the tests will be marked as failing but todo. Test::Harness will interpret them as passing. +=end original + todoã§ã¯ãªããã¹ãã失æã¨ãã¦ãã¼ã¯ããã以å¤ã¯ã æ§æãæ¯ãèããC<SKIP: BLOCK>ã«ä¼¼ã¦ãã¾ãã Test::Harness ã¯ããã¹ãã«åæ ¼ãã¦ããã¨è§£éãã¾ãã =item SKIP 対 TODO ãã©ã®ããã«ä½¿ãåããã®ã§ãããï¼ +=begin original + B<If it's something the user might not be able to do>, use SKIP. This includes optional modules that aren't installed, running under an OS that doesn't have some feature (like fork() or symlinks), or maybe you need an Internet connection and one isn't available. +=end original + B<ãããã¦ã¼ã¶ãåºæ¥ããã«ãªãã¨ãã«ã¯>ãSKIPã使ã£ã¦ãã ããã ããã«ã¯ãã¤ã³ã¹ãã¼ã«ããã¦ããªããªãã·ã§ãã«ãªã¢ã¸ã¥ã¼ã«ãã (fork()ãsymlinksãªã©ã®)æ©è½ãæã£ã¦ããªãOSã§å®è¡ãããã¨ãã ã¤ã³ã¿ã¼ãããæ¥ç¶ãå¿ è¦ã¨ãã¦ããã®ã«ããããã¦ã¼ã¶ãå©ç¨ã§ããªããã¨ãå«ã¿ã¾ãã +=begin original + B<If it's something the programmer hasn't done yet>, use TODO. This is for any code you haven't written yet, or bugs you have yet to fix, but want to put tests in your testing script (always a good idea). +=end original + B<ãããããã°ã©ããã¾ã ããã£ã¦ããªãã¨ãã«ã¯>ãTODO ã使ã£ã¦ãã ããã ããã¯ããã¹ãscriptã«ããã¹ããç½®ããã(常ã«ããèãã§ã)ããã©ãã ã¾ã æ¸ãã¦ããªãã³ã¼ãããã¾ã ç´ãã¦ããªããã°ãªã©ã§ãã @@ -1154,22 +1559,34 @@ BAIL_OUT($reason); +=begin original + Indicates to the harness that things are going so badly all testing should terminate. This includes the running of any additional test scripts. +=end original + æ²æ¨ãªãªãã¨ã«ãªã£ãããããã¹ã¦ã®ãã¹ããçµäºãããããã«ãharnessã«ä¼ãã¾ãã ããã¯ãã©ããªè¿½å ã®ãã¹ãã¹ã¯ãªããã®å®è¡ãå«ã¿ã¾ãã +=begin original + This is typically used when testing cannot continue such as a critical module failing to compile or a necessary external utility not being available such as a database connection failing. +=end original + ãã¼ã¿ãã¼ã¹æ¥ç¶ã®ãããªãéè¦ãªã¢ã¸ã¥ã¼ã«ã®ã³ã³ãã¤ã«ã¨ã©ã¼ã å¿ é ã®å¤é¨ã¦ã¼ãã£ãªãã£ãå©ç¨ã§ããªããããªããã«ã ãã¹ããç¶ããããªãå ´åã«ãå ¸åçã«ä½¿ããã¾ãã +=begin original + The test will exit with 255. +=end original + ãã¹ãã¯255ã§çµäºãã¾ãã For even better control look at L<Test::Most>. @@ -1184,19 +1601,27 @@ =head2 æ¨å¥¨ãããªãæ¯è¼é¢æ° +=begin original + The use of the following functions is discouraged as they are not actually testing functions and produce no diagnostics to help figure out what went wrong. They were written before is_deeply() existed because I couldn't figure out how to display a useful diff of two arbitrary data structures. +=end original + ä¸è¨ã®é¢æ°ã®ä½¿ç¨ã¯æ¨å¥¨ããã¾ããããããã¯ãå®éã«ã¯ãã¹ãé¢æ°ã§ã¯ãªãã ä½ãééã£ã¦ããããçªãæ¢ããå©ãã¨ãªã診æã¯æä¾ãã¾ããã is_deeply() ãã§ããããåã«æ¸ãããé¢æ°ã§ã2ã¤ã®ä»»æã®ãã¼ã¿æ§é ã® éãã表示ããæå¹ãªæ¹æ³ãèãä»ããã¨ãåºæ¥ãªãã£ãããã§ãã +=begin original + These functions are usually used inside an ok(). +=end original + ãããã¯ãok() ã®ä¸ã§ä½¿ãããã®ãæ®éã§ãã ok( eq_array(\@got, \@expected) ); @@ -1207,8 +1632,12 @@ is_deeply( \@got, \@expected ); +=begin original + They may be deprecated in future versions. +=end original + å°æ¥ã®ãã¼ã¸ã§ã³ã§ãªããªãããããã¾ããã =over 4 @@ -1217,9 +1646,13 @@ my $is_eq = eq_array(\@got, \@expected); +=begin original + Checks if two arrays are equivalent. This is a deep check, so multi-level structures are handled correctly. +=end original + äºã¤ã®é åãã¤ã³ã¼ã«ãã©ããããã§ãã¯ãã¾ããããã¯ãæ·±ããã§ãã¯ã§ããã ãã«ãã¬ãã«ã®æ§é ãæ£ç¢ºã«æ±ããã¾ãã @@ -1227,9 +1660,13 @@ my $is_eq = eq_hash(\%got, \%expected); +=begin original + Determines if the two hashes contain the same keys and values. This is a deep check. +=end original + äºã¤ã®ããã·ã¥ãåããã¼ã¨å¤ãå«ãã§ãããã©ããã調ã¹ã¾ãã ããã¯æ·±ããã§ãã¯ã§ãã @@ -1237,37 +1674,57 @@ my $is_eq = eq_set(\@got, \@expected); +=begin original + Similar to eq_array(), except the order of the elements is B<not> important. This is a deep check, but the irrelevancy of order only applies to the top level. +=end original + eq_array() ã¨ã«ã¦ãã¾ãããè¦ç´ ã®é çªã¯éè¦ã§ã¯ããã¾ããã ããã¯ãæ·±ããã§ãã¯ã§ãããé çªã®ä¸æ´åã¯ããããã¬ãã«ã«ããé©ç¨ããã¾ããã ok( eq_set(\@got, \@expected) ); +=begin original + Is better written: +=end original + ããè¯ãæ¸ãæ¹: is_deeply( [sort @got], [sort @expected] ); +=begin original + B<NOTE> By historical accident, this is not a true set comparison. While the order of elements does not matter, duplicate elements do. +=end original + B<注æ>ãæ´å²çãªé½åã«ãããããã¯ãæ¬å½ã® set ã®æ¯è¼ã§ã¯ããã¾ããã è¦ç´ ã®é çªãåé¡ã§ã¯ãªãä¸ã«ãéè¤ããè¦ç´ ãåé¡ã«ãã¾ããã +=begin original + B<NOTE> eq_set() does not know how to deal with references at the top level. The following is an example of a comparison which might not work: +=end original + B<注æ>ãeq_set() ã¯ããããã¬ãã«ã§ãªãã¡ã¬ã³ã¹ãã©ãæ±ãããç¥ãã¾ããã 以ä¸ã®ãã®ã¯ãåããªãæ¯è¼ã®ä¾ã§ãã eq_set([\1, \2], [\2, \1]); +=begin original + L<Test::Deep> contains much better set comparison functions. +=end original + L<Test::Deep> ã«ã¯ãããããæ¯è¼é¢æ°ã®ã»ãããããã¾ãã =cut @@ -1277,21 +1734,29 @@ =head2 Test::Moreã®æ¡å¼µã¨å å« +=begin original + Sometimes the Test::More interface isn't quite enough. Fortunately, Test::More is built on top of Test::Builder which provides a single, unified backend for any test library to use. This means two test libraries which both use Test::Builder B<can be used together in the same program>. +=end original + Test::More ã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ããã¾ã£ããååã§ãªãæãããã¾ãã 幸éãªãã¨ã«ãTest::More ã¯ãTest::Builderã®ä¸ã«ä½ããã¦ãã¾ãã Test::Builder ã¯ããããããã¹ãã©ã¤ãã©ãªã¼ã®ããã®ãä¸ã¤ã®ãçµ±åããããããã¯ã¨ã³ããæä¾ãã¦ãã¾ãã ãã®ãã¨ã¯ã両æ¹ã¨ããTest::Builderã使ã£ã¦ãããäºã¤ã®ãã¹ãã©ã¤ãã©ãªã¼ãªãã°ã B<åãããã°ã©ã ã§ãã£ããã«ä½¿ãããã¨>ãæå³ãã¾ã +=begin original + If you simply want to do a little tweaking of how the tests behave, you can access the underlying Test::Builder object like so: +=end original + ããåç´ã«ããã¹ãã®æåã®ä»æ¹ã微調æ´ããããã°ã次ã®ããã«ã ãã¼ã¹ã¨ãããTest::Builderãªãã¸ã§ã¯ãã«ã¢ã¯ã»ã¹ã§ãã¾ã: @@ -1301,9 +1766,13 @@ my $test_builder = Test::More->builder; +=begin original + Returns the Test::Builder object underlying Test::More for you to play with. +=end original + Test::Moreã§éã¶ããã®ãTest::Moreã®åºç¤ããªãTest::Builder ãªãã¸ã§ã¯ãã è¿ãã¾ãã @@ -1313,6 +1782,8 @@ =head1 çµäºã³ã¼ã +=begin original + If all your tests passed, Test::Builder will exit with zero (which is normal). If anything failed it will exit with how many failed. If you run less (or more) tests than you planned, the missing (or extras) @@ -1321,6 +1792,8 @@ having successfully completed all its tests, it will still be considered a failure and will exit with 255. +=end original + ãã¹ã¦ã®ãã¹ãããã¹ããããTest::Builder㯠0 ã§çµäºãã¾ã(é常ã§ã)ã ä½ãééã£ã¦ãããï¼ééã£ãæ°ã§çµäºãã¾ããè¨ç»ãã¦ãããããã å°ãªã(ããå¤ã)ããè¦å¤±ã£ãããä½è¨ãªãã¹ããèµ°ãããã¨ã失æããã¨ã¿ãªããã¾ãã @@ -1328,20 +1801,32 @@ ãã¹ããæ»ãã ãããã¨ããã¹ã¦ã®ãã¹ããæåãã¦ãã 失æã¨ã¿ãªãã255ã§çµäºãã¾ãã +=begin original + So the exit codes are... +=end original + çµäºã³ã¼ãã¯... 0 ãã¹ã¦ã®ãã¹ããæå 255 ãã¹ãã¯æ»ãã ãããã¹ã¦æåããããééã£ã¦ãã # of tests run any other number ééã£ãæ°(失æããä½è¨ãªãã®ãå«ã) +=begin original + If you fail more than 254 tests, it will be reported as 254. +=end original + 254以ä¸ã®ãã¹ãã«å¤±æãããã254ãå ±åãã¾ãã +=begin original + B<NOTE> This behavior may go away in future versions. +=end original + B<注æ>ããã®æ¯ãèãã¯ãå°æ¥ã®ãã¼ã¸ã§ã³ã§ãªããªãããããã¾ããã =head1 è¦åã¨æ³¨æ @@ -1350,13 +1835,19 @@ =item å¾æ¹äºææ§ +=begin original + Test::More works with Perls as old as 5.6.0. +=end original + Test::More ã¯Perl 5.6.0ã§åãã¾ãã =item utf8 / "Wide character in print" +=begin original + If you use utf8 or other non-ASCII characters with Test::More you might get a "Wide character in print" warning. Using C<binmode STDOUT, ":utf8"> will not fix it. Test::Builder (which powers @@ -1364,6 +1855,8 @@ including changing their output disciplines, will not be seem by Test::More. +=end original + utf8 ã non-ASCIIãªæåãTest::Moreã¨ä¸ç·ã«ä½¿ãå ´åã "Wide character in print"ã®è¦åãåºãããããã¾ããã C<binmode STDOUT, ":utf8">ã使ã£ã¦ããç´ãã¾ãããTest::Builder ( @@ -1371,9 +1864,13 @@ ãã®ããããããã¸ã®ã©ããªå¤æ´ãããããã®åºåã®ä»æ¹ã®å¤æ´ãå«ã¿ã Test::Moreã«ã¯ãããã¾ããã +=begin original + The work around is to change the filehandles used by Test::Builder directly. +=end original + Test::Builderãç´æ¥ä½¿ã£ã¦ãã¡ã¤ã«ãã³ãã«ãå¤æ´ãã¦ã対å¦ãã¦ãã ããã my $builder = Test::More->builder; @@ -1384,6 +1881,8 @@ =item ãªã¼ãã¼ãã¼ãããããªãã¸ã§ã¯ã +=begin original + String overloaded objects are compared B<as strings> (or in cmp_ok()'s case, strings or numbers as appropriate to the comparison op). This prevents Test::More from piercing an object's interface allowing @@ -1391,17 +1890,23 @@ objects instead of bare strings your tests won't notice the difference. This is good. +=end original + ãªã¼ãã¼ãã¼ãããããªãã¸ã§ã¯ãã¯B<æååã¨ãã¦>(ã¾ãã¯ã cmp_ok()ã§ã¯ã æ¯è¼ãããªãã¬ã¼ã¿ã¼ã«ãããã£ã¦ãæååãæ°åã¨ãã¦)æ¯è¼ããã¾ããããã¯ã Test::Moreããããè¯ããã©ãã¯ããã¯ã¹ãã¹ãã許ãã¦ãããªãã¸ã§ã¯ãã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã çªãåºãã®ã妨ãã¾ãããã®ãããé¢æ°ã裸ã®æååã®ä»£ããã«ããªã¼ãã¼ãã¼ãããã ãªãã¸ã§ã¯ããè¿ãããã«ãªãã°ãããªãã®ãã¹ãã¯éãã«æ°ä»ããªãã§ããããããã¯è¯ããã¨ã§ãã +=begin original + However, it does mean that functions like is_deeply() cannot be used to test the internals of string overloaded objects. In this case I would suggest L<Test::Deep> which contains more flexible testing functions for complex data structures. +=end original + ã§ãããis_deeply()ã®ãããªé¢æ°ãããªãã¸ã§ã¯ãããªã¼ãã¼ãã¼ããããæååã®å é¨ã® ãã¹ãã«ä½¿ããã¨ãåºæ¥ãªãã¨ããããã§ã¯ããã¾ããããã®ã¨ã¼ã¹ã§ã¯ã L<Test::Deep>ãææ¡ãã¾ããè¤éãªãã¼ã¿æ§é ã®ããã«ãããæè»ãªãã¹ãé¢æ°ãããã¾ãã @@ -1409,9 +1914,13 @@ =item Threads +=begin original + Test::More will only be aware of threads if "use threads" has been done I<before> Test::More is loaded. This is ok: +=end original + Test::Moreã¯ãTest::Moreããã¼ããããåã«ã"use threads"ãããã¦ããå ´åã ã¹ã¬ãããæèãã¾ãã次㯠ok ã§ã: @@ -1419,15 +1928,23 @@ use threads; use Test::More; +=begin original + This may cause problems: +=end original + 次ã®ãã®ã¯åé¡ã«ãªãã¾ã: use Test::More use threads; +=begin original + 5.8.1 and above are supported. Anything below that has too many bugs. +=end original + 5.8.1 以ä¸ãæ³å®ãã¦ãã¾ããããæªæºã®ãã¼ã¸ã§ã³ã¯ãå¤ãã®ãã°ãããã¾ãã =back @@ -1435,23 +1952,31 @@ =head1 çµç·¯ +=begin original + This is a case of convergent evolution with Joshua Pritikin's Test module. I was largely unaware of its existence when I'd first written my own ok() routines. This module exists because I can't figure out how to easily wedge test names into Test's interface (along with a few other problems). +=end original + ããã¯ãJoshua Pritikin ã®ãã¹ãã¢ã¸ã¥ã¼ã«ãã¾ã¨ãã¦é²åããããã®ã§ãã èªåã®ok()ã«ã¼ãã³ãæåã«æ¸ããã¨ããPritikinã®ãã¹ãã¢ã¸ã¥ã¼ã«ã®åå¨ã«ã¾ã£ããæ°ã¥ãã¦ãã¾ããã§ããã ãã®ã¢ã¸ã¥ã¼ã«ãå¨ãã®ã¯ãç°¡åã«ãã¹ãã®ååããã¹ãã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ã«ãæ¼ãè¾¼ãæ¹æ³ãè¦ã¤ãåºããªãã£ãããã§ã (ä»ã®ããã¤ãã®åé¡ã¨ã¨ãã«)ã +=begin original + The goal here is to have a testing utility that's simple to learn, quick to use and difficult to trip yourself up with while still providing more flexibility than the existing Test.pm. As such, the names of the most common routines are kept tiny, special cases and magic side-effects are kept to a minimum. WYSIWYG. +=end original + ããã§ã®ã´ã¼ã«ã¯ãåå¨ããTest.pmãããæè»æ§ãæä¾ãã¤ã¤ å¦ã³ããããããã«ä½¿ãã¦ãã¤ã¾ããã«ãããã¹ãã®ã¦ã¼ãã£ãªãã£ã§ãã ãããªããã§ãã»ã¨ãã©ã®å ±éã®ã«ã¼ãã³ã®ååã¯å°ããã¾ã¾ã«ãã¦ã @@ -1461,33 +1986,49 @@ =head1 SEE ALSO +=begin original + L<Test::Simple> if all this confuses you and you just want to write some tests. You can upgrade to Test::More later (it's forward compatible). +=end original + L<Test::Simple> ãããTest::Moreãã¾ã£ããæ··ä¹±ãããã ãã®ãã®ã§ããã ãã ããã¹ããæ¸ãããã ããªããå¾ã§ãTest::Moreã«ã¢ããã°ã¬ã¼ãã§ãã¾ã (Test::More ã¯ãä¸ä½äºææ§ãããã¾ã)ã +=begin original + L<Test::Harness> is the test runner and output interpreter for Perl. It's the thing that powers C<make test> and where the C<prove> utility comes from. +=end original + L<Test::Harness>ã¯ããã¹ããå®è¡æ©ã§ãããPerlã®åºåã¤ã³ã¿ããªã¿ã§ãã C<make test>ã«åãä¸ãã¦ãããã®ã§ãããC<prove>ã¦ã¼ãã£ãªãã£ã ç±æ¥ããã¨ããã§ãã +=begin original + L<Test::Legacy> tests written with Test.pm, the original testing module, do not play well with other testing libraries. Test::Legacy emulates the Test.pm interface and does play well with others. +=end original + C<Test::Legacy>ã¯ãTest.pmã¨ä¸ç·ã«æ¸ãããããªãªã¸ãã«ã®ãã¹ãã¢ã¸ã¥ã¼ã«ã§ãã ä»ã®ãã¹ãã©ã¤ãã©ãªã¨ä¸ç·ã«ã¾ãã¾ãåãã¾ãããTest::Legacyã¯ã Test.pmã®ã¤ã³ã¿ã¼ãã§ã¼ã¹ãã¨ãã¥ã¬ã¼ãããä»ã®ãã®ã¨ãã¾ãåãã¾ãã +=begin original + L<Test::Differences> for more ways to test complex data structures. And it plays well with Test::More. +=end original + L<Test::Differences> è¤éãªãã¼ã¿æ§é ããã¹ãããããã®ããå¤ãã®æ¹æ³ã®ããã«ã Test::Moreã¨ä¸ç·ã«ããã¯ãããã¾ãã