Skip to content

Commit

Permalink
Starting point for perl with tests and empty module
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Kullberg committed Jul 31, 2017
1 parent 5ef7d76 commit 887cc83
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
12 changes: 12 additions & 0 deletions starting_points/perl/README.txt
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.

19 changes: 19 additions & 0 deletions starting_points/perl/lib/Life.pm
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;
12 changes: 12 additions & 0 deletions starting_points/perl/life.pl
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;





20 changes: 20 additions & 0 deletions starting_points/perl/t/01_life.t
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 );

0 comments on commit 887cc83

Please sign in to comment.