diff options
| author | Teddy Wing | 2021-08-08 18:39:00 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2021-08-08 18:40:04 +0200 | 
| commit | 965aafb4d9ff0eba748704b32ab140e9a019dde1 (patch) | |
| tree | e54fb12d8a801021f4fa02343032ecbf8f579ddd | |
| parent | db918a0716aaf559c3f64688c2c3ca9388172b7f (diff) | |
| download | readline-incdec-965aafb4d9ff0eba748704b32ab140e9a019dde1.tar.bz2 | |
Add a Perl module for performing the action
This allows us to more easily test the functionality and add new
behaviours.
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | incdec.pm | 14 | ||||
| -rw-r--r-- | t/100-increment-decrement.t | 16 | 
3 files changed, 33 insertions, 0 deletions
| diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..667ff7e --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +.PHONY: test +test: +	prove -v diff --git a/incdec.pm b/incdec.pm new file mode 100644 index 0000000..96b28c8 --- /dev/null +++ b/incdec.pm @@ -0,0 +1,14 @@ +use strict; +use warnings; + +package incdec; + +sub incdec { +	my ($line) = @_; + +	$line =~ s/(\d+)/$1+1/e; + +	return $line; +} + +1; diff --git a/t/100-increment-decrement.t b/t/100-increment-decrement.t new file mode 100644 index 0000000..d3b1e13 --- /dev/null +++ b/t/100-increment-decrement.t @@ -0,0 +1,16 @@ +#!/usr/bin/env perl -w + +use strict; + +use Test::More; + +use lib './'; +use incdec; + +is( +	incdec::incdec('test 12'), +	'test 13', +	'increments an integer' +); + +done_testing; | 
