-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Starting point for perl with tests and empty module
- Loading branch information
Scott Kullberg
committed
Jul 31, 2017
1 parent
5ef7d76
commit 887cc83
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Simple Perl setup using modules and tests | ||
|
||
To run the program: perl life.pl | ||
|
||
To run tests: prove -l | ||
|
||
Sample tests are included to demonstrate failing and passing. | ||
|
||
See perldoc for Test::Simple and Test::Tutorial for details on | ||
testing. If you find yourself needing more complex tests, have a look | ||
at the Test::More module, a drop-in replacement for Test::Simple. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Life; | ||
|
||
use strict; | ||
use warnings; | ||
use 5.010; | ||
|
||
# Optional: list functions to export | ||
use base 'Exporter'; | ||
our @EXPORT_OK = qw(get_true get_false); | ||
|
||
sub get_true { | ||
return 1; | ||
} | ||
|
||
sub get_false { | ||
return 0; | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/perl | ||
|
||
use lib 'lib'; | ||
use warnings; | ||
use strict; | ||
|
||
use Life; | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use strict; | ||
use warnings; | ||
use 5.010; | ||
|
||
## Instruct the test harness how many tests you expect so it can | ||
## number them. This doesn't *have* to be correct, but you'll get a | ||
## warning if it does not match. | ||
use Test::Simple tests => 2; | ||
|
||
## This is the module we're testing | ||
use Life qw(get_true get_false); | ||
|
||
my $true = get_true; | ||
my $false = get_false; | ||
|
||
## Two simple tests to show tests passing and failing. 'ok' passes if | ||
## the argument is true, and fails if it is false. | ||
|
||
ok( $true == $true ); | ||
ok( $true == $false ); |