From 887cc83c9b7b1305cc02f7097e8c88abf218b7a5 Mon Sep 17 00:00:00 2001 From: Scott Kullberg Date: Mon, 24 Oct 2016 12:35:52 -0400 Subject: [PATCH] Starting point for perl with tests and empty module --- starting_points/perl/README.txt | 12 ++++++++++++ starting_points/perl/lib/Life.pm | 19 +++++++++++++++++++ starting_points/perl/life.pl | 12 ++++++++++++ starting_points/perl/t/01_life.t | 20 ++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 starting_points/perl/README.txt create mode 100644 starting_points/perl/lib/Life.pm create mode 100644 starting_points/perl/life.pl create mode 100644 starting_points/perl/t/01_life.t diff --git a/starting_points/perl/README.txt b/starting_points/perl/README.txt new file mode 100644 index 0000000..e8b04e8 --- /dev/null +++ b/starting_points/perl/README.txt @@ -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. + diff --git a/starting_points/perl/lib/Life.pm b/starting_points/perl/lib/Life.pm new file mode 100644 index 0000000..ec74898 --- /dev/null +++ b/starting_points/perl/lib/Life.pm @@ -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; diff --git a/starting_points/perl/life.pl b/starting_points/perl/life.pl new file mode 100644 index 0000000..e90235d --- /dev/null +++ b/starting_points/perl/life.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl + +use lib 'lib'; +use warnings; +use strict; + +use Life; + + + + + diff --git a/starting_points/perl/t/01_life.t b/starting_points/perl/t/01_life.t new file mode 100644 index 0000000..b707564 --- /dev/null +++ b/starting_points/perl/t/01_life.t @@ -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 );