You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This perl program use strict and wanrings (you already know they are friends, do you?) then load the core module <ahref="https://perldoc.perl.org/Test/More.html">Test::More</a> which generally
596
+
This perl program use strict and warnings (you already know they are friends, do you?) then load the core module <ahref="https://perldoc.perl.org/Test/More.html">Test::More</a> which generally
597
597
requires that you declare how many tests you intend to run ( <code>plan tests => 1</code> ) then inside the <code>BEGIN</code> block use its method <code>use_ok</code> that loads our own module and in case of failure print "Bail out!\n" aka "everything went wrong, leave the boat".
598
598
599
599
If the above succeeded <ahref="https://perldoc.perl.org/Test/More.html">Test::More</a> calls <code>diag</code> that emits a note with the text specified, useful to have while reviewing test output. The module also has the <code>note</code> method that I prefer. Go to the module documentation to have an idea of <ahref="https://perldoc.perl.org/Test/More.html">Test::More</a>
@@ -768,9 +768,9 @@ sub validate{
768
768
}
769
769
770
770
</pre>
771
-
The above is straightforward (if ugly): we get something in via <code>@_</code> (a string or a list) and we return something via <code>return @range</code> To accomplish this we initialize <code>$range</code> to hold our string.
771
+
The above is straightforward (if ugly): we get something in via <code>@_</code> (a string or a list) and we return something via <code>return @range</code> To accomplish this we initialize <code>$range</code> to hold our string.
772
772
773
-
A good principle in loops is "put exit conditions early" and following this principle we put our our die conditions as soon as possible, ie after the if/else check.
773
+
A good principle in loops is "put exit conditions early" and following this principle we put our die conditions as soon as possible, ie after the if/else check.
774
774
775
775
But we dont want to die with an ugly message like <code>Died at ../Range/Validator.pm line x</code> ie from the module perspective: we want to inform the user where his code provoked our module to die.
776
776
@@ -1823,7 +1823,7 @@ B - Yeah man, for a coffee, as always.
1823
1823
1824
1824
So we add a line in the top of the module, just after VERSION: <code>our $WARNINGS = 0;</code> to let dev B to trigger our warnings. We commit even this small change.
1825
1825
1826
-
Then we add to the sub a <code>carp</code> call triggered if <code>our $WARNINGS == 1;</code> and if <code>@_ == 0</code> and we add this as <code>elsif</code> condition:
1826
+
Then we add to the sub a <code>carp</code> call triggered if <code>$WARNINGS == 1</code> and if <code>@_ == 0</code> and we add this as <code>elsif</code> condition:
1827
1827
1828
1828
<pre>
1829
1829
# assume we have a string if we receive only one argument
@@ -2047,7 +2047,7 @@ Push recent changes into the online repository.
2047
2047
<aid="daysevenstep4"></a>
2048
2048
<h4>step 4) another kind of test: POD and POD coverage</h4>
2049
2049
2050
-
In our <code>/t</code> folder we still have two tests we did not run: shame! <code>module-starter</code> created for us <code>pod.t</code> and <code>pod-coverage.t</code> The first one checks every POD in our distribution has no errors and the second ensures that all relevant files in your distribution are appropriately documented in POD documentation. Thanks for this. Run them:
2050
+
In our <code>/t</code> folder we still have two tests we did not run: shame! <code>module-starter</code> created for us <code>pod.t</code> and <code>pod-coverage.t</code> The first one checks every POD in our distribution has no errors and the second ensures that all relevant files in your distribution are appropriately documented in POD documentation. Thanks for this. Run them (after installing the necessary modules <code>Test::Pod</code> and <code>Test::Pod::Coverage</code>):
2051
2051
2052
2052
<pre>
2053
2053
shell> prove -l -v ./t/pod.t
@@ -2140,7 +2140,7 @@ Just an example: install <a href="https://metacpan.org/pod/Module::CPANTS::Analy
2140
2140
<aid="dayeightoptionone"></a>
2141
2141
<h4>option one - the bare bone module</h4>
2142
2142
2143
-
This is option we choosed for the above example and, even if it is the less favorable one, we used this form for the extreme easy. The module is just a container of subs and all subs are available in the program tha uses our module but only using their fully qualified name, ie including the name space where they are defined: <code>Range::Validator::validate</code> was the syntax we used all over the tutorial.
2143
+
This is option we choosed for the above example and, even if it is the less favorable one, we used this form for the extreme easy. The module is just a container of subs and all subs are available in the program that uses our module but only using their fully qualified name, ie including the name space where they are defined: <code>Range::Validator::validate</code> was the syntax we used all over the tutorial.
2144
2144
2145
2145
Nothing bad if the above behaviour is all you need.
0 commit comments