trackler 2.0.6.11 → 2.0.6.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +6 -1
- data/common/exercises/difference-of-squares/metadata.yml +1 -1
- data/common/exercises/luhn/canonical-data.json +2 -2
- data/common/exercises/rectangles/canonical-data.json +25 -0
- data/common/exercises/rectangles/description.md +11 -3
- data/lib/trackler/version.rb +1 -1
- data/tracks/ceylon/config.json +9 -0
- data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +38 -39
- data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +28 -29
- data/tracks/ceylon/exercises/largest-series-product/example/Series.ceylon +13 -0
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/Series.ceylon +5 -0
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +30 -0
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/module.ceylon +3 -0
- data/tracks/csharp/config.json +41 -0
- data/tracks/csharp/exercises/alphametics/AlphameticsTest.cs +122 -0
- data/tracks/csharp/exercises/alphametics/Example.cs +139 -0
- data/tracks/csharp/exercises/dot-dsl/DotDslTest.cs +91 -0
- data/tracks/csharp/exercises/dot-dsl/Example.cs +90 -0
- data/tracks/csharp/exercises/dot-dsl/HINTS.md +2 -0
- data/tracks/csharp/exercises/error-handling/ErrorHandlingTest.cs +65 -0
- data/tracks/csharp/exercises/error-handling/Example.cs +34 -0
- data/tracks/csharp/exercises/exercises.csproj +1 -1
- data/tracks/csharp/exercises/hangman/Example.cs +85 -0
- data/tracks/csharp/exercises/hangman/HangmanTest.cs +140 -0
- data/tracks/csharp/exercises/ledger/Example.cs +106 -0
- data/tracks/csharp/exercises/ledger/Ledger.cs +166 -0
- data/tracks/csharp/exercises/ledger/LedgerTest.cs +168 -0
- data/tracks/elixir/exercises/allergies/allergies_test.exs +2 -2
- data/tracks/elixir/exercises/markdown/example.exs +3 -3
- data/tracks/elixir/exercises/phone-number/example.exs +0 -2
- data/tracks/elixir/exercises/queen-attack/example.exs +1 -1
- data/tracks/elixir/exercises/wordy/example.exs +6 -6
- data/tracks/elixir/exercises/zipper/zipper_test.exs +12 -12
- data/tracks/elixir/mix.exs +1 -1
- data/tracks/fsharp/config.json +8 -8
- data/tracks/fsharp/docs/ABOUT.md +4 -0
- data/tracks/fsharp/exercises/alphametics/AlphameticsTest.fs +33 -13
- data/tracks/fsharp/exercises/alphametics/Example.fs +29 -64
- data/tracks/fsharp/exercises/binary-search-tree/BinarySearchTreeTest.fs +14 -14
- data/tracks/fsharp/exercises/binary-search-tree/Example.fs +17 -14
- data/tracks/fsharp/exercises/triangle/TriangleTest.fs +0 -5
- data/tracks/go/README.md +3 -3
- data/tracks/go/config.json +10 -3
- data/tracks/go/exercises/acronym/acronym.go +5 -0
- data/tracks/go/exercises/bob/example_gen.go +1 -1
- data/tracks/go/exercises/clock/example_gen.go +1 -1
- data/tracks/go/exercises/connect/example_gen.go +1 -1
- data/tracks/go/exercises/custom-set/example_gen.go +1 -1
- data/tracks/go/exercises/gigasecond/example_gen.go +1 -1
- data/tracks/go/exercises/hamming/example_gen.go +1 -1
- data/tracks/go/exercises/largest-series-product/example_gen.go +1 -1
- data/tracks/go/exercises/leap/cases_test.go +5 -7
- data/tracks/go/exercises/leap/example.go +1 -1
- data/tracks/go/exercises/leap/example_gen.go +1 -1
- data/tracks/go/exercises/leap/leap.go +1 -1
- data/tracks/go/exercises/leap/leap_test.go +1 -1
- data/tracks/go/exercises/meetup/example_gen.go +1 -1
- data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +0 -5
- data/tracks/go/exercises/pangram/pangram.go +5 -0
- data/tracks/go/exercises/raindrops/example_gen.go +1 -1
- data/tracks/go/exercises/rna-transcription/example_gen.go +1 -1
- data/tracks/go/exercises/roman-numerals/example_gen.go +1 -1
- data/tracks/go/exercises/word-count/example_gen.go +1 -1
- data/tracks/go/gen/gen.go +3 -2
- data/tracks/haskell/exercises/accumulate/src/Accumulate.hs +1 -1
- data/tracks/haskell/exercises/all-your-base/src/Base.hs +1 -1
- data/tracks/haskell/exercises/allergies/src/Allergies.hs +2 -2
- data/tracks/haskell/exercises/alphametics/src/Alphametics.hs +1 -1
- data/tracks/haskell/exercises/anagram/src/Anagram.hs +1 -1
- data/tracks/haskell/exercises/atbash-cipher/src/Atbash.hs +2 -2
- data/tracks/haskell/exercises/bank-account/src/BankAccount.hs +4 -4
- data/tracks/haskell/exercises/binary/src/Binary.hs +1 -1
- data/tracks/haskell/exercises/binary-search-tree/src/BST.hs +8 -8
- data/tracks/haskell/exercises/bob/src/Bob.hs +1 -1
- data/tracks/haskell/exercises/bowling/src/Bowling.hs +1 -1
- data/tracks/haskell/exercises/change/src/Change.hs +1 -1
- data/tracks/haskell/exercises/clock/src/Clock.hs +4 -4
- data/tracks/haskell/exercises/connect/src/Connect.hs +1 -1
- data/tracks/haskell/exercises/crypto-square/src/CryptoSquare.hs +1 -1
- data/tracks/haskell/exercises/custom-set/src/CustomSet.hs +13 -13
- data/tracks/haskell/exercises/difference-of-squares/src/Squares.hs +3 -3
- data/tracks/haskell/exercises/dominoes/src/Dominoes.hs +1 -1
- data/tracks/haskell/exercises/etl/src/ETL.hs +1 -1
- data/tracks/haskell/exercises/forth/src/Forth.hs +3 -3
- data/tracks/haskell/exercises/gigasecond/src/Gigasecond.hs +1 -1
- data/tracks/haskell/exercises/go-counting/src/Counting.hs +2 -2
- data/tracks/haskell/exercises/grade-school/src/School.hs +4 -4
- data/tracks/haskell/exercises/grains/src/Grains.hs +2 -2
- data/tracks/haskell/exercises/hamming/src/Hamming.hs +1 -1
- data/tracks/haskell/exercises/hexadecimal/src/Hexadecimal.hs +1 -1
- data/tracks/haskell/exercises/kindergarten-garden/src/Garden.hs +3 -3
- data/tracks/haskell/exercises/largest-series-product/src/Series.hs +1 -1
- data/tracks/haskell/exercises/leap/src/LeapYear.hs +1 -1
- data/tracks/haskell/exercises/lens-person/src/Person.hs +4 -4
- data/tracks/haskell/exercises/linked-list/src/Deque.hs +5 -5
- data/tracks/haskell/exercises/list-ops/src/ListOps.hs +8 -8
- data/tracks/haskell/exercises/luhn/src/Luhn.hs +5 -5
- data/tracks/haskell/exercises/matrix/src/Matrix.hs +10 -10
- data/tracks/haskell/exercises/meetup/src/Meetup.hs +1 -1
- data/tracks/haskell/exercises/minesweeper/src/Minesweeper.hs +1 -1
- data/tracks/haskell/exercises/nth-prime/src/Prime.hs +1 -1
- data/tracks/haskell/exercises/nucleotide-count/src/DNA.hs +2 -2
- data/tracks/haskell/exercises/ocr-numbers/src/OCR.hs +1 -1
- data/tracks/haskell/exercises/octal/src/Octal.hs +2 -2
- data/tracks/haskell/exercises/palindrome-products/src/Palindromes.hs +2 -2
- data/tracks/haskell/exercises/parallel-letter-frequency/src/Frequency.hs +1 -1
- data/tracks/haskell/exercises/pascals-triangle/src/Triangle.hs +1 -1
- data/tracks/haskell/exercises/phone-number/src/Phone.hs +3 -3
- data/tracks/haskell/exercises/pig-latin/src/PigLatin.hs +1 -1
- data/tracks/haskell/exercises/pov/src/POV.hs +2 -2
- data/tracks/haskell/exercises/prime-factors/src/PrimeFactors.hs +1 -1
- data/tracks/haskell/exercises/pythagorean-triplet/src/Triplet.hs +3 -3
- data/tracks/haskell/exercises/queen-attack/src/Queens.hs +2 -2
- data/tracks/haskell/exercises/raindrops/src/Raindrops.hs +1 -1
- data/tracks/haskell/exercises/rna-transcription/src/DNA.hs +1 -1
- data/tracks/haskell/exercises/robot-name/src/Robot.hs +3 -3
- data/tracks/haskell/exercises/robot-simulator/src/Robot.hs +6 -6
- data/tracks/haskell/exercises/roman-numerals/src/Roman.hs +1 -1
- data/tracks/haskell/exercises/run-length-encoding/src/RunLength.hs +2 -2
- data/tracks/haskell/exercises/saddle-points/src/Matrix.hs +1 -1
- data/tracks/haskell/exercises/say/src/Say.hs +1 -1
- data/tracks/haskell/exercises/scrabble-score/src/Scrabble.hs +2 -2
- data/tracks/haskell/exercises/secret-handshake/src/SecretHandshake.hs +1 -1
- data/tracks/haskell/exercises/series/src/Series.hs +1 -1
- data/tracks/haskell/exercises/sgf-parsing/src/Sgf.hs +1 -1
- data/tracks/haskell/exercises/sieve/src/Sieve.hs +1 -1
- data/tracks/haskell/exercises/simple-cipher/src/Cipher.hs +3 -3
- data/tracks/haskell/exercises/simple-linked-list/src/LinkedList.hs +8 -8
- data/tracks/haskell/exercises/space-age/src/SpaceAge.hs +1 -1
- data/tracks/haskell/exercises/strain/src/Strain.hs +2 -2
- data/tracks/haskell/exercises/sublist/src/Sublist.hs +1 -1
- data/tracks/haskell/exercises/sum-of-multiples/src/SumOfMultiples.hs +1 -1
- data/tracks/haskell/exercises/triangle/src/Triangle.hs +1 -1
- data/tracks/haskell/exercises/trinary/src/Trinary.hs +2 -2
- data/tracks/haskell/exercises/word-count/src/WordCount.hs +1 -1
- data/tracks/haskell/exercises/wordy/src/WordProblem.hs +1 -1
- data/tracks/haskell/exercises/zebra-puzzle/src/ZebraPuzzle.hs +1 -1
- data/tracks/haskell/exercises/zipper/src/Zipper.hs +9 -9
- data/tracks/java/docs/MAINTAINING.md +48 -0
- data/tracks/java/exercises/queen-attack/src/test/java/QueenAttackCalculatorTest.java +51 -51
- data/tracks/kotlin/exercises/etl/src/example/kotlin/ETL.kt +1 -1
- data/tracks/kotlin/exercises/etl/src/test/kotlin/ETLTest.kt +19 -19
- data/tracks/kotlin/exercises/pangram/src/test/kotlin/PangramTest.kt +5 -0
- data/tracks/lisp/docs/ABOUT.md +9 -0
- data/tracks/lua/exercises/transpose/example.lua +1 -1
- data/tracks/lua/exercises/transpose/transpose_spec.lua +16 -0
- data/tracks/pascal/config.json +36 -36
- data/tracks/pascal/exercises/bob/uBobTests.pas +0 -1
- data/tracks/pascal/exercises/hamming/uHammingTests.pas +0 -1
- data/tracks/pascal/exercises/leap/uLeapTests.pas +0 -1
- data/tracks/pascal/exercises/saddle-points/uSaddlePointsExample.pas +11 -0
- data/tracks/pascal/exercises/saddle-points/uSaddlePointsTests.pas +9 -1
- data/tracks/perl6/exercises/atbash-cipher/cipher.t +1 -1
- data/tracks/php/config.json +7 -0
- data/tracks/php/exercises/robot-simulator/example.php +148 -0
- data/tracks/php/exercises/robot-simulator/robot-simulator_test.php +168 -0
- data/tracks/pony/config.json +16 -7
- data/tracks/pony/exercises/roman-numerals/example.pony +35 -0
- data/tracks/pony/exercises/roman-numerals/test.pony +45 -0
- data/tracks/python/requirements-travis.txt +1 -1
- data/tracks/ruby/.rubocop.yml +1 -1
- data/tracks/ruby/bin/enable-executable +1 -1
- data/tracks/ruby/bin/executable-tests-check +1 -1
- data/tracks/ruby/exercises/acronym/example.tt +2 -3
- data/tracks/ruby/exercises/all-your-base/example.tt +2 -2
- data/tracks/ruby/exercises/alphametics/example.tt +2 -2
- data/tracks/ruby/exercises/anagram/example.tt +2 -3
- data/tracks/ruby/exercises/binary/example.tt +2 -3
- data/tracks/ruby/exercises/bowling/example.tt +2 -3
- data/tracks/ruby/exercises/bracket-push/example.tt +2 -3
- data/tracks/ruby/exercises/clock/example.tt +2 -3
- data/tracks/ruby/exercises/connect/example.rb +1 -1
- data/tracks/ruby/exercises/connect/example.tt +1 -1
- data/tracks/ruby/exercises/custom-set/example.tt +2 -3
- data/tracks/ruby/exercises/diamond/example.rb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/example.tt +2 -3
- data/tracks/ruby/exercises/dominoes/example.tt +2 -2
- data/tracks/ruby/exercises/gigasecond/example.tt +2 -3
- data/tracks/ruby/exercises/grains/example.tt +2 -2
- data/tracks/ruby/exercises/hamming/example.tt +2 -3
- data/tracks/ruby/exercises/hello-world/example.tt +1 -2
- data/tracks/ruby/exercises/isogram/example.tt +2 -2
- data/tracks/ruby/exercises/largest-series-product/example.tt +2 -4
- data/tracks/ruby/exercises/leap/example.tt +2 -3
- data/tracks/ruby/exercises/nth-prime/example.tt +2 -4
- data/tracks/ruby/exercises/pangram/example.tt +2 -2
- data/tracks/ruby/exercises/queen-attack/example.tt +2 -3
- data/tracks/ruby/exercises/raindrops/example.tt +2 -3
- data/tracks/ruby/exercises/rna-transcription/example.tt +2 -3
- data/tracks/ruby/exercises/roman-numerals/example.tt +2 -3
- data/tracks/ruby/exercises/run-length-encoding/example.tt +2 -3
- data/tracks/ruby/exercises/sieve/example.tt +2 -4
- data/tracks/ruby/exercises/simple-linked-list/simple_linked_list_test.rb +6 -6
- data/tracks/ruby/exercises/tournament/example.tt +2 -3
- data/tracks/ruby/exercises/transpose/example.tt +2 -3
- data/tracks/ruby/exercises/triangle/example.tt +2 -3
- data/tracks/ruby/exercises/two-bucket/example.tt +2 -3
- data/tracks/ruby/exercises/word-count/example.tt +2 -3
- data/tracks/ruby/exercises/wordy/example.tt +2 -2
- data/tracks/ruby/lib/acronym_cases.rb +2 -0
- data/tracks/ruby/lib/all_your_base_cases.rb +3 -1
- data/tracks/ruby/lib/alphametics_cases.rb +6 -4
- data/tracks/ruby/lib/anagram_cases.rb +2 -0
- data/tracks/ruby/lib/binary_cases.rb +2 -0
- data/tracks/ruby/lib/bowling_cases.rb +2 -0
- data/tracks/ruby/lib/bracket_push_cases.rb +2 -0
- data/tracks/ruby/lib/clock_cases.rb +2 -0
- data/tracks/ruby/lib/connect_cases.rb +2 -0
- data/tracks/ruby/lib/custom_set_cases.rb +2 -0
- data/tracks/ruby/lib/difference_of_squares_cases.rb +2 -0
- data/tracks/ruby/lib/dominoes_cases.rb +2 -0
- data/tracks/ruby/lib/exercise_cases.rb +2 -0
- data/tracks/ruby/lib/generator/files/track_files.rb +3 -3
- data/tracks/ruby/lib/generator/files.rb +1 -1
- data/tracks/ruby/lib/generator/template_values.rb +5 -14
- data/tracks/ruby/lib/gigasecond_cases.rb +2 -0
- data/tracks/ruby/lib/grains_cases.rb +3 -1
- data/tracks/ruby/lib/hamming_cases.rb +2 -0
- data/tracks/ruby/lib/hello_world_cases.rb +2 -0
- data/tracks/ruby/lib/isogram_cases.rb +3 -1
- data/tracks/ruby/lib/largest_series_product_cases.rb +2 -0
- data/tracks/ruby/lib/leap_cases.rb +2 -0
- data/tracks/ruby/lib/nth_prime_cases.rb +2 -0
- data/tracks/ruby/lib/pangram_cases.rb +3 -1
- data/tracks/ruby/lib/queen_attack_cases.rb +2 -0
- data/tracks/ruby/lib/raindrops_cases.rb +2 -0
- data/tracks/ruby/lib/rna_transcription_cases.rb +2 -0
- data/tracks/ruby/lib/roman_numerals_cases.rb +2 -0
- data/tracks/ruby/lib/run_length_encoding_cases.rb +2 -0
- data/tracks/ruby/lib/sieve_cases.rb +2 -0
- data/tracks/ruby/lib/tournament_cases.rb +2 -0
- data/tracks/ruby/lib/transpose_cases.rb +2 -0
- data/tracks/ruby/lib/triangle_cases.rb +2 -0
- data/tracks/ruby/lib/two_bucket_cases.rb +2 -0
- data/tracks/ruby/lib/word_count_cases.rb +2 -0
- data/tracks/ruby/lib/wordy_cases.rb +2 -0
- data/tracks/ruby/test/fixtures/xruby/exercises/alpha/example.tt +2 -2
- data/tracks/ruby/test/fixtures/xruby/lib/alpha_cases.rb +1 -1
- data/tracks/ruby/test/generator/command_line_test.rb +1 -1
- data/tracks/ruby/test/generator/template_values_test.rb +7 -7
- data/tracks/rust/.travis.yml +4 -0
- data/tracks/rust/_test/check-exercises.sh +11 -2
- data/tracks/rust/config.json +9 -0
- data/tracks/rust/exercises/luhn/.gitignore +7 -0
- data/tracks/rust/exercises/luhn/Cargo.toml +3 -0
- data/tracks/rust/exercises/luhn/example.rs +13 -0
- data/tracks/rust/exercises/luhn/tests/luhn.rs +38 -0
- data/tracks/rust/exercises/parallel-letter-frequency/HINTS.md +32 -0
- data/tracks/rust/exercises/parallel-letter-frequency/benches/benchmark.rs +99 -0
- data/tracks/scala/config.json +57 -1
- data/tracks/scala/exercises/allergies/build.sbt +2 -2
- data/tracks/scala/exercises/atbash-cipher/build.sbt +2 -2
- data/tracks/scala/exercises/bank-account/build.sbt +3 -2
- data/tracks/scala/exercises/binary-search-tree/build.sbt +2 -2
- data/tracks/scala/exercises/clock/build.sbt +2 -2
- data/tracks/scala/exercises/crypto-square/build.sbt +2 -2
- data/tracks/scala/exercises/custom-set/build.sbt +3 -2
- data/tracks/scala/exercises/food-chain/build.sbt +3 -2
- data/tracks/scala/exercises/house/build.sbt +2 -2
- data/tracks/scala/exercises/kindergarten-garden/build.sbt +3 -2
- data/tracks/scala/exercises/largest-series-product/build.sbt +2 -2
- data/tracks/scala/exercises/linked-list/build.sbt +3 -2
- data/tracks/scala/exercises/matrix/build.sbt +2 -2
- data/tracks/scala/exercises/minesweeper/build.sbt +2 -2
- data/tracks/scala/exercises/nth-prime/build.sbt +2 -2
- data/tracks/scala/exercises/ocr-numbers/build.sbt +2 -2
- data/tracks/scala/exercises/palindrome-products/build.sbt +2 -2
- data/tracks/scala/exercises/prime-factors/build.sbt +3 -2
- data/tracks/scala/exercises/queen-attack/build.sbt +2 -2
- data/tracks/scala/exercises/raindrops/build.sbt +2 -2
- data/tracks/scala/exercises/robot-simulator/build.sbt +2 -2
- data/tracks/scala/exercises/triangle/build.sbt +2 -2
- data/tracks/scala/exercises/trinary/build.sbt +2 -2
- data/tracks/scala/exercises/wordy/build.sbt +3 -3
- metadata +33 -2
@@ -3,8 +3,7 @@ gem 'minitest', '>= 5.0.0'
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require_relative 'word_count'
|
5
5
|
|
6
|
-
#
|
7
|
-
# <%= sha1 %>
|
6
|
+
# Common test data version: <%= abbreviated_commit_hash %>
|
8
7
|
class PhraseTest < Minitest::Test<% test_cases.each do |test_case| %>
|
9
8
|
def <%= test_case.name %><% if test_case.skipped? %>
|
10
9
|
skip<% end %>
|
@@ -16,7 +15,7 @@ class PhraseTest < Minitest::Test<% test_cases.each do |test_case| %>
|
|
16
15
|
<%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
|
17
16
|
def test_bookkeeping
|
18
17
|
skip
|
19
|
-
assert_equal <%= version
|
18
|
+
assert_equal <%= version %>, BookKeeping::VERSION
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require_relative 'wordy'
|
3
3
|
|
4
|
-
#
|
4
|
+
# Common test data version: <%= abbreviated_commit_hash %>
|
5
5
|
class WordyTest < Minitest::Test<% test_cases.each do |test_case| %>
|
6
6
|
def <%= test_case.test_name %>
|
7
7
|
<%= test_case.skipped %>
|
@@ -12,6 +12,6 @@ class WordyTest < Minitest::Test<% test_cases.each do |test_case| %>
|
|
12
12
|
<%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
|
13
13
|
def test_bookkeeping
|
14
14
|
skip
|
15
|
-
assert_equal <%= version
|
15
|
+
assert_equal <%= version %>, BookKeeping::VERSION
|
16
16
|
end
|
17
17
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'exercise_cases'
|
2
|
+
|
1
3
|
class AllYourBaseCase < OpenStruct
|
2
4
|
def test_name
|
3
5
|
'test_%s' % description.downcase.tr(' -', '_')
|
@@ -95,7 +97,7 @@ class AllYourBaseCase::PreProcessor
|
|
95
97
|
end
|
96
98
|
|
97
99
|
def handle_special_cases
|
98
|
-
[4,2] if row['input_digits'] == [0, 6, 0]
|
100
|
+
[4, 2] if row['input_digits'] == [0, 6, 0]
|
99
101
|
end
|
100
102
|
end
|
101
103
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'exercise_cases'
|
2
|
+
|
1
3
|
class AlphameticsCase < OpenStruct
|
2
4
|
def test_name
|
3
5
|
"test_#{description.tr(' ', '_')}"
|
@@ -20,7 +22,7 @@ class AlphameticsCase < OpenStruct
|
|
20
22
|
"input = %s\n" % input,
|
21
23
|
"expected = %s\n" % expect,
|
22
24
|
"assert_equal expected, Alphametics.solve(input)"
|
23
|
-
indent(body,4)
|
25
|
+
indent(body, 4)
|
24
26
|
end
|
25
27
|
|
26
28
|
def runtime_comment
|
@@ -30,7 +32,7 @@ class AlphameticsCase < OpenStruct
|
|
30
32
|
"# The obvious algorithm can take a long time to solve this puzzle,\n",
|
31
33
|
"# but an optimised solution can solve it fairly quickly.\n",
|
32
34
|
"# (It's OK to submit your solution without getting this test to pass.)\n"
|
33
|
-
indent(comments,2)
|
35
|
+
indent(comments, 2)
|
34
36
|
end
|
35
37
|
end
|
36
38
|
|
@@ -41,7 +43,7 @@ class AlphameticsCase < OpenStruct
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def expected_values
|
44
|
-
"{ #{indent(expected_values_as_lines,17)} }"
|
46
|
+
"{ #{indent(expected_values_as_lines, 17)} }"
|
45
47
|
end
|
46
48
|
|
47
49
|
def expected_values_as_lines
|
@@ -50,7 +52,7 @@ class AlphameticsCase < OpenStruct
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def expected_values_as_strings
|
53
|
-
expected.sort.map { |(key,value)| "'#{key}' => #{value}" }
|
55
|
+
expected.sort.map { |(key, value)| "'#{key}' => #{value}" }
|
54
56
|
end
|
55
57
|
|
56
58
|
def add_trailing_comma_and_newline(lines)
|
@@ -11,7 +11,7 @@ module Generator
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def filename(exercise_name)
|
14
|
-
"#{exercise_name.tr('-','_')}_cases"
|
14
|
+
"#{exercise_name.tr('-', '_')}_cases"
|
15
15
|
end
|
16
16
|
|
17
17
|
def proc_name(exercise_name)
|
@@ -19,7 +19,7 @@ module Generator
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def exercise_name(filename)
|
22
|
-
%r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_','-')
|
22
|
+
%r{([^/]*)_cases\.rb$}.match(filename).captures[0].tr('_', '-')
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -71,7 +71,7 @@ module Generator
|
|
71
71
|
end
|
72
72
|
|
73
73
|
class MinitestTestsFile < Writable
|
74
|
-
def generate(template:,values:)
|
74
|
+
def generate(template:, values:)
|
75
75
|
content = ERB.new(template, nil, '<>').result values.get_binding
|
76
76
|
save(content)
|
77
77
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Generator
|
2
2
|
# Contains methods accessible to the ERB template
|
3
3
|
class TemplateValues
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :abbreviated_commit_hash, :version, :test_cases
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@
|
6
|
+
def initialize(abbreviated_commit_hash:, version:, test_cases:)
|
7
|
+
@abbreviated_commit_hash = abbreviated_commit_hash
|
8
8
|
@version = version
|
9
9
|
@test_cases = test_cases
|
10
10
|
end
|
@@ -16,20 +16,11 @@ module Generator
|
|
16
16
|
|
17
17
|
module TemplateValuesFactory
|
18
18
|
def template_values
|
19
|
-
# These are needed by the 'ExerciseCases' classes
|
20
|
-
# TODO: move these into the individual classes
|
21
|
-
require 'ostruct'
|
22
|
-
require 'json'
|
23
19
|
require cases_require_name
|
24
20
|
|
25
|
-
# Compensate for the version.next that appears in template files.
|
26
|
-
# TODO: remove the .next from the template files and remove compensation
|
27
|
-
compensated_version = version - 1
|
28
|
-
|
29
21
|
TemplateValues.new(
|
30
|
-
|
31
|
-
|
32
|
-
version: compensated_version,
|
22
|
+
abbreviated_commit_hash: canonical_data.abbreviated_commit_hash,
|
23
|
+
version: version,
|
33
24
|
test_cases: test_cases_proc.call(canonical_data.to_s)
|
34
25
|
)
|
35
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'exercise_cases'
|
2
|
+
|
1
3
|
class GrainsCase < OpenStruct
|
2
4
|
def test_name
|
3
5
|
'test_%s' % description.downcase.tr_s(' ', '_')
|
@@ -14,7 +16,7 @@ class GrainsCase < OpenStruct
|
|
14
16
|
private
|
15
17
|
|
16
18
|
def underscore_format(number)
|
17
|
-
number.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse
|
19
|
+
number.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
require_relative 'alpha'
|
6
6
|
|
7
|
-
# Common test data version: <%=
|
7
|
+
# Common test data version: <%= abbreviated_commit_hash %>
|
8
8
|
class AlphaTest < Minitest::Test<% test_cases.each do |test_case| %>
|
9
9
|
def <%= test_case.name %>
|
10
10
|
<%= test_case.skip %>
|
@@ -15,6 +15,6 @@ class AlphaTest < Minitest::Test<% test_cases.each do |test_case| %>
|
|
15
15
|
<%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
|
16
16
|
def test_bookkeeping
|
17
17
|
skip
|
18
|
-
assert_equal <%= version
|
18
|
+
assert_equal <%= version %>, BookKeeping::VERSION
|
19
19
|
end
|
20
20
|
end
|
@@ -16,7 +16,7 @@ module Generator
|
|
16
16
|
|
17
17
|
def test_invalid_metadata_repository_outputs_message_to_stderr
|
18
18
|
paths = Paths.new(metadata: 'test/fixtures/nonexistent', track: nil)
|
19
|
-
expected_stderr = <<-MESSAGE.gsub(/^ {6}/,'')
|
19
|
+
expected_stderr = <<-MESSAGE.gsub(/^ {6}/, '')
|
20
20
|
'x-common' repository not found.
|
21
21
|
Try running the command:
|
22
22
|
git clone https://github.com/exercism/x-common.git "test/fixtures/nonexistent"
|
@@ -2,26 +2,26 @@ require_relative '../test_helper'
|
|
2
2
|
|
3
3
|
module Generator
|
4
4
|
class TestCasesValuesTest < Minitest::Test
|
5
|
-
def
|
6
|
-
|
7
|
-
subject = TemplateValues.new(
|
8
|
-
assert_equal
|
5
|
+
def test_abbreviated_commit_hash
|
6
|
+
expected_abbreviated_commit_hash = '1234567'
|
7
|
+
subject = TemplateValues.new(abbreviated_commit_hash: expected_abbreviated_commit_hash, version: nil, test_cases: nil)
|
8
|
+
assert_equal expected_abbreviated_commit_hash, subject.abbreviated_commit_hash
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_version
|
12
12
|
expected_version = '1234567'
|
13
|
-
subject = TemplateValues.new(version: expected_version,
|
13
|
+
subject = TemplateValues.new(version: expected_version, abbreviated_commit_hash: nil, test_cases: nil)
|
14
14
|
assert_equal expected_version, subject.version
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_test_cases
|
18
18
|
expected_test_cases = 'should be TemplateValues class'
|
19
|
-
subject = TemplateValues.new(test_cases: expected_test_cases,
|
19
|
+
subject = TemplateValues.new(test_cases: expected_test_cases, abbreviated_commit_hash: nil, version: nil)
|
20
20
|
assert_equal expected_test_cases, subject.test_cases
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_get_binding
|
24
|
-
subject = TemplateValues.new(
|
24
|
+
subject = TemplateValues.new(abbreviated_commit_hash: nil, version: nil, test_cases: nil)
|
25
25
|
assert_instance_of Binding, subject.get_binding
|
26
26
|
end
|
27
27
|
end
|
data/tracks/rust/.travis.yml
CHANGED
@@ -6,6 +6,12 @@ if [ -z "$DENYWARNINGS" ]; then
|
|
6
6
|
set -e
|
7
7
|
fi
|
8
8
|
|
9
|
+
if [ -n "$BENCHMARK" ]; then
|
10
|
+
files=exercises/*/benches
|
11
|
+
else
|
12
|
+
files=exercises/*/tests
|
13
|
+
fi
|
14
|
+
|
9
15
|
tmp=${TMPDIR:-/tmp/}
|
10
16
|
mkdir "${tmp}exercises"
|
11
17
|
|
@@ -13,7 +19,7 @@ exitcode=0
|
|
13
19
|
|
14
20
|
# An exercise worth testing is defined here as any top level directory with
|
15
21
|
# a 'tests' directory
|
16
|
-
for exercise in
|
22
|
+
for exercise in $files; do
|
17
23
|
# This assumes that exercises are only one directory deep
|
18
24
|
# and that the primary module is named the same as the directory
|
19
25
|
directory=$(dirname "${exercise}");
|
@@ -38,7 +44,10 @@ for exercise in exercises/*/tests; do
|
|
38
44
|
sed -i '/\[ignore\]/d' $test
|
39
45
|
done
|
40
46
|
|
41
|
-
|
47
|
+
# Run benchmarks instead of tests when enabled.
|
48
|
+
if [ -n "$BENCHMARK" ]; then
|
49
|
+
cargo bench
|
50
|
+
elif [ -n "$DENYWARNINGS" ]; then
|
42
51
|
sed -i -e '1i #![deny(warnings)]' src/lib.rs
|
43
52
|
|
44
53
|
# No-run mode so we see no test output.
|
data/tracks/rust/config.json
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
pub fn is_valid(candidate: &str) -> bool {
|
2
|
+
if candidate.chars().any(|c| c.is_alphabetic()) || candidate.chars().count() == 1 {
|
3
|
+
return false;
|
4
|
+
}
|
5
|
+
|
6
|
+
candidate.chars()
|
7
|
+
.filter_map(|c| c.to_digit(10))
|
8
|
+
.rev()
|
9
|
+
.enumerate()
|
10
|
+
.map(|(index, digit)| if index % 2 == 0 { digit } else { digit * 2 })
|
11
|
+
.map(|digit| if digit > 9 { digit - 9 } else { digit })
|
12
|
+
.sum::<u32>() % 10 == 0
|
13
|
+
}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
extern crate luhn;
|
2
|
+
|
3
|
+
use luhn::*;
|
4
|
+
|
5
|
+
#[test]
|
6
|
+
fn single_digit_string_is_invalid() {
|
7
|
+
assert!(!is_valid("1"));
|
8
|
+
}
|
9
|
+
|
10
|
+
#[test]
|
11
|
+
#[ignore]
|
12
|
+
fn single_zero_string_is_invalid() {
|
13
|
+
assert!(!is_valid("0"));
|
14
|
+
}
|
15
|
+
|
16
|
+
#[test]
|
17
|
+
#[ignore]
|
18
|
+
fn valid_canadian_sin_is_valid() {
|
19
|
+
assert!(is_valid("046 454 286"));
|
20
|
+
}
|
21
|
+
|
22
|
+
#[test]
|
23
|
+
#[ignore]
|
24
|
+
fn invalid_canadian_sin_is_invalid() {
|
25
|
+
assert!(!is_valid("046 454 287"));
|
26
|
+
}
|
27
|
+
|
28
|
+
#[test]
|
29
|
+
#[ignore]
|
30
|
+
fn invalid_credit_card_is_invalid() {
|
31
|
+
assert!(!is_valid("8273 1232 7352 0569"));
|
32
|
+
}
|
33
|
+
|
34
|
+
#[test]
|
35
|
+
#[ignore]
|
36
|
+
fn strings_that_contain_non_digits_are_invalid() {
|
37
|
+
assert!(!is_valid("046a 454 286"));
|
38
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Parallel Letter Frequency in Rust
|
2
|
+
|
3
|
+
Learn more about concurrency in Rust here:
|
4
|
+
|
5
|
+
- [Concurrency](https://doc.rust-lang.org/book/concurrency.html)
|
6
|
+
|
7
|
+
## Bonus
|
8
|
+
|
9
|
+
This exercise also includes a benchmark, with a sequential implementation as a
|
10
|
+
baseline. You can compare your solution to the benchmark. Observe the
|
11
|
+
effect different size inputs have on the performance of each. Can you
|
12
|
+
surpass the benchmark using concurrent programming techniques?
|
13
|
+
|
14
|
+
As of this writing, test::Bencher is unstable and only available on
|
15
|
+
*nightly* Rust. Run the benchmarks with Cargo:
|
16
|
+
|
17
|
+
```
|
18
|
+
cargo bench
|
19
|
+
```
|
20
|
+
|
21
|
+
If you are using rustup.rs:
|
22
|
+
|
23
|
+
```
|
24
|
+
rustup run nightly cargo bench
|
25
|
+
```
|
26
|
+
|
27
|
+
- [Benchmark tests](https://doc.rust-lang.org/book/benchmark-tests.html)
|
28
|
+
|
29
|
+
Learn more about nightly Rust:
|
30
|
+
|
31
|
+
- [Nightly Rust](https://doc.rust-lang.org/book/nightly-rust.html)
|
32
|
+
- [Rustup: Working with nightly](https://github.com/rust-lang-nursery/rustup.rs#working-with-nightly-rust)
|