From 1776bd778db4f6ed72eed47602877ab7a8fb904f Mon Sep 17 00:00:00 2001 From: dakkar Date: Mon, 29 Aug 2011 13:54:58 +0100 Subject: reflectors, in box, and some refactor --- t/rotors.t | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 't/rotors.t') diff --git a/t/rotors.t b/t/rotors.t index fb53fe4..90ce6ce 100644 --- a/t/rotors.t +++ b/t/rotors.t @@ -1,35 +1,22 @@ #!perl use DAKKAR::p 'test'; use List::Util 'shuffle'; +use Test::Enigmatic; use Enigmatic::Rotor; use Enigmatic::RotorBox; -sub test_the_rotor { - my ($r,$out,$name) = @_; - - my @in = 'A'..'Z'; - my %map;@map{@in}=@$out; - - for my $c ('A' .. 'Z') { - is($r->map($c), - $map{$c}, - "$name on $c"); - } -} - subtest 'identity rotor' => sub { my @in = 'A'..'Z'; my $r = Enigmatic::Rotor->new(@in->join); - test_the_rotor($r,\@in,'identity'); + Test::Enigmatic::test_static_map($r,\@in,'identity'); }; - subtest 'scramble rotor' => sub { my @out = shuffle 'A'..'Z'; my $r = Enigmatic::Rotor->new(@out->join); - test_the_rotor($r,\@out,'shuffle'); + Test::Enigmatic::test_static_map($r,\@out,'shuffle'); }; subtest 'identity rotor, non-default ring setting' => sub { @@ -39,7 +26,7 @@ subtest 'identity rotor, non-default ring setting' => sub { wiring => ['A'..'Z']->join, ring_setting => 1, ); - test_the_rotor($r,\@out,'ring=1'); + Test::Enigmatic::test_static_map($r,\@out,'ring=1'); }; subtest 'constraints' => sub { @@ -77,8 +64,9 @@ subtest 'rotor box' => sub { my ($rotor,$wiring) = @_; my $r = $box->get($rotor); my $out = $wiring->split(qr//); - test_the_rotor($r,$out, - "rotor $rotor from box"); + Test::Enigmatic::test_static_map( + $r,$out, + "rotor $rotor from box"); }); }; -- cgit v1.2.3