trackler 2.2.1.137 → 2.2.1.138

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/diffie-hellman/canonical-data.json +72 -0
  4. data/problem-specifications/exercises/yacht/description.md +2 -2
  5. data/tracks/csharp/exercises/sgf-parsing/Example.cs +1 -1
  6. data/tracks/csharp/exercises/sgf-parsing/SgfParsingTest.cs +1 -1
  7. data/tracks/csharp/exercises/sublist/SublistTest.cs +37 -78
  8. data/tracks/csharp/generators/Exercises/Sublist.cs +32 -0
  9. data/tracks/elisp/exercises/bob/README.md +2 -0
  10. data/tracks/elisp/exercises/bob/bob-test.el +60 -15
  11. data/tracks/elisp/exercises/bob/example.el +15 -5
  12. data/tracks/elisp/exercises/hamming/hamming-test.el +1 -1
  13. data/tracks/fsharp/build.ps1 +3 -3
  14. data/tracks/fsharp/build.sh +3 -3
  15. data/tracks/fsharp/exercises/bracket-push/BracketPushTest.fs +5 -1
  16. data/tracks/fsharp/exercises/isbn-verifier/IsbnVerifierTest.fs +5 -1
  17. data/tracks/fsharp/exercises/kindergarten-garden/KindergartenGardenTest.fs +1 -1
  18. data/tracks/fsharp/exercises/pov/PovTest.fs +6 -1
  19. data/tracks/fsharp/exercises/react/Example.fs +2 -2
  20. data/tracks/fsharp/exercises/react/React.fsproj +1 -0
  21. data/tracks/fsharp/exercises/react/ReactTest.fs +55 -33
  22. data/tracks/fsharp/exercises/series/Example.fs +2 -12
  23. data/tracks/fsharp/exercises/series/SeriesTest.fs +33 -56
  24. data/tracks/fsharp/generators/Generators.fs +81 -46
  25. data/tracks/idris/exercises/rna-transcription/src/{example.idr → Example.idr} +0 -0
  26. data/tracks/java/config.json +14 -0
  27. data/tracks/java/exercises/acronym/src/test/java/AcronymTest.java +10 -10
  28. data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +39 -39
  29. data/tracks/java/exercises/grep/.meta/hints.md +58 -0
  30. data/tracks/java/exercises/grep/.meta/src/reference/java/GrepTool.java +65 -0
  31. data/tracks/java/exercises/grep/.meta/version +1 -0
  32. data/tracks/java/exercises/grep/README.md +145 -0
  33. data/tracks/java/exercises/grep/build.gradle +18 -0
  34. data/tracks/java/exercises/grep/src/main/java/.keep +0 -0
  35. data/tracks/java/exercises/grep/src/test/java/GrepToolTest.java +395 -0
  36. data/tracks/java/exercises/largest-series-product/src/test/java/LargestSeriesProductCalculatorTest.java +36 -36
  37. data/tracks/java/exercises/minesweeper/src/test/java/MinesweeperBoardTest.java +36 -36
  38. data/tracks/java/exercises/phone-number/src/test/java/PhoneNumberTest.java +14 -14
  39. data/tracks/java/exercises/poker/src/test/java/PokerTest.java +40 -40
  40. data/tracks/java/exercises/pythagorean-triplet/src/test/java/PythagoreanTripletTest.java +10 -10
  41. data/tracks/java/exercises/settings.gradle +1 -0
  42. data/tracks/ocaml/exercises/anagram/example.ml +1 -1
  43. data/tracks/ocaml/exercises/change/example.ml +1 -1
  44. data/tracks/ocaml/exercises/custom-set/example.ml +4 -3
  45. data/tracks/ocaml/exercises/custom-set/test.ml +0 -1
  46. data/tracks/ocaml/exercises/dominoes/test.ml +1 -1
  47. data/tracks/ocaml/exercises/etl/example.ml +1 -1
  48. data/tracks/ocaml/exercises/grade-school/example.ml +1 -1
  49. data/tracks/ocaml/exercises/palindrome-products/example.ml +2 -2
  50. data/tracks/ocaml/exercises/prime-factors/example.ml +1 -1
  51. data/tracks/ocaml/exercises/robot-name/test.ml +1 -1
  52. data/tracks/ocaml/exercises/triangle/example.ml +1 -1
  53. data/tracks/ocaml/make-exercise.sh +1 -0
  54. data/tracks/ocaml/tools/test-generator/src/controller.ml +1 -1
  55. data/tracks/perl5/exercises/raindrops/.meta/solutions/Raindrops.pm +13 -12
  56. data/tracks/perl5/exercises/raindrops/raindrops.t +166 -111
  57. data/tracks/perl6/docs/INSTALLATION.md +1 -3
  58. data/tracks/perl6/exercises/raindrops/.meta/exercise-data.yaml +5 -5
  59. data/tracks/perl6/exercises/raindrops/.meta/solutions/Raindrops.pm6 +2 -2
  60. data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +2 -2
  61. data/tracks/perl6/exercises/raindrops/raindrops.t +3 -3
  62. data/tracks/python/exercises/food-chain/example.py +11 -2
  63. data/tracks/python/exercises/food-chain/food_chain_test.py +48 -45
  64. data/tracks/python/exercises/pov/pov_test.py +12 -1
  65. data/tracks/python/exercises/series/README.md +6 -6
  66. data/tracks/python/exercises/series/example.py +2 -3
  67. data/tracks/python/exercises/series/series_test.py +27 -28
  68. data/tracks/python/exercises/sgf-parsing/example.py +1 -1
  69. data/tracks/python/exercises/sgf-parsing/sgf_parsing_test.py +1 -1
  70. data/tracks/python/exercises/yacht/README.md +2 -2
  71. data/tracks/ruby/Gemfile +0 -1
  72. data/tracks/ruby/README.md +23 -0
  73. data/tracks/ruby/bin/generate +1 -0
  74. data/tracks/ruby/exercises/complex-numbers/complex_numbers_test.rb +1 -1
  75. data/tracks/ruby/lib/generator.rb +1 -2
  76. data/tracks/ruby/lib/generator/command_line.rb +3 -0
  77. data/tracks/ruby/lib/generator/command_line/generator_optparser.rb +1 -0
  78. data/tracks/ruby/lib/generator/exercise.rb +2 -0
  79. data/tracks/ruby/lib/generator/exercise_case.rb +3 -0
  80. data/tracks/ruby/lib/generator/files.rb +1 -0
  81. data/tracks/ruby/lib/generator/files/metadata_files.rb +2 -0
  82. data/tracks/ruby/lib/generator/files/track_files.rb +1 -0
  83. data/tracks/ruby/lib/generator/implementation.rb +1 -0
  84. data/tracks/ruby/lib/generator/repository.rb +3 -0
  85. data/tracks/ruby/lib/generator/template_values.rb +1 -0
  86. data/tracks/ruby/test/generator/case_values_test.rb +2 -0
  87. data/tracks/ruby/test/generator/command_line_test.rb +1 -0
  88. data/tracks/ruby/test/generator/files/metadata_files_test.rb +2 -0
  89. data/tracks/ruby/test/generator/files/track_files_test.rb +1 -0
  90. data/tracks/ruby/test/generator/implementation_test.rb +1 -0
  91. data/tracks/ruby/test/tasks/exercise_test.rb +1 -0
  92. data/tracks/ruby/test/tasks/exercise_test_tasks_test.rb +2 -0
  93. data/tracks/ruby/test/test_helper.rb +1 -3
  94. data/tracks/rust/config.json +12 -0
  95. data/tracks/rust/exercises/atbash-cipher/src/lib.rs +9 -0
  96. data/tracks/rust/exercises/hamming/src/lib.rs +6 -0
  97. data/tracks/rust/exercises/isogram/src/lib.rs +3 -0
  98. data/tracks/rust/exercises/luhn/src/lib.rs +4 -0
  99. data/tracks/rust/exercises/palindrome-products/.meta/test-in-release-mode +1 -0
  100. data/tracks/rust/exercises/palindrome-products/Cargo.toml +6 -0
  101. data/tracks/rust/exercises/palindrome-products/README.md +72 -0
  102. data/tracks/rust/exercises/palindrome-products/example.rs +25 -0
  103. data/tracks/rust/exercises/palindrome-products/src/lib.rs +22 -0
  104. data/tracks/rust/exercises/palindrome-products/tests/palindrome-products.rs +57 -0
  105. data/tracks/rust/exercises/pangram/src/lib.rs +4 -0
  106. data/tracks/rust/exercises/run-length-encoding/src/lib.rs +7 -0
  107. data/tracks/rust/exercises/say/src/lib.rs +3 -4
  108. data/tracks/rust/exercises/scrabble-score/src/lib.rs +4 -0
  109. data/tracks/rust/exercises/word-count/src/lib.rs +6 -0
  110. data/tracks/scheme/exercises/hello-world/example.scm +1 -4
  111. data/tracks/scheme/exercises/hello-world/hello-world-test.scm +1 -5
  112. data/tracks/scheme/exercises/scrabble-score/scrabble-score-test.scm +2 -2
  113. data/tracks/typescript/config.json +30 -0
  114. data/tracks/typescript/exercises/queen-attack/README.md +59 -0
  115. data/tracks/typescript/exercises/queen-attack/package.json +36 -0
  116. data/tracks/typescript/exercises/queen-attack/queen-attack.example.ts +56 -0
  117. data/tracks/typescript/exercises/queen-attack/queen-attack.test.ts +71 -0
  118. data/tracks/typescript/exercises/queen-attack/queen-attack.ts +0 -0
  119. data/tracks/typescript/exercises/queen-attack/tsconfig.json +22 -0
  120. data/tracks/typescript/exercises/queen-attack/tslint.json +127 -0
  121. data/tracks/typescript/exercises/queen-attack/yarn.lock +2624 -0
  122. data/tracks/typescript/exercises/spiral-matrix/README.md +56 -0
  123. data/tracks/typescript/exercises/spiral-matrix/package.json +36 -0
  124. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.example.ts +33 -0
  125. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.test.ts +49 -0
  126. data/tracks/typescript/exercises/spiral-matrix/spiral-matrix.ts +0 -0
  127. data/tracks/typescript/exercises/spiral-matrix/tsconfig.json +22 -0
  128. data/tracks/typescript/exercises/spiral-matrix/tslint.json +127 -0
  129. data/tracks/typescript/exercises/spiral-matrix/yarn.lock +2624 -0
  130. metadata +35 -3
@@ -15,8 +15,8 @@ public class PythagoreanTripletTest {
15
15
  @Test
16
16
  public void shouldCalculateSum() {
17
17
  PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
18
- final int expected = 12;
19
- final int actual = triplet.calculateSum();
18
+ int expected = 12;
19
+ int actual = triplet.calculateSum();
20
20
  assertEquals(expected, actual);
21
21
  }
22
22
 
@@ -24,8 +24,8 @@ public class PythagoreanTripletTest {
24
24
  @Test
25
25
  public void shouldCalculateProduct() {
26
26
  PythagoreanTriplet triplet = new PythagoreanTriplet(3, 4, 5);
27
- final long expected = 60l;
28
- final long actual = triplet.calculateProduct();
27
+ long expected = 60l;
28
+ long actual = triplet.calculateProduct();
29
29
  assertEquals(expected, actual);
30
30
  }
31
31
 
@@ -46,7 +46,7 @@ public class PythagoreanTripletTest {
46
46
  @Ignore("Remove to run test")
47
47
  @Test
48
48
  public void shouldMakeTripletsUpToTen() {
49
- final List<Long> actual
49
+ List<Long> actual
50
50
  = PythagoreanTriplet
51
51
  .makeTripletsList()
52
52
  .withFactorsLessThanOrEqualTo(10)
@@ -55,14 +55,14 @@ public class PythagoreanTripletTest {
55
55
  .map(t -> t.calculateProduct())
56
56
  .sorted()
57
57
  .collect(Collectors.toList());
58
- final List<Long> expected = Arrays.asList(60l, 480l);
58
+ List<Long> expected = Arrays.asList(60l, 480l);
59
59
  assertEquals(expected, actual);
60
60
  }
61
61
 
62
62
  @Ignore("Remove to run test")
63
63
  @Test
64
64
  public void shouldMakeTripletsElevenToTwenty() {
65
- final List<Long> actual
65
+ List<Long> actual
66
66
  = PythagoreanTriplet
67
67
  .makeTripletsList()
68
68
  .withFactorsGreaterThanOrEqualTo(11)
@@ -72,14 +72,14 @@ public class PythagoreanTripletTest {
72
72
  .map(t -> t.calculateProduct())
73
73
  .sorted((p1, p2) -> Double.compare(p1, p2))
74
74
  .collect(Collectors.toList());
75
- final List<Long> expected = Arrays.asList(3840l);
75
+ List<Long> expected = Arrays.asList(3840l);
76
76
  assertEquals(expected, actual);
77
77
  }
78
78
 
79
79
  @Ignore("Remove to run test")
80
80
  @Test
81
81
  public void shouldMakeTripletsAndFilterOnSum() {
82
- final List<Long> actual
82
+ List<Long> actual
83
83
  = PythagoreanTriplet
84
84
  .makeTripletsList()
85
85
  .withFactorsLessThanOrEqualTo(100)
@@ -89,7 +89,7 @@ public class PythagoreanTripletTest {
89
89
  .map(t -> t.calculateProduct())
90
90
  .sorted((p1, p2) -> Double.compare(p1, p2))
91
91
  .collect(Collectors.toList());
92
- final List<Long> expected = Arrays.asList(118080l, 168480l, 202500l);
92
+ List<Long> expected = Arrays.asList(118080l, 168480l, 202500l);
93
93
  assertEquals(expected, actual);
94
94
  }
95
95
  }
@@ -34,6 +34,7 @@ include 'forth'
34
34
  include 'gigasecond'
35
35
  include 'go-counting'
36
36
  include 'grade-school'
37
+ include 'grep'
37
38
  include 'hamming'
38
39
  include 'hexadecimal'
39
40
  include 'hello-world'
@@ -1,6 +1,6 @@
1
1
  open Base
2
2
 
3
- let to_sorted_list s = String.to_list s |> List.sort ~cmp:Char.compare
3
+ let to_sorted_list s = String.to_list s |> List.sort ~compare:Char.compare
4
4
 
5
5
  let anagrams target candidates =
6
6
  let target_lc = String.lowercase target in
@@ -8,7 +8,7 @@ let find_smallest_coins_list_meeting_target (cache: int list option array) (coin
8
8
  List.filter coins ~f:(fun x -> x <= target)
9
9
  |> List.map ~f:find_coins_meeting_target_minus_coin
10
10
  |> List.filter_map ~f:(Fn.id)
11
- |> List.sort ~cmp:(fun xs ys -> Int.compare (List.length xs) (List.length ys))
11
+ |> List.sort ~compare:(fun xs ys -> Int.compare (List.length xs) (List.length ys))
12
12
  |> List.hd
13
13
 
14
14
  let make_change ~target ~coins = match target with
@@ -1,7 +1,6 @@
1
1
  module type ELEMENT = sig
2
2
  type t
3
3
  val compare : t -> t -> int
4
- val equal : t -> t -> bool
5
4
  end
6
5
 
7
6
  module Make(El: ELEMENT) = struct
@@ -12,11 +11,13 @@ module Make(El: ELEMENT) = struct
12
11
 
13
12
  type el = El.t
14
13
 
14
+ let el_equal a b = El.compare a b = 0
15
+
15
16
  let is_empty = function
16
17
  | [] -> true
17
18
  | _ -> false
18
19
 
19
- let is_member l n = List.filter (El.equal n) l |> is_empty |> not
20
+ let is_member l n = List.filter (el_equal n) l |> is_empty |> not
20
21
 
21
22
  let rec is_subset x y = match (x, y) with
22
23
  | ([], []) -> true
@@ -34,7 +35,7 @@ module Make(El: ELEMENT) = struct
34
35
  | ([], []) -> true
35
36
  | ([], _) -> false
36
37
  | (_, []) -> false
37
- | ((x::xs), (y::ys)) -> El.equal x y && equal xs ys
38
+ | ((x::xs), (y::ys)) -> el_equal x y && equal xs ys
38
39
 
39
40
  let of_list = List.sort_uniq El.compare
40
41
 
@@ -17,7 +17,6 @@ end
17
17
  module CSet : EXPECTED = Custom_set.Make(struct
18
18
  type t = int
19
19
  let compare a b = compare (a mod 10) (b mod 10)
20
- let equal a b = compare a b = 0
21
20
  end)
22
21
 
23
22
  let assert_true exp _text_ctxt = assert_equal exp true
@@ -20,7 +20,7 @@ let tuple_compare (x0, y0) (x1, y1) =
20
20
 
21
21
  let norm l =
22
22
  let norm1 (x, y) = if x > y then (y, x) else (x, y) in
23
- List.map ~f:norm1 l |> List.sort ~cmp:tuple_compare
23
+ List.map ~f:norm1 l |> List.sort ~compare:tuple_compare
24
24
 
25
25
  let check_chain (input: dominoe list) (chained: dominoe list) =
26
26
  assert_equal (norm input) (norm chained) ~printer:dominoes_printer ~msg:"chain doesn't use the same dominoes as the input";
@@ -4,4 +4,4 @@ let transform data =
4
4
  let assign_value value character = ((Char.lowercase character), value) in
5
5
  let assign (value, characters) = List.map ~f:(assign_value value) characters in
6
6
  let compare (a, _) (b, _) = Char.compare a b in
7
- List.sort ~cmp:compare (List.concat (List.map ~f:assign data))
7
+ List.sort ~compare:compare (List.concat (List.map ~f:assign data))
@@ -9,4 +9,4 @@ let add s g school = Map.add_multi ~key:g ~data:s school
9
9
 
10
10
  let grade g school = Map.find school g |> Option.value ~default:[]
11
11
 
12
- let sorted school = Map.map ~f:(List.sort ~cmp:String.compare) school
12
+ let sorted school = Map.map ~f:(List.sort ~compare:String.compare) school
@@ -31,7 +31,7 @@ let smallest ~min ~max =
31
31
  |> Sequence.filter ~f:(fun (n, _) -> is_palindrome n) in
32
32
  products
33
33
  |> Sequence.to_list
34
- |> List.sort ~cmp:(fun (x,_) (y,_) -> Int.compare x y)
34
+ |> List.sort ~compare:(fun (x,_) (y,_) -> Int.compare x y)
35
35
  |> List.group ~break:(fun (x, _) (y, _) -> x <> y)
36
36
  |> List.hd
37
37
  |> Option.map ~f:to_palindrome_products
@@ -50,7 +50,7 @@ let largest ~min ~max =
50
50
  |> Sequence.filter ~f:(fun (n, _) -> is_palindrome n) in
51
51
  products
52
52
  |> Sequence.to_list
53
- |> List.sort ~cmp:(fun (x,_) (y,_) -> Int.compare y x)
53
+ |> List.sort ~compare:(fun (x,_) (y,_) -> Int.compare y x)
54
54
  |> List.group ~break:(fun (x, _) (y, _) -> x <> y)
55
55
  |> List.hd
56
56
  |> Option.map ~f:to_palindrome_products
@@ -20,4 +20,4 @@ and factors_of_loop n =
20
20
  done;
21
21
  Option.value ~default:[n] !res
22
22
 
23
- let factors_of n = List.sort ~cmp:Int64.compare (factors_of' n)
23
+ let factors_of n = List.sort ~compare:Int64.compare (factors_of' n)
@@ -55,7 +55,7 @@ let unique_name_tests = [
55
55
  then (Set.add repeated n, seen)
56
56
  else (repeated, Set.add seen n)
57
57
  ) in
58
- let first_few_repeats = Array.slice (Set.to_array repeated) 0 (min 20 (Set.length repeated)) in
58
+ let first_few_repeats = Array.sub (Set.to_array repeated) 0 (min 20 (Set.length repeated)) in
59
59
  let failure_message = "first few repeats: " ^ (String.concat_array first_few_repeats ~sep:",") in
60
60
  assert_bool failure_message (Set.is_empty repeated)
61
61
  );
@@ -1,7 +1,7 @@
1
1
  open Base
2
2
 
3
3
  let sort_sides a b c =
4
- let side = List.nth_exn (List.sort ~cmp:Int.compare [a; b; c]) in
4
+ let side = List.nth_exn (List.sort ~compare:Int.compare [a; b; c]) in
5
5
  (side 0, side 1, side 2)
6
6
 
7
7
  let is_triangle a b c =
@@ -0,0 +1 @@
1
+ make test-assignment ASSIGNMENT=$1
@@ -85,7 +85,7 @@ let run ~(language_config: language_config) ~(templates_folder: string) ~(canoni
85
85
  let check_canonical_data canonical_data_folder =
86
86
  let ok_count = ref 0 in
87
87
  let canonical_data_files = find_canonical_data_files canonical_data_folder in
88
- let canonical_data_files = List.sort canonical_data_files ~cmp:(fun (s1, _) (s2, _) -> String.compare s1 s2) in
88
+ let canonical_data_files = List.sort canonical_data_files ~compare:(fun (s1, _) (s2, _) -> String.compare s1 s2) in
89
89
  let total_count = List.length canonical_data_files in
90
90
  List.iter canonical_data_files ~f:(fun (slug, text) ->
91
91
  match parse_json_text text "cases" with
@@ -1,18 +1,19 @@
1
- package Raindrops;
1
+ package Raindrops 1;
2
2
  use strict;
3
3
  use warnings;
4
+ use Exporter 'import';
5
+ our @EXPORT_OK = qw(raindrop);
4
6
 
5
- sub convert {
6
- my ($num) = @_;
7
-
8
- my $str = '';
9
- $str .= "Pling" if $num / 3 == int($num / 3);
10
- $str .= "Plang" if $num / 5 == int($num / 5);
11
- $str .= "Plong" if $num / 7 == int($num / 7);
12
- return $str if $str;
13
-
14
- return $num;
7
+ sub raindrop {
8
+ my ($num) = @_;
9
+ my %sounds = (Pling => 3, Plang => 5, Plong => 7);
10
+ my $str = '';
11
+ foreach (qw(Pling Plang Plong)) {
12
+ if ($num % $sounds{$_} == 0) {
13
+ $str .= $_;
14
+ }
15
+ }
16
+ return $str || $num;
15
17
  }
16
18
 
17
19
  1;
18
-
@@ -1,123 +1,178 @@
1
1
  #!/usr/bin/env perl
2
2
  use strict;
3
3
  use warnings;
4
-
5
- use Test::More;
6
- use JSON::PP qw(decode_json);
4
+ use JSON::PP;
7
5
  use FindBin;
8
- my $dir;
9
- BEGIN { $dir = $FindBin::Bin . '/' };
10
- use lib $dir;
6
+ use lib $FindBin::Bin;
7
+ use Raindrops qw(raindrop);
11
8
 
12
- my $module = 'Raindrops';
9
+ my $exercise = 'Raindrops';
10
+ my $test_version = 1;
11
+ use Test::More tests => 19;
13
12
 
14
- my $cases;
15
- {
16
- local $/ = undef;
17
- $cases = decode_json scalar <DATA>;
13
+ my $exercise_version = $exercise->VERSION // 0;
14
+ if ($exercise_version != $test_version) {
15
+ warn "\nExercise version mismatch. Further tests may fail!"
16
+ . "\n$exercise is v$exercise_version. "
17
+ . "Test is v$test_version.\n";
18
+ BAIL_OUT if $ENV{EXERCISM};
18
19
  }
19
20
 
20
- #plan tests => 3 + @$cases;
21
- #diag explain $cases;
22
-
23
- ok -e "${dir}${module}.pm", "missing $module.pm"
24
- or BAIL_OUT("You need to create a class called $module.pm with a constructor called convert.");
25
-
26
- eval "use $module";
27
- ok !$@, "Cannot load $module.pm"
28
- or BAIL_OUT("Does $module.pm compile? Does it end with 1; ? ($@)");
29
-
30
- can_ok($module, 'convert') or BAIL_OUT("Missing package $module; or missing sub convert()");
21
+ can_ok $exercise, 'import' or BAIL_OUT 'Cannot import subroutines from module';
31
22
 
32
- my $sub = $module->can('convert');
33
-
34
- foreach my $c (@$cases) {
35
- is $sub->($c->{input}), $c->{expected}, $c->{name}
23
+ my $C_DATA = do { local $/; decode_json(<DATA>); };
24
+ foreach (@{$C_DATA->{cases}}) {
25
+ is raindrop($_->{input}{number}), $_->{expected}, $_->{description};
36
26
  }
37
27
 
38
- done_testing();
39
-
40
28
  __DATA__
41
- [
42
- {
43
- "input" : 1,
44
- "expected" : 1,
45
- "name" : "test_1"
46
- },
47
- {
48
- "input" : 3,
49
- "expected" : "Pling",
50
- "name" : "test_3"
51
- },
52
- {
53
- "input" : 5,
54
- "expected" : "Plang",
55
- "name" : "test_5"
56
- },
57
- {
58
- "input" : 7,
59
- "expected" : "Plong",
60
- "name" : "test_7"
61
- },
62
- {
63
- "input" : 6,
64
- "expected" : "Pling",
65
- "name" : "test_6"
66
- },
67
- {
68
- "input" : 9,
69
- "expected" : "Pling",
70
- "name" : "test_9"
71
- },
72
- {
73
- "input" : 10,
74
- "expected" : "Plang",
75
- "name" : "test_10"
76
- },
77
- {
78
- "input" : 14,
79
- "expected" : "Plong",
80
- "name" : "test_14"
81
- },
82
- {
83
- "input" : 15,
84
- "expected" : "PlingPlang",
85
- "name" : "test_15"
86
- },
87
- {
88
- "input" : 21,
89
- "expected" : "PlingPlong",
90
- "name" : "test_21"
91
- },
92
- {
93
- "input" : 25,
94
- "expected" : "Plang",
95
- "name" : "test_25"
96
- },
97
- {
98
- "input" : 35,
99
- "expected" : "PlangPlong",
100
- "name" : "test_35"
101
- },
102
- {
103
- "input" : 49,
104
- "expected" : "Plong",
105
- "name" : "test_49"
106
- },
107
- {
108
- "input" : 52,
109
- "expected" : 52,
110
- "name" : "test_52"
111
- },
112
- {
113
- "input" : 105,
114
- "expected" : "PlingPlangPlong",
115
- "name" : "test_105"
116
- },
117
- {
118
- "input" : 12121,
119
- "expected" : 12121,
120
- "name" : "test_12121"
121
- }
122
- ]
123
-
29
+ {
30
+ "exercise": "raindrops",
31
+ "version": "1.1.0",
32
+ "cases": [
33
+ {
34
+ "description": "the sound for 1 is 1",
35
+ "property": "convert",
36
+ "input": {
37
+ "number": 1
38
+ },
39
+ "expected": "1"
40
+ },
41
+ {
42
+ "description": "the sound for 3 is Pling",
43
+ "property": "convert",
44
+ "input": {
45
+ "number": 3
46
+ },
47
+ "expected": "Pling"
48
+ },
49
+ {
50
+ "description": "the sound for 5 is Plang",
51
+ "property": "convert",
52
+ "input": {
53
+ "number": 5
54
+ },
55
+ "expected": "Plang"
56
+ },
57
+ {
58
+ "description": "the sound for 7 is Plong",
59
+ "property": "convert",
60
+ "input": {
61
+ "number": 7
62
+ },
63
+ "expected": "Plong"
64
+ },
65
+ {
66
+ "description": "the sound for 6 is Pling as it has a factor 3",
67
+ "property": "convert",
68
+ "input": {
69
+ "number": 6
70
+ },
71
+ "expected": "Pling"
72
+ },
73
+ {
74
+ "description": "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base",
75
+ "property": "convert",
76
+ "input": {
77
+ "number": 8
78
+ },
79
+ "expected": "8"
80
+ },
81
+ {
82
+ "description": "the sound for 9 is Pling as it has a factor 3",
83
+ "property": "convert",
84
+ "input": {
85
+ "number": 9
86
+ },
87
+ "expected": "Pling"
88
+ },
89
+ {
90
+ "description": "the sound for 10 is Plang as it has a factor 5",
91
+ "property": "convert",
92
+ "input": {
93
+ "number": 10
94
+ },
95
+ "expected": "Plang"
96
+ },
97
+ {
98
+ "description": "the sound for 14 is Plong as it has a factor of 7",
99
+ "property": "convert",
100
+ "input": {
101
+ "number": 14
102
+ },
103
+ "expected": "Plong"
104
+ },
105
+ {
106
+ "description": "the sound for 15 is PlingPlang as it has factors 3 and 5",
107
+ "property": "convert",
108
+ "input": {
109
+ "number": 15
110
+ },
111
+ "expected": "PlingPlang"
112
+ },
113
+ {
114
+ "description": "the sound for 21 is PlingPlong as it has factors 3 and 7",
115
+ "property": "convert",
116
+ "input": {
117
+ "number": 21
118
+ },
119
+ "expected": "PlingPlong"
120
+ },
121
+ {
122
+ "description": "the sound for 25 is Plang as it has a factor 5",
123
+ "property": "convert",
124
+ "input": {
125
+ "number": 25
126
+ },
127
+ "expected": "Plang"
128
+ },
129
+ {
130
+ "description": "the sound for 27 is Pling as it has a factor 3",
131
+ "property": "convert",
132
+ "input": {
133
+ "number": 27
134
+ },
135
+ "expected": "Pling"
136
+ },
137
+ {
138
+ "description": "the sound for 35 is PlangPlong as it has factors 5 and 7",
139
+ "property": "convert",
140
+ "input": {
141
+ "number": 35
142
+ },
143
+ "expected": "PlangPlong"
144
+ },
145
+ {
146
+ "description": "the sound for 49 is Plong as it has a factor 7",
147
+ "property": "convert",
148
+ "input": {
149
+ "number": 49
150
+ },
151
+ "expected": "Plong"
152
+ },
153
+ {
154
+ "description": "the sound for 52 is 52",
155
+ "property": "convert",
156
+ "input": {
157
+ "number": 52
158
+ },
159
+ "expected": "52"
160
+ },
161
+ {
162
+ "description": "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7",
163
+ "property": "convert",
164
+ "input": {
165
+ "number": 105
166
+ },
167
+ "expected": "PlingPlangPlong"
168
+ },
169
+ {
170
+ "description": "the sound for 3125 is Plang as it has a factor 5",
171
+ "property": "convert",
172
+ "input": {
173
+ "number": 3125
174
+ },
175
+ "expected": "Plang"
176
+ }
177
+ ]
178
+ }