tracks/perl5/exercises/phone-number/phone-number.t in trackler-2.2.1.110 vs tracks/perl5/exercises/phone-number/phone-number.t in trackler-2.2.1.111

- old
+ new

@@ -1,16 +1,15 @@ #!/usr/bin/env perl use strict; use warnings; use FindBin; -my $dir; -use lib $dir = $FindBin::Bin; +use lib $FindBin::Bin; use JSON::PP; my $exercise = 'PhoneNumber'; -my $test_version = 2; -use Test::More tests => 15; +my $test_version = 3; +use Test::More tests => 16; use_ok $exercise or BAIL_OUT; my $exercise_version = $exercise->VERSION // 0; if ($exercise_version != $test_version) { @@ -26,28 +25,17 @@ $subs{$_} = $exercise->can($_); } my $C_DATA = do { local $/; decode_json(<DATA>); }; foreach my $subcases (@{$C_DATA->{cases}}) { - is $subs{clean_number}->($_->{phrase}), $_->{expected}, $_->{description} foreach @{$subcases->{cases}}; + is $subs{clean_number}->($_->{input}{phrase}), $_->{expected}, $_->{description} foreach @{$subcases->{cases}}; } -SKIP: { - skip '', 1 unless $ENV{EXERCISM}; - TODO: { - local $TODO = 'update canonical-data'; - is_deeply eval q{ - use Path::Tiny; - decode_json path("$dir/../../problem-specifications/exercises/".path($dir)->basename.'/canonical-data.json')->realpath->slurp; - }, $C_DATA, 'canonical-data'; - } -} - __DATA__ { "exercise": "phone-number", - "version": "1.2.0", + "version": "1.4.0", "cases": [ { "description": "Cleanup user-entered phone numbers", "comments": [ " Returns the cleaned phone number if given number is valid, " @@ -56,76 +44,116 @@ ], "cases": [ { "description": "cleans the number", "property": "clean", - "phrase": "(223) 456-7890", + "input": { + "phrase": "(223) 456-7890" + }, "expected": "2234567890" }, { "description": "cleans numbers with dots", "property": "clean", - "phrase": "223.456.7890", + "input": { + "phrase": "223.456.7890" + }, "expected": "2234567890" }, { "description": "cleans numbers with multiple spaces", "property": "clean", - "phrase": "223 456 7890 ", + "input": { + "phrase": "223 456 7890 " + }, "expected": "2234567890" }, { "description": "invalid when 9 digits", "property": "clean", - "phrase": "123456789", + "input": { + "phrase": "123456789" + }, "expected": null }, { "description": "invalid when 11 digits does not start with a 1", "property": "clean", - "phrase": "22234567890", + "input": { + "phrase": "22234567890" + }, "expected": null }, { "description": "valid when 11 digits and starting with 1", "property": "clean", - "phrase": "12234567890", + "input": { + "phrase": "12234567890" + }, "expected": "2234567890" }, { "description": "valid when 11 digits and starting with 1 even with punctuation", "property": "clean", - "phrase": "+1 (223) 456-7890", + "input": { + "phrase": "+1 (223) 456-7890" + }, "expected": "2234567890" }, { "description": "invalid when more than 11 digits", "property": "clean", - "phrase": "321234567890", + "input": { + "phrase": "321234567890" + }, "expected": null }, { "description": "invalid with letters", "property": "clean", - "phrase": "123-abc-7890", + "input": { + "phrase": "123-abc-7890" + }, "expected": null }, { "description": "invalid with punctuations", "property": "clean", - "phrase": "123-@:!-7890", + "input": { + "phrase": "123-@:!-7890" + }, "expected": null }, { - "description": "invalid if area code does not start with 2-9", + "description": "invalid if area code starts with 0", "property": "clean", - "phrase": "(123) 456-7890", + "input": { + "phrase": "(023) 456-7890" + }, "expected": null }, { - "description": "invalid if exchange code does not start with 2-9", + "description": "invalid if area code starts with 1", "property": "clean", - "phrase": "(223) 056-7890", + "input": { + "phrase": "(123) 456-7890" + }, + "expected": null + }, + { + "description": "invalid if exchange code starts with 0", + "property": "clean", + "input": { + "phrase": "(223) 056-7890" + }, + "expected": null + }, + { + "description": "invalid if exchange code starts with 1", + "property": "clean", + "input": { + "phrase": "(223) 156-7890" + }, "expected": null } ] } ]