Skip to content

Commit

Permalink
add texttest fixture for Perl 5 code
Browse files Browse the repository at this point in the history
  • Loading branch information
voegelas committed May 2, 2014
1 parent 0a77251 commit 9d1856b
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
4 changes: 2 additions & 2 deletions perl/Item.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ sub new {
return bless \%attrs, $class;
}

sub _data_printer { ## no critic (ProhibitUnusedPrivateSubroutines)
my ( $self, $properties ) = @_;
sub to_string {
my ($self) = @_;
return $self->{name} . ', ' . $self->{sell_in} . ', ' . $self->{quality};
}

Expand Down
72 changes: 72 additions & 0 deletions perl/texttest_fixture.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env perl

use strict;
use warnings;

use GildedRose;
use Item;

print 'OMGHAI!', "\n";
my $items = [
Item->new(
name => '+5 Dexterity Vest',
sell_in => 10,
quality => 20
),
Item->new(
name => 'Aged Brie',
sell_in => 2,
quality => 0
),
Item->new(
name => 'Elixir of the Mongoose',
sell_in => 5,
quality => 7
),
Item->new(
name => 'Sulfuras, Hand of Ragnaros',
sell_in => 0,
quality => 80
),
Item->new(
name => 'Sulfuras, Hand of Ragnaros',
sell_in => -1,
quality => 80
),
Item->new(
name => 'Backstage passes to a TAFKAL80ETC concert',
sell_in => 15,
quality => 20
),
Item->new(
name => 'Backstage passes to a TAFKAL80ETC concert',
sell_in => 10,
quality => 49
),
Item->new(
name => 'Backstage passes to a TAFKAL80ETC concert',
sell_in => 5,
quality => 49
),
Item->new( # This Conjured item does not work properly yet
name => 'Conjured Mana Cake',
sell_in => 3,
quality => 6
),
];

my $days = 2;
if ( $#ARGV >= 0 ) {
$days = $ARGV[0];
}

my $gilded_rose = GildedRose->new( items => $items );
for my $day ( 0 .. $days ) {
print "-------- day $day --------", "\n";
print 'name, sellIn, quality', "\n";
for my $item ( @{$items} ) {
print $item->to_string(), "\n";
}
print "\n";
$gilded_rose->update_quality();
}
4 changes: 4 additions & 0 deletions texttests/config.gr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ interpreter:java
# Settings for the C# version
#executable:${TEXTTEST_CHECKOUT}/GildedRose.exe

# Settings for the Perl version
#executable:${TEXTTEST_CHECKOUT}/perl/texttest_fixture.pl
#interpreter:perl

# turn on one of these if you prefer them to notepad or emacs.
[view_program]
*:mate
Expand Down
1 change: 1 addition & 0 deletions texttests/environment.gr
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# If your .class files are somewhere else, add the path to the list
CLASSPATH:${TEXTTEST_CHECKOUT}/Java:${TEXTTEST_CHECKOUT}/Java/bin
PERL5OPT:-I${TEXTTEST_CHECKOUT}/perl

0 comments on commit 9d1856b

Please sign in to comment.