trackler 2.0.0.1 → 2.0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bump-content +3 -1
  3. data/bin/verify-metadata +2 -2
  4. data/common/exercises/alphametics/canonical-data.json +19 -9
  5. data/common/exercises/food-chain/canonical-data.json +7 -1
  6. data/common/exercises/grains/canonical-data.json +66 -0
  7. data/common/exercises/raindrops/description.md +4 -5
  8. data/common/exercises/triangle/canonical-data.json +81 -54
  9. data/lib/trackler/version.rb +1 -1
  10. data/tracks/c/config.json +26 -19
  11. data/tracks/c/exercises/allergies/makefile +15 -0
  12. data/tracks/c/exercises/allergies/src/allergies.h +21 -0
  13. data/tracks/c/exercises/allergies/src/example.c +32 -0
  14. data/tracks/c/exercises/allergies/src/example.h +26 -0
  15. data/tracks/c/exercises/allergies/test/test_allergies.c +203 -0
  16. data/tracks/c/exercises/allergies/test/vendor/unity.c +1300 -0
  17. data/tracks/c/exercises/allergies/test/vendor/unity.h +274 -0
  18. data/tracks/c/exercises/allergies/test/vendor/unity_internals.h +701 -0
  19. data/tracks/c/exercises/atbash-cipher/makefile +16 -0
  20. data/tracks/c/exercises/atbash-cipher/src/example.c +71 -0
  21. data/tracks/c/exercises/atbash-cipher/src/example.h +7 -0
  22. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +113 -0
  23. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.c +1300 -0
  24. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.h +274 -0
  25. data/tracks/c/exercises/atbash-cipher/test/vendor/unity_internals.h +701 -0
  26. data/tracks/c/exercises/phone-number/makefile +16 -0
  27. data/tracks/c/exercises/phone-number/src/example.c +66 -0
  28. data/tracks/c/exercises/phone-number/src/example.h +8 -0
  29. data/tracks/c/exercises/phone-number/test/test_phone_number.c +108 -0
  30. data/tracks/c/exercises/phone-number/test/vendor/unity.c +1300 -0
  31. data/tracks/c/exercises/phone-number/test/vendor/unity.h +274 -0
  32. data/tracks/c/exercises/phone-number/test/vendor/unity_internals.h +701 -0
  33. data/tracks/csharp/config.json +8 -0
  34. data/tracks/csharp/exercises/bowling/BowlingTest.cs +188 -33
  35. data/tracks/csharp/exercises/bowling/Example.cs +38 -9
  36. data/tracks/csharp/exercises/rectangles/Example.cs +91 -0
  37. data/tracks/csharp/exercises/rectangles/RectanglesTest.cs +133 -0
  38. data/tracks/elisp/docs/INSTALLATION.org +1 -1
  39. data/tracks/elixir/config.json +8 -66
  40. data/tracks/elixir/docs/LEARNING.md +1 -1
  41. data/tracks/elixir/exercises/diamond/diamond_test.exs +12 -12
  42. data/tracks/elixir/exercises/grep/example.exs +92 -0
  43. data/tracks/elixir/exercises/grep/grep.exs +6 -0
  44. data/tracks/elixir/exercises/grep/grep_test.exs +259 -0
  45. data/tracks/elixir/exercises/markdown/markdown.exs +59 -2
  46. data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +4 -4
  47. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +5 -0
  48. data/tracks/fsharp/exercises/bowling/BowlingTest.fs +158 -43
  49. data/tracks/fsharp/exercises/bowling/Example.fs +53 -24
  50. data/tracks/go/config.json +5 -0
  51. data/tracks/go/exercises/diamond/diamond_test.go +227 -0
  52. data/tracks/go/exercises/diamond/example.go +47 -0
  53. data/tracks/go/exercises/food-chain/example.go +1 -1
  54. data/tracks/go/exercises/food-chain/food_chain_test.go +30 -6
  55. data/tracks/go/exercises/nucleotide-count/example.go +21 -8
  56. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +45 -37
  57. data/tracks/haskell/exercises/anagram/test/Tests.hs +1 -11
  58. data/tracks/java/bin/journey-test.sh +165 -128
  59. data/tracks/java/docs/ABOUT.md +5 -8
  60. data/tracks/java/exercises/hello-world/build.gradle +0 -6
  61. data/tracks/java/exercises/hello-world/src/test/java/HelloWorldTest.java +0 -1
  62. data/tracks/java/exercises/meetup/build.gradle +0 -1
  63. data/tracks/java/exercises/meetup/src/example/java/Meetup.java +9 -7
  64. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +185 -188
  65. data/tracks/lua/config.json +0 -73
  66. data/tracks/lua/exercises/bowling/bowling_spec.lua +92 -48
  67. data/tracks/lua/exercises/bowling/example.lua +4 -1
  68. data/tracks/objective-c/config.json +9 -30
  69. data/tracks/objective-c/exercises/pangram/PangramExample.h +7 -0
  70. data/tracks/objective-c/exercises/pangram/PangramExample.m +21 -0
  71. data/tracks/objective-c/exercises/pangram/PangramTest.m +51 -0
  72. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  73. data/tracks/ocaml/README.md +46 -1
  74. data/tracks/ocaml/SETUP.md +21 -2
  75. data/tracks/ocaml/config.json +48 -78
  76. data/tracks/perl5/README.md +15 -8
  77. data/tracks/perl5/testall.pl +5 -5
  78. data/tracks/php/config.json +26 -34
  79. data/tracks/php/docs/ABOUT.md +15 -0
  80. data/tracks/php/exercises/allergies/allergies_test.php +121 -0
  81. data/tracks/php/exercises/allergies/example.php +64 -0
  82. data/tracks/php/exercises/etl/etl_test.php +52 -0
  83. data/tracks/php/exercises/etl/example.php +12 -0
  84. data/tracks/php/exercises/nucleotide-count/example.php +25 -0
  85. data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +36 -0
  86. data/tracks/php/exercises/pig-latin/example.php +25 -29
  87. data/tracks/php/exercises/pig-latin/pig-latin_test.php +26 -19
  88. data/tracks/php/exercises/space-age/example.php +65 -0
  89. data/tracks/php/exercises/space-age/space-age_test.php +70 -0
  90. data/tracks/php/exercises/triangle/example.php +43 -0
  91. data/tracks/php/exercises/triangle/triangle_test.php +140 -0
  92. data/tracks/pony/exercises/anagram/example.pony +6 -6
  93. data/tracks/pony/exercises/anagram/test.pony +3 -4
  94. data/tracks/pony/exercises/bob/test.pony +23 -23
  95. data/tracks/pony/exercises/difference-of-squares/test.pony +11 -11
  96. data/tracks/pony/exercises/hamming/example.pony +3 -3
  97. data/tracks/pony/exercises/hamming/test.pony +16 -16
  98. data/tracks/pony/exercises/hello-world/test.pony +5 -4
  99. data/tracks/pony/exercises/leap/test.pony +8 -8
  100. data/tracks/python/config.json +18 -0
  101. data/tracks/python/exercises/diamond/diamond_test.py +33 -0
  102. data/tracks/python/exercises/diamond/example.py +15 -0
  103. data/tracks/python/exercises/linked-list/example.py +47 -0
  104. data/tracks/python/exercises/linked-list/linked_list.py +13 -0
  105. data/tracks/python/exercises/linked-list/linked_list_test.py +49 -0
  106. data/tracks/python/exercises/list-ops/example.py +55 -0
  107. data/tracks/python/exercises/list-ops/list_ops.py +38 -0
  108. data/tracks/python/exercises/list-ops/list_ops_test.py +136 -0
  109. data/tracks/ruby/bin/generate +22 -2
  110. data/tracks/ruby/config.json +12 -83
  111. data/tracks/ruby/exercises/allergies/allergies_test.rb +0 -1
  112. data/tracks/ruby/exercises/atbash-cipher/atbash_cipher_test.rb +0 -1
  113. data/tracks/ruby/exercises/beer-song/beer_song_test.rb +1 -2
  114. data/tracks/ruby/exercises/binary/example.rb +0 -1
  115. data/tracks/ruby/exercises/binary-search-tree/binary_search_tree_test.rb +1 -1
  116. data/tracks/ruby/exercises/bowling/.version +1 -0
  117. data/tracks/ruby/exercises/bowling/bowling_test.rb +109 -133
  118. data/tracks/ruby/exercises/bowling/example.rb +7 -7
  119. data/tracks/ruby/exercises/bowling/example.tt +27 -0
  120. data/tracks/ruby/exercises/circular-buffer/circular_buffer_test.rb +0 -2
  121. data/tracks/ruby/exercises/clock/example.rb +0 -2
  122. data/tracks/ruby/exercises/connect/connect_test.rb +0 -1
  123. data/tracks/ruby/exercises/custom-set/custom_set_test.rb +0 -1
  124. data/tracks/ruby/exercises/diamond/diamond_test.rb +0 -1
  125. data/tracks/ruby/exercises/etl/etl_test.rb +1 -1
  126. data/tracks/ruby/exercises/house/house_test.rb +0 -1
  127. data/tracks/ruby/exercises/isogram/isogram_test.rb +2 -2
  128. data/tracks/ruby/exercises/largest-series-product/example.tt +0 -3
  129. data/tracks/ruby/exercises/largest-series-product/largest_series_product_test.rb +0 -4
  130. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +1 -1
  131. data/tracks/ruby/exercises/meetup/meetup_test.rb +0 -1
  132. data/tracks/ruby/exercises/nth-prime/example.tt +0 -2
  133. data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +0 -2
  134. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +1 -2
  135. data/tracks/ruby/exercises/protein-translation/protein_translation_test.rb +0 -1
  136. data/tracks/ruby/exercises/proverb/proverb_test.rb +1 -3
  137. data/tracks/ruby/exercises/queen-attack/example.rb +3 -1
  138. data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +34 -8
  139. data/tracks/ruby/exercises/robot-simulator/robot_simulator_test.rb +1 -1
  140. data/tracks/ruby/exercises/strain/strain_test.rb +2 -2
  141. data/tracks/ruby/exercises/tournament/.version +1 -0
  142. data/tracks/ruby/exercises/tournament/example.rb +54 -0
  143. data/tracks/ruby/exercises/tournament/example.tt +23 -0
  144. data/tracks/ruby/exercises/tournament/tournament_test.rb +92 -0
  145. data/tracks/ruby/exercises/transpose/.version +1 -0
  146. data/tracks/ruby/exercises/transpose/example.rb +14 -0
  147. data/tracks/ruby/exercises/transpose/example.tt +22 -0
  148. data/tracks/ruby/exercises/transpose/transpose_test.rb +303 -0
  149. data/tracks/ruby/lib/bowling_cases.rb +46 -0
  150. data/tracks/ruby/lib/isogram_cases.rb +1 -1
  151. data/tracks/ruby/lib/tournament_cases.rb +45 -0
  152. data/tracks/ruby/lib/transpose_cases.rb +45 -0
  153. data/tracks/rust/config.json +2 -0
  154. data/tracks/rust/exercises/bowling/.gitignore +7 -0
  155. data/tracks/rust/exercises/bowling/Cargo.toml +3 -0
  156. data/tracks/rust/exercises/bowling/example.rs +134 -0
  157. data/tracks/rust/exercises/bowling/tests/bowling.rs +373 -0
  158. data/tracks/rust/exercises/grains/.gitignore +7 -0
  159. data/tracks/rust/exercises/grains/Cargo.toml +3 -0
  160. data/tracks/rust/exercises/grains/example.rs +11 -0
  161. data/tracks/rust/exercises/grains/src/lib.rs +7 -0
  162. data/tracks/rust/exercises/grains/tests/grains.rs +63 -0
  163. data/tracks/rust/problems.md +2 -0
  164. data/tracks/scala/README.md +38 -0
  165. data/tracks/scala/config.json +20 -74
  166. data/tracks/scala/exercises/accumulate/src/test/scala/accumulate_test.scala +4 -0
  167. data/tracks/scala/exercises/allergies/src/test/scala/allergies_test.scala +11 -0
  168. data/tracks/scala/exercises/alphametics/build.sbt +6 -0
  169. data/tracks/scala/exercises/alphametics/example.scala +125 -0
  170. data/tracks/scala/exercises/alphametics/src/main/scala/.keep +0 -0
  171. data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +62 -0
  172. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +8 -0
  173. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +4 -0
  174. data/tracks/scala/exercises/binary/src/test/scala/binary_test.scala +13 -0
  175. data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +11 -0
  176. data/tracks/scala/exercises/bowling/Example.scala +116 -0
  177. data/tracks/scala/exercises/bowling/build.sbt +3 -0
  178. data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +11 -0
  179. data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +237 -0
  180. data/tracks/scala/exercises/clock/src/test/scala/ClockTest.scala +50 -0
  181. data/tracks/scala/exercises/connect/README.md +17 -0
  182. data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +7 -0
  183. data/tracks/scala/exercises/crypto-square/src/test/scala/{CrytpoSquareTest.scala → CryptoSquareTest.scala} +9 -0
  184. data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +36 -0
  185. data/tracks/scala/exercises/difference-of-squares/src/test/scala/squares_test.scala +8 -0
  186. data/tracks/scala/exercises/forth/src/test/scala/ForthTest.scala +22 -0
  187. data/tracks/scala/exercises/hexadecimal/src/test/scala/HexadecimalTest.scala +8 -0
  188. data/tracks/scala/exercises/kindergarten-garden/src/test/scala/GardenTest.scala +5 -0
  189. data/tracks/scala/exercises/largest-series-product/src/test/scala/SeriesTest.scala +2 -0
  190. data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +4 -0
  191. data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +4 -0
  192. data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +2 -0
  193. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +6 -0
  194. data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +5 -0
  195. data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +15 -0
  196. data/tracks/scala/exercises/octal/src/test/scala/OctalTest.scala +7 -0
  197. data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +8 -0
  198. data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +5 -0
  199. data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +4 -0
  200. data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +3 -0
  201. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +5 -0
  202. data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotTest.scala +16 -8
  203. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +34 -17
  204. data/tracks/scala/exercises/scrabble-score/src/test/scala/scrabble_score_test.scala +6 -0
  205. data/tracks/scala/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala +18 -9
  206. data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +4 -2
  207. data/tracks/scala/exercises/sieve/src/test/scala/SieveTest.scala +8 -4
  208. data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +17 -9
  209. data/tracks/scala/exercises/sublist/src/test/scala/sublist_test.scala +17 -0
  210. data/tracks/scala/exercises/trinary/src/test/scala/TrinaryTest.scala +14 -7
  211. data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +28 -14
  212. data/tracks/scala/project/Build.scala +3 -3
  213. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +57 -0
  214. data/tracks/sml/config.json +41 -6
  215. data/tracks/sml/exercises/flatten-array/example.sml +6 -0
  216. data/tracks/sml/exercises/flatten-array/test_flatten_array.sml +10 -0
  217. data/tracks/sml/exercises/nth-prime/example.sml +46 -0
  218. data/tracks/sml/exercises/nth-prime/test_nth_prime.sml +14 -0
  219. data/tracks/sml/exercises/raindrops/example.sml +9 -0
  220. data/tracks/sml/exercises/raindrops/raindrops.sml +2 -0
  221. data/tracks/sml/exercises/raindrops/test_raindrops.sml +95 -0
  222. data/tracks/swift/config.json +269 -328
  223. data/tracks/swift/exercises/pangram/PangramExample.swift +17 -0
  224. data/tracks/swift/exercises/pangram/PangramTest.swift +43 -0
  225. data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +16 -0
  226. metadata +95 -3
@@ -4,89 +4,6 @@
4
4
  "repository": "https://github.com/exercism/xruby",
5
5
  "active": true,
6
6
  "gitter": "xruby",
7
- "problems": [
8
- "hello-world",
9
- "hamming",
10
- "gigasecond",
11
- "rna-transcription",
12
- "raindrops",
13
- "difference-of-squares",
14
- "pangram",
15
- "sieve",
16
- "roman-numerals",
17
- "robot-name",
18
- "nth-prime",
19
- "leap",
20
- "grains",
21
- "word-count",
22
- "bob",
23
- "run-length-encoding",
24
- "binary",
25
- "accumulate",
26
- "sum-of-multiples",
27
- "grade-school",
28
- "series",
29
- "phone-number",
30
- "prime-factors",
31
- "strain",
32
- "etl",
33
- "trinary",
34
- "beer-song",
35
- "bowling",
36
- "space-age",
37
- "anagram",
38
- "binary-search-tree",
39
- "crypto-square",
40
- "clock",
41
- "alphametics",
42
- "rail-fence-cipher",
43
- "acronym",
44
- "scrabble-score",
45
- "nucleotide-count",
46
- "flatten-array",
47
- "hexadecimal",
48
- "say",
49
- "meetup",
50
- "queen-attack",
51
- "palindrome-products",
52
- "bracket-push",
53
- "food-chain",
54
- "matrix",
55
- "saddle-points",
56
- "triangle",
57
- "atbash-cipher",
58
- "house",
59
- "secret-handshake",
60
- "proverb",
61
- "ocr-numbers",
62
- "pig-latin",
63
- "simple-linked-list",
64
- "luhn",
65
- "simple-cipher",
66
- "wordy",
67
- "allergies",
68
- "poker",
69
- "kindergarten-garden",
70
- "linked-list",
71
- "pythagorean-triplet",
72
- "robot-simulator",
73
- "twelve-days",
74
- "circular-buffer",
75
- "largest-series-product",
76
- "binary-search",
77
- "two-bucket",
78
- "pascals-triangle",
79
- "custom-set",
80
- "minesweeper",
81
- "scale-generator",
82
- "protein-translation",
83
- "perfect-numbers",
84
- "connect",
85
- "list-ops",
86
- "diamond",
87
- "all-your-base",
88
- "isogram"
89
- ],
90
7
  "exercises": [
91
8
  {
92
9
  "slug": "hello-world",
@@ -573,6 +490,18 @@
573
490
  "difficulty": 1,
574
491
  "topics": [
575
492
  ]
493
+ },
494
+ {
495
+ "slug": "transpose",
496
+ "difficulty": 1,
497
+ "topics": [
498
+ ]
499
+ },
500
+ {
501
+ "slug": "tournament",
502
+ "difficulty": 1,
503
+ "topics": [
504
+ ]
576
505
  }
577
506
  ],
578
507
  "deprecated": [
@@ -59,7 +59,6 @@ class AllergiesTest < Minitest::Test
59
59
  def test_allergic_to_everything
60
60
  skip
61
61
  allergies = Allergies.new(255)
62
- # rubocop:disable Metrics/LineLength
63
62
  expected = %w(eggs peanuts shellfish strawberries tomatoes chocolate pollen cats)
64
63
  assert_equal expected, allergies.list
65
64
  end
@@ -3,7 +3,6 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'atbash_cipher'
5
5
 
6
- # rubocop:disable Style/MethodName
7
6
  class AtbashTest < Minitest::Test
8
7
  def test_encode_no
9
8
  assert_equal 'ml', Atbash.encode('no')
@@ -3,7 +3,6 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'beer_song'
5
5
 
6
- # rubocop:disable Metrics/LineLength
7
6
  class BeerSongTest < Minitest::Test
8
7
  def test_the_first_verse
9
8
  expected = "99 bottles of beer on the wall, 99 bottles of beer.\n" \
@@ -62,7 +61,7 @@ class BeerSongTest < Minitest::Test
62
61
  assert_equal expected, BeerSong.new.verses(2, 0)
63
62
  end
64
63
 
65
- def test_the_whole_song # rubocop:disable Metrics/MethodLength
64
+ def test_the_whole_song
66
65
  skip
67
66
  expected = <<-SONG
68
67
  99 bottles of beer on the wall, 99 bottles of beer.
@@ -19,7 +19,6 @@ class Binary
19
19
 
20
20
  private
21
21
 
22
- # rubocop:disable Style/WordArray
23
22
  def valid?(s)
24
23
  s.chars.all? { |char| ['0', '1'].include?(char) }
25
24
  end
@@ -32,7 +32,7 @@ class BstTest < Minitest::Test
32
32
  assert_equal 5, four.right.data
33
33
  end
34
34
 
35
- def test_complex_tree # rubocop:disable Metrics/MethodLength
35
+ def test_complex_tree
36
36
  skip
37
37
  four = Bst.new 4
38
38
  four.insert 2
@@ -0,0 +1 @@
1
+ 2
@@ -3,224 +3,200 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'bowling'
5
5
 
6
- class GameTest < Minitest::Test
6
+ # Test data version:
7
+ # 0a51cfc
8
+ class BowlingTest < Minitest::Test
7
9
  def setup
8
10
  @game = Game.new
9
11
  end
10
12
 
11
- def test_must_be_able_to_roll_with_number_of_pins
12
- assert_respond_to @game, :roll
13
- assert_equal 1, @game.method(:roll).arity
13
+ def roll(rolls)
14
+ rolls.each { |pins| @game.roll(pins) }
14
15
  end
15
16
 
16
- def test_must_have_a_score
17
- skip
18
- assert_respond_to @game, :score
17
+ def test_should_be_able_to_score_a_game_with_all_zeros
18
+ # skip
19
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
20
+ assert_equal 0, @game.score
19
21
  end
20
22
 
21
- def test_should_be_able_to_score_open_frame
23
+ def test_should_be_able_to_score_a_game_with_no_strikes_or_spares
22
24
  skip
23
- @game.roll(3)
24
- @game.roll(4)
25
- roll_n_times(18, 0)
26
- assert_equal 7, @game.score
25
+ roll([3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6])
26
+ assert_equal 90, @game.score
27
27
  end
28
28
 
29
- def test_should_be_able_to_score_multiple_frames
29
+ def test_a_spare_followed_by_zeros_is_worth_ten_points
30
30
  skip
31
- [3, 4, 2, 3, 5, 2].each do |pins|
32
- @game.roll pins
33
- end
34
- roll_n_times(14, 0)
35
- assert_equal 19, @game.score
31
+ roll([6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
32
+ assert_equal 10, @game.score
36
33
  end
37
34
 
38
- def test_should_score_a_game_with_all_gutterballs
35
+ def test_points_scored_in_the_roll_after_a_spare_are_counted_twice
39
36
  skip
40
- roll_n_times(20, 0)
41
- assert_equal 0, @game.score
37
+ roll([6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
38
+ assert_equal 16, @game.score
42
39
  end
43
40
 
44
- def test_should_score_a_game_with_all_single_pin_rolls
41
+ def test_consecutive_spares_each_get_a_one_roll_bonus
45
42
  skip
46
- roll_n_times(20, 1)
47
- assert_equal 20, @game.score
43
+ roll([5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
44
+ assert_equal 31, @game.score
48
45
  end
49
46
 
50
- def test_should_allow_game_with_all_open_frames
47
+ def test_a_spare_in_the_last_frame_gets_a_one_roll_bonus_that_is_counted_once
51
48
  skip
52
- roll_n_times(10, [3, 6])
53
- assert_equal 90, @game.score
49
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7])
50
+ assert_equal 17, @game.score
54
51
  end
55
52
 
56
- def test_should_correctly_score_a_strike_that_is_not_on_the_last_frame
53
+ def test_a_strike_earns_ten_points_in_frame_with_a_single_roll
57
54
  skip
58
- @game.roll(10)
59
- @game.roll(5)
60
- @game.roll(3)
61
- roll_n_times(16, 0)
62
-
63
- assert_equal 26, @game.score
55
+ roll([10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
56
+ assert_equal 10, @game.score
64
57
  end
65
58
 
66
- def test_should_score_a_spare_that_is_not_on_the_last_frame
59
+ def test_points_scored_in_the_two_rolls_after_a_strike_are_counted_twice_as_a_bonus
67
60
  skip
68
- @game.roll(5)
69
- @game.roll(5)
70
- @game.roll(3)
71
- @game.roll(4)
72
- roll_n_times(16, 0)
73
-
74
- assert_equal 20, @game.score
61
+ roll([10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
62
+ assert_equal 26, @game.score
75
63
  end
76
64
 
77
- def test_should_score_multiple_strikes_in_a_row
65
+ def test_consecutive_strikes_each_get_the_two_roll_bonus
78
66
  skip
79
- @game.roll(10)
80
- @game.roll(10)
81
- @game.roll(10)
82
- @game.roll(5)
83
- @game.roll(3)
84
- roll_n_times(12, 0)
85
-
67
+ roll([10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
86
68
  assert_equal 81, @game.score
87
69
  end
88
70
 
89
- def test_should_score_multiple_spares_in_a_row
71
+ def test_a_strike_in_the_last_frame_gets_a_two_roll_bonus_that_is_counted_once
90
72
  skip
91
- @game.roll(5)
92
- @game.roll(5)
93
- @game.roll(3)
94
- @game.roll(7)
95
- @game.roll(4)
96
- @game.roll(1)
97
- roll_n_times(14, 0)
98
-
99
- assert_equal 32, @game.score
73
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1])
74
+ assert_equal 18, @game.score
100
75
  end
101
76
 
102
- def test_should_allow_fill_balls_when_the_final_frame_is_strike
77
+ def test_rolling_a_spare_with_the_two_roll_bonus_does_not_get_a_bonus_roll
103
78
  skip
104
- roll_n_times(18, 0)
105
- @game.roll(10)
106
- @game.roll(7)
107
- @game.roll(1)
108
-
109
- assert_equal 18, @game.score
79
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3])
80
+ assert_equal 20, @game.score
110
81
  end
111
82
 
112
- def test_should_allow_fill_ball_in_last_frame_if_spare
83
+ def test_strikes_with_the_two_roll_bonus_do_not_get_bonus_rolls
113
84
  skip
114
- roll_n_times(18, 0)
115
- @game.roll(9)
116
- @game.roll(1)
117
- @game.roll(7)
118
-
119
- assert_equal 17, @game.score
85
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10])
86
+ assert_equal 30, @game.score
120
87
  end
121
88
 
122
- def test_should_allow_fill_balls_to_be_strike
89
+ def test_a_strike_with_the_one_roll_bonus_after_a_spare_in_the_last_frame_does_not_get_a_bonus
123
90
  skip
124
- roll_n_times(18, 0)
125
- @game.roll(10)
126
- @game.roll(10)
127
- @game.roll(10)
128
-
129
- assert_equal 30, @game.score
91
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10])
92
+ assert_equal 20, @game.score
130
93
  end
131
94
 
132
- def test_should_score_a_perfect_game
95
+ def test_all_strikes_is_a_perfect_game
133
96
  skip
134
- roll_n_times(12, 10)
97
+ roll([10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10])
135
98
  assert_equal 300, @game.score
136
99
  end
137
100
 
138
- def test_should_not_allow_rolls_with_negative_pins
101
+ def test_rolls_can_not_score_negative_points
139
102
  skip
140
- assert_raises(
141
- RuntimeError,
142
- 'Pins must have a value from 0 to 10') do
143
- @game.roll(-1)
144
- end
103
+ assert_raises StandardError do
104
+ roll([-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
105
+ @game.score
106
+ end
145
107
  end
146
108
 
147
- def test_should_not_allow_rolls_better_than_strike
109
+ def test_a_roll_can_not_score_more_than_10_points
148
110
  skip
149
- assert_raises(
150
- RuntimeError,
151
- 'Pins must have a value from 0 to 10') do
152
- @game.roll(11)
153
- end
111
+ assert_raises StandardError do
112
+ roll([11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
113
+ @game.score
114
+ end
154
115
  end
155
116
 
156
- def test_should_not_allow_two_normal_rolls_better_than_strike
117
+ def test_two_rolls_in_a_frame_can_not_score_more_than_10_points
157
118
  skip
158
- assert_raises RuntimeError, 'Pin count exceeds pins on the lane' do
159
- @game.roll(5)
160
- @game.roll(6)
119
+ assert_raises StandardError do
120
+ roll([5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
121
+ @game.score
161
122
  end
162
123
  end
163
124
 
164
- def test_should_not_allow_two_normal_rolls_better_than_strike_in_last_frame
125
+ def test_two_bonus_rolls_after_a_strike_in_the_last_frame_can_not_score_more_than_10_points
165
126
  skip
166
- roll_n_times(18, 0)
167
- assert_raises RuntimeError, 'Pin count exceeds pins on the lane' do
168
- @game.roll(10)
169
- @game.roll(5)
170
- @game.roll(6)
127
+ assert_raises StandardError do
128
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6])
129
+ @game.score
171
130
  end
172
131
  end
173
132
 
174
- def test_should_not_allow_to_take_score_at_the_beginning
133
+ def test_an_unstarted_game_can_not_be_scored
175
134
  skip
176
- assert_raises(
177
- RuntimeError,
178
- 'Score cannot be taken until the end of the game',
179
- ) do
135
+ assert_raises StandardError do
136
+ roll([])
180
137
  @game.score
181
138
  end
182
139
  end
183
140
 
184
- def test_should_not_allow_to_take_score_before_game_has_ended
141
+ def test_an_incomplete_game_can_not_be_scored
185
142
  skip
186
- roll_n_times(19, 5)
187
- assert_raises(
188
- RuntimeError,
189
- 'Score cannot be taken until the end of the game') do
190
- @game.score
191
- end
143
+ assert_raises StandardError do
144
+ roll([0, 0])
145
+ @game.score
146
+ end
192
147
  end
193
148
 
194
- def test_should_not_allow_rolls_after_the_tenth_frame
149
+ def test_a_game_with_more_than_ten_frames_can_not_be_scored
195
150
  skip
196
- roll_n_times(20, 0)
197
- assert_raises(
198
- RuntimeError,
199
- 'Should not be able to roll after game is over',
200
- ) do
201
- @game.roll(0)
151
+ assert_raises StandardError do
152
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
153
+ @game.score
202
154
  end
203
155
  end
204
156
 
205
- def test_should_not_calculate_score_before_fill_balls_have_been_played
157
+ def test_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
206
158
  skip
207
- roll_n_times(10, 10)
159
+ assert_raises StandardError do
160
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10])
161
+ @game.score
162
+ end
163
+ end
208
164
 
209
- assert_raises RuntimeError, 'Game is not yet over, cannot score!' do
165
+ def test_both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
166
+ skip
167
+ assert_raises StandardError do
168
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10])
210
169
  @game.score
211
170
  end
212
171
  end
213
172
 
214
- def roll_n_times(rolls, pins)
215
- rolls.times do
216
- Array(pins).each { |value| @game.roll(value) }
173
+ def test_bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated
174
+ skip
175
+ assert_raises StandardError do
176
+ roll([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3])
177
+ @game.score
217
178
  end
218
179
  end
219
- private :roll_n_times
220
180
 
221
- # Don't forget to define a constant VERSION inside of BookKeeping.
181
+ # Problems in exercism evolve over time, as we find better ways to ask
182
+ # questions.
183
+ # The version number refers to the version of the problem you solved,
184
+ # not your solution.
185
+ #
186
+ # Define a constant named VERSION inside of the top level BookKeeping
187
+ # module, which may be placed near the end of your file.
188
+ #
189
+ # In your file, it will look like this:
190
+ #
191
+ # module BookKeeping
192
+ # VERSION = 1 # Where the version number matches the one in the test.
193
+ # end
194
+ #
195
+ # If you are curious, read more about constants on RubyDoc:
196
+ # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
197
+
222
198
  def test_bookkeeping
223
199
  skip
224
- assert_equal 1, BookKeeping::VERSION
200
+ assert_equal 2, BookKeeping::VERSION
225
201
  end
226
202
  end
@@ -1,9 +1,9 @@
1
1
  module BookKeeping
2
- VERSION = 1
2
+ VERSION = 2
3
3
  end
4
4
 
5
5
  class Game
6
- RULES = { MIN: 0, MAX: 10 }.freeze
6
+ PINS = { MIN: 0, MAX: 10 }.freeze
7
7
  at_exit { public :roll, :score }
8
8
 
9
9
  private
@@ -20,7 +20,7 @@ class Game
20
20
  end
21
21
 
22
22
  def validate(pins)
23
- raise 'Invalid number of pins' unless (RULES[:MIN]..RULES[:MAX]).cover?(pins)
23
+ raise 'Invalid number of pins' unless (PINS[:MIN]..PINS[:MAX]).cover?(pins)
24
24
  raise 'Too many pins in frame' unless valid_frame?(pins)
25
25
  raise 'Game is over, no rolls allowed' if game_complete?
26
26
  end
@@ -28,8 +28,8 @@ class Game
28
28
  def valid_frame?(pins)
29
29
  last_roll_was_strike = @score_card[current_frame].last == 10
30
30
 
31
- (last_frame? && last_roll_was_strike) ||
32
- @score_card[current_frame].last.to_i + pins <= RULES[:MAX]
31
+ (last_frame? && last_roll_was_strike || spare?) ||
32
+ @score_card[current_frame].last.to_i + pins <= PINS[:MAX]
33
33
  end
34
34
 
35
35
  def score
@@ -40,10 +40,10 @@ class Game
40
40
  end
41
41
 
42
42
  def score_frame(f, i)
43
- strike_or_spare = [f.first, f.inject(:+)].any? {|e| e == RULES[:MAX]}
43
+ strike_or_spare = [f.first, f.inject(:+)].any? { |e| e == PINS[:MAX] }
44
44
 
45
45
  if strike_or_spare
46
- special(@score_card[i], @score_card[i+1], @score_card[i+2])
46
+ special(@score_card[i], @score_card[i + 1], @score_card[i + 2])
47
47
  else
48
48
  f.reduce(:+)
49
49
  end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ gem 'minitest', '>= 5.0.0'
3
+ require 'minitest/autorun'
4
+ require_relative 'bowling'
5
+
6
+ # Test data version:
7
+ # <%= sha1 %>
8
+ class BowlingTest < Minitest::Test
9
+ def setup
10
+ @game = Game.new
11
+ end
12
+
13
+ def roll(rolls)
14
+ rolls.each { |pins| @game.roll(pins) }
15
+ end
16
+ <% test_cases.each do |test_case| %>
17
+ def <%= test_case.test_name %>
18
+ <%= test_case.skipped %>
19
+ <%= test_case.work_load %>
20
+ end
21
+ <% end %>
22
+ <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
23
+ def test_bookkeeping
24
+ skip
25
+ assert_equal <%= version.next %>, BookKeeping::VERSION
26
+ end
27
+ end
@@ -89,7 +89,6 @@ class CircularBufferTest < Minitest::Test
89
89
  assert_raises(CircularBuffer::BufferEmptyException) { buffer.read }
90
90
  end
91
91
 
92
- # rubocop:disable Metrics/MethodLength
93
92
  def test_alternate_read_and_write_into_buffer_overflow
94
93
  skip
95
94
  buffer = CircularBuffer.new(5)
@@ -108,5 +107,4 @@ class CircularBufferTest < Minitest::Test
108
107
  assert_equal 'B', buffer.read
109
108
  assert_raises(CircularBuffer::BufferEmptyException) { buffer.read }
110
109
  end
111
- # rubocop:enable Metrics/MethodLength
112
110
  end
@@ -12,7 +12,6 @@ class Clock
12
12
  @internal = hours * 60 + minutes
13
13
  end
14
14
 
15
- # rubocop:disable Style/OpMethod
16
15
  def +(hours=0, minutes)
17
16
  @internal += hours * 60 + minutes
18
17
  self
@@ -21,7 +20,6 @@ class Clock
21
20
  def -(*args)
22
21
  self.+(*args.map(&:-@))
23
22
  end
24
- # rubocop:enable Style/OpMethod
25
23
 
26
24
  def ==(other)
27
25
  to_s == other.to_s
@@ -95,7 +95,6 @@ class ConnectTest < Minitest::Test
95
95
  assert_equal 'X', game.winner, 'X wins using a convoluted path'
96
96
  end
97
97
 
98
- # rubocop:disable MethodLength
99
98
  def test_x_wins_using_a_spiral_path
100
99
  skip
101
100
  board = [
@@ -204,7 +204,6 @@ class CustomSetTest < Minitest::Test
204
204
  assert_equal expected, set2.intersection(set1)
205
205
  end
206
206
 
207
- # rubocop:disable Metrics/LineLength
208
207
  def test_intersection_of_two_sets_with_shared_elements_is_a_set_of_the_shared_elements
209
208
  skip
210
209
  set1 = CustomSet.new [1, 2, 3, 4]
@@ -1,4 +1,3 @@
1
- # rubocop:disable Metrics/MethodLength
2
1
  # !/usr/bin/env ruby
3
2
  gem 'minitest', '>= 5.0.0'
4
3
  require 'minitest/autorun'
@@ -32,7 +32,7 @@ class TransformTest < Minitest::Test
32
32
  assert_equal expected, ETL.transform(old)
33
33
  end
34
34
 
35
- def test_full_dataset # rubocop:disable Metrics/MethodLength
35
+ def test_full_dataset
36
36
  skip
37
37
  old = {
38
38
  1 => %w(A E I O U L N R S T),
@@ -3,7 +3,6 @@ gem 'minitest', '>= 5.0.0'
3
3
  require 'minitest/autorun'
4
4
  require_relative 'house'
5
5
 
6
- # rubocop:disable Metrics/MethodLength
7
6
  class HouseTest < Minitest::Test
8
7
  def test_rhyme
9
8
  expected = <<-RHYME
@@ -4,10 +4,10 @@ gem 'minitest', '>= 5.0.0'
4
4
  require 'minitest/autorun'
5
5
  require_relative 'isogram'
6
6
 
7
- # Common test data version: 3dfde31
7
+ # Common test data version: c1cb73f
8
8
  class IsogramTest < Minitest::Test
9
9
  def test_duplicates
10
-
10
+ # skip
11
11
  string = 'duplicates'
12
12
  assert Isogram.is_isogram?(string)
13
13
  end
@@ -5,9 +5,6 @@ require_relative 'largest_series_product'
5
5
 
6
6
  # Test data version:
7
7
  # <%= sha1 %>
8
- # Rubocop directives
9
- # rubocop:disable Style/NumericLiterals
10
- # rubocop:disable Metrics/LineLength
11
8
  #
12
9
  class Seriestest < Minitest::Test<% test_cases.each do |test_case| %>
13
10
  def <%= test_case.name %><% if test_case.skipped? %>