trackler 2.1.0.24 → 2.1.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/CONTRIBUTING.md +5 -8
- data/README.md +7 -7
- data/common/CONTRIBUTING.md +0 -5
- data/common/exercises/accumulate/description.md +4 -1
- data/common/exercises/acronym/description.md +1 -1
- data/common/exercises/bank-account/description.md +2 -1
- data/common/exercises/book-store/description.md +2 -5
- data/common/exercises/bracket-push/description.md +2 -4
- data/common/exercises/change/description.md +2 -5
- data/common/exercises/circular-buffer/description.md +0 -2
- data/common/exercises/clock/description.md +0 -2
- data/common/exercises/collatz-conjecture/canonical-data.json +36 -0
- data/common/exercises/collatz-conjecture/description.md +25 -0
- data/common/exercises/collatz-conjecture/metadata.yml +4 -0
- data/common/exercises/counter/description.md +1 -2
- data/common/exercises/diamond/description.md +0 -4
- data/common/exercises/flatten-array/description.md +1 -1
- data/common/exercises/grade-school/description.md +2 -1
- data/common/exercises/grains/description.md +2 -1
- data/common/exercises/grep/description.md +3 -2
- data/common/exercises/kindergarten-garden/description.md +2 -1
- data/common/exercises/largest-series-product/description.md +2 -1
- data/common/exercises/matrix/description.md +2 -1
- data/common/exercises/nucleotide-codons/description.md +2 -1
- data/common/exercises/ocr-numbers/description.md +2 -1
- data/common/exercises/octal/description.md +3 -1
- data/common/exercises/pangram/description.md +2 -1
- data/common/exercises/perfect-numbers/description.md +2 -1
- data/common/exercises/poker/description.md +0 -2
- data/common/exercises/protein-translation/description.md +3 -2
- data/common/exercises/proverb/description.md +2 -1
- data/common/exercises/pythagorean-triplet/description.md +4 -2
- data/common/exercises/queen-attack/description.md +2 -1
- data/common/exercises/rectangles/description.md +1 -3
- data/common/exercises/rotational-cipher/description.md +0 -4
- data/common/exercises/scale-generator/description.md +0 -2
- data/common/exercises/secret-handshake/description.md +2 -2
- data/common/exercises/series/description.md +2 -1
- data/common/exercises/sieve/description.md +2 -1
- data/common/exercises/space-age/description.md +0 -2
- data/common/exercises/strain/description.md +4 -5
- data/common/exercises/sublist/description.md +3 -6
- data/common/exercises/sum-of-multiples/description.md +2 -1
- data/common/exercises/tournament/description.md +4 -3
- data/common/exercises/transpose/description.md +1 -3
- data/common/exercises/trinary/description.md +2 -1
- data/common/exercises/two-bucket/description.md +1 -3
- data/common/exercises/two-fer/canonical-data.json +24 -0
- data/common/exercises/two-fer/description.md +40 -0
- data/common/exercises/two-fer/metadata.yml +4 -0
- data/common/exercises/word-search/description.md +2 -4
- data/common/exercises/zebra-puzzle/description.md +1 -1
- data/lib/trackler.rb +10 -5
- data/lib/trackler/description.rb +2 -2
- data/lib/trackler/guaranteed_file.rb +15 -15
- data/lib/trackler/implementation.rb +5 -5
- data/lib/trackler/implementations.rb +2 -2
- data/lib/trackler/metadata.rb +2 -2
- data/lib/trackler/problem.rb +2 -96
- data/lib/trackler/problems.rb +3 -48
- data/lib/trackler/specification.rb +101 -0
- data/lib/trackler/specifications.rb +52 -0
- data/lib/trackler/track.rb +6 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/LICENSE +21 -0
- data/tracks/bash/README.md +0 -5
- data/tracks/c/LICENSE +21 -0
- data/tracks/c/README.md +0 -5
- data/tracks/clojure/LICENSE +2 -2
- data/tracks/clojure/README.org +0 -5
- data/tracks/clojure/config.json +5 -0
- data/tracks/clojure/exercises/sublist/project.clj +4 -0
- data/tracks/clojure/exercises/sublist/src/example.clj +19 -0
- data/tracks/clojure/exercises/sublist/sublist.mustache +9 -0
- data/tracks/clojure/exercises/sublist/test/sublist_test.clj +40 -0
- data/tracks/cpp/LICENSE +2 -2
- data/tracks/cpp/README.md +0 -5
- data/tracks/csharp/LICENSE +2 -2
- data/tracks/csharp/README.md +0 -5
- data/tracks/delphi/LICENSE +2 -2
- data/tracks/delphi/README.md +0 -5
- data/tracks/ecmascript/LICENSE +2 -2
- data/tracks/ecmascript/README.md +0 -5
- data/tracks/elisp/.travis.yml +7 -3
- data/tracks/elisp/LICENSE +2 -2
- data/tracks/elisp/README.org +3 -6
- data/tracks/elisp/bin/test-examples +27 -0
- data/tracks/elisp/config.json +10 -0
- data/tracks/elisp/docs/LEARNING.org +0 -3
- data/tracks/elisp/exercises/grains/example.el +18 -0
- data/tracks/elisp/exercises/grains/grains-test.el +38 -0
- data/tracks/elisp/exercises/grains/grains.el +10 -0
- data/tracks/elisp/exercises/phone-number/example.el +34 -0
- data/tracks/elisp/exercises/phone-number/phone-number-test.el +43 -0
- data/tracks/elisp/exercises/phone-number/phone-number.el +9 -0
- data/tracks/elixir/LICENSE +2 -2
- data/tracks/elixir/README.md +0 -5
- data/tracks/elm/LICENSE +2 -2
- data/tracks/elm/README.md +0 -5
- data/tracks/erlang/LICENSE +2 -2
- data/tracks/erlang/README.md +0 -5
- data/tracks/erlang/SETUP.md +7 -0
- data/tracks/erlang/exercises/rotational-cipher/rebar.config +5 -5
- data/tracks/erlang/exercises/rotational-cipher/test/rotational_cipher_tests.erl +18 -18
- data/tracks/factor/LICENSE +2 -2
- data/tracks/fortran/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- data/tracks/fortran/.gitignore +4 -0
- data/tracks/fortran/.travis.yml +17 -0
- data/tracks/fortran/LICENSE +21 -0
- data/tracks/fortran/Makefile +40 -0
- data/tracks/fortran/README.md +72 -0
- data/tracks/fortran/bin/fetch-configlet +32 -0
- data/tracks/fortran/config.json +32 -0
- data/tracks/{kotlin/SETUP.md → fortran/docs/ABOUT.md} +0 -0
- data/tracks/fortran/docs/INSTALLATION.md +0 -0
- data/tracks/fortran/docs/LEARNING.md +0 -0
- data/tracks/fortran/docs/RESOURCES.md +0 -0
- data/tracks/fortran/docs/TESTS.md +0 -0
- data/tracks/fortran/exercises/TRACK_HINTS.md +0 -0
- data/tracks/fortran/exercises/bob/bob.fun +114 -0
- data/tracks/fortran/exercises/bob/example.f90 +61 -0
- data/tracks/fortran/exercises/hello_world/example.f90 +9 -0
- data/tracks/fortran/exercises/hello_world/hello_world.fun +10 -0
- data/tracks/fortran/img/.keep +0 -0
- data/tracks/fsharp/LICENSE +2 -2
- data/tracks/fsharp/README.md +0 -5
- data/tracks/go/LICENSE +2 -2
- data/tracks/go/README.md +0 -5
- data/tracks/haskell/LICENSE +2 -2
- data/tracks/haskell/README.md +0 -5
- data/tracks/idris/LICENSE +2 -2
- data/tracks/idris/README.md +0 -5
- data/tracks/java/LICENSE +2 -2
- data/tracks/java/README.md +0 -7
- data/tracks/java/{SETUP.md → TRACK_HINTS.md} +0 -0
- data/tracks/java/config.json +5 -0
- data/tracks/java/exercises/_template/build.gradle +1 -0
- data/tracks/java/exercises/accumulate/build.gradle +1 -0
- data/tracks/java/exercises/acronym/build.gradle +1 -0
- data/tracks/java/exercises/all-your-base/build.gradle +1 -0
- data/tracks/java/exercises/allergies/build.gradle +1 -0
- data/tracks/java/exercises/anagram/build.gradle +1 -0
- data/tracks/java/exercises/atbash-cipher/build.gradle +1 -0
- data/tracks/java/exercises/beer-song/build.gradle +1 -0
- data/tracks/java/exercises/binary-search/build.gradle +1 -0
- data/tracks/java/exercises/binary/build.gradle +1 -0
- data/tracks/java/exercises/bob/build.gradle +1 -0
- data/tracks/java/exercises/book-store/build.gradle +1 -0
- data/tracks/java/exercises/bracket-push/build.gradle +1 -0
- data/tracks/java/exercises/change/build.gradle +1 -0
- data/tracks/java/exercises/clock/build.gradle +2 -1
- data/tracks/java/exercises/collatz-conjecture/build.gradle +18 -0
- data/tracks/java/exercises/collatz-conjecture/src/example/java/CollatzCalculator.java +19 -0
- data/tracks/java/exercises/collatz-conjecture/src/main/java/CollatzCalculator.java +7 -0
- data/tracks/java/exercises/collatz-conjecture/src/test/java/CollatzCalculatorTest.java +59 -0
- data/tracks/java/exercises/crypto-square/build.gradle +1 -0
- data/tracks/java/exercises/diamond/build.gradle +1 -0
- data/tracks/java/exercises/diamond/src/example/java/DiamondPrinter.java +4 -4
- data/tracks/java/exercises/diamond/src/test/java/DiamondPrinterTest.java +6 -2
- data/tracks/java/exercises/difference-of-squares/build.gradle +1 -0
- data/tracks/java/exercises/difference-of-squares/src/main/java/.keep +0 -0
- data/tracks/java/exercises/etl/build.gradle +1 -0
- data/tracks/java/exercises/flatten-array/build.gradle +1 -0
- data/tracks/java/exercises/gigasecond/build.gradle +1 -0
- data/tracks/java/exercises/grade-school/build.gradle +1 -0
- data/tracks/java/exercises/hamming/build.gradle +1 -0
- data/tracks/java/exercises/hexadecimal/build.gradle +1 -0
- data/tracks/java/exercises/isogram/build.gradle +1 -0
- data/tracks/java/exercises/kindergarten-garden/build.gradle +1 -0
- data/tracks/java/exercises/largest-series-product/build.gradle +1 -0
- data/tracks/java/exercises/linked-list/build.gradle +1 -0
- data/tracks/java/exercises/luhn/build.gradle +1 -0
- data/tracks/java/exercises/matrix/build.gradle +2 -1
- data/tracks/java/exercises/meetup/build.gradle +1 -0
- data/tracks/java/exercises/minesweeper/build.gradle +1 -0
- data/tracks/java/exercises/nth-prime/build.gradle +1 -0
- data/tracks/java/exercises/ocr-numbers/build.gradle +1 -0
- data/tracks/java/exercises/octal/build.gradle +1 -0
- data/tracks/java/exercises/pangram/build.gradle +1 -0
- data/tracks/java/exercises/pascals-triangle/build.gradle +1 -0
- data/tracks/java/exercises/perfect-numbers/build.gradle +1 -0
- data/tracks/java/exercises/phone-number/build.gradle +1 -0
- data/tracks/java/exercises/pig-latin/build.gradle +1 -0
- data/tracks/java/exercises/queen-attack/build.gradle +1 -0
- data/tracks/java/exercises/raindrops/build.gradle +1 -0
- data/tracks/java/exercises/rectangles/build.gradle +1 -0
- data/tracks/java/exercises/rna-transcription/build.gradle +1 -0
- data/tracks/java/exercises/robot-simulator/build.gradle +1 -0
- data/tracks/java/exercises/roman-numerals/build.gradle +1 -0
- data/tracks/java/exercises/run-length-encoding/build.gradle +1 -0
- data/tracks/java/exercises/saddle-points/build.gradle +1 -0
- data/tracks/java/exercises/scrabble-score/build.gradle +1 -0
- data/tracks/java/exercises/secret-handshake/build.gradle +1 -0
- data/tracks/java/exercises/series/build.gradle +1 -0
- data/tracks/java/exercises/settings.gradle +1 -0
- data/tracks/java/exercises/sieve/build.gradle +1 -0
- data/tracks/java/exercises/simple-cipher/build.gradle +1 -0
- data/tracks/java/exercises/simple-linked-list/build.gradle +1 -0
- data/tracks/java/exercises/space-age/build.gradle +1 -0
- data/tracks/java/exercises/strain/build.gradle +1 -0
- data/tracks/java/exercises/sublist/build.gradle +1 -0
- data/tracks/java/exercises/sum-of-multiples/build.gradle +1 -0
- data/tracks/java/exercises/triangle/build.gradle +1 -0
- data/tracks/java/exercises/trinary/build.gradle +1 -0
- data/tracks/java/exercises/twelve-days/build.gradle +2 -1
- data/tracks/java/exercises/word-count/build.gradle +1 -0
- data/tracks/java/exercises/wordy/build.gradle +1 -0
- data/tracks/javascript/LICENSE +2 -2
- data/tracks/javascript/README.md +0 -5
- data/tracks/julia/LICENSE +2 -2
- data/tracks/kotlin/LICENSE +2 -2
- data/tracks/kotlin/README.md +0 -7
- data/tracks/kotlin/TRACK_HINTS.md +1 -0
- data/tracks/kotlin/exercises/phone-number/src/example/kotlin/PhoneNumber.kt +1 -1
- data/tracks/kotlin/exercises/phone-number/src/test/kotlin/PhoneNumberTest.kt +7 -8
- data/tracks/kotlin/exercises/rna-transcription/src/test/kotlin/RnaTranscriptionTest.kt +6 -6
- data/tracks/lfe/LICENSE +2 -2
- data/tracks/lfe/README.md +0 -5
- data/tracks/lisp/LICENSE +2 -2
- data/tracks/lisp/README.md +0 -5
- data/tracks/lua/LICENSE +2 -2
- data/tracks/lua/README.md +0 -5
- data/tracks/mips/LICENSE +2 -2
- data/tracks/mips/README.md +0 -5
- data/tracks/objective-c/LICENSE +2 -2
- data/tracks/objective-c/README.md +0 -5
- data/tracks/ocaml/LICENSE +2 -2
- data/tracks/ocaml/README.md +0 -5
- data/tracks/ocaml/config.json +54 -25
- data/tracks/ocaml/exercises/forth/.merlin +5 -0
- data/tracks/ocaml/exercises/forth/Makefile +11 -0
- data/tracks/ocaml/exercises/forth/example.ml +89 -0
- data/tracks/ocaml/exercises/forth/forth.mli +1 -0
- data/tracks/ocaml/exercises/forth/test.ml +147 -0
- data/tracks/ocaml/exercises/react/.merlin +5 -0
- data/tracks/ocaml/exercises/react/HINT.md +3 -0
- data/tracks/ocaml/exercises/react/Makefile +11 -0
- data/tracks/ocaml/exercises/react/example.ml +106 -0
- data/tracks/ocaml/exercises/react/react.mli +26 -0
- data/tracks/ocaml/exercises/react/test.ml +157 -0
- data/tracks/ocaml/tools/test-generator/src/special_cases.ml +5 -2
- data/tracks/ocaml/tools/test-generator/templates/forth/template.ml +114 -0
- data/tracks/perl5/LICENSE +2 -2
- data/tracks/perl6/LICENSE +2 -2
- data/tracks/perl6/README.md +0 -5
- data/tracks/perl6/config.json +5 -0
- data/tracks/perl6/exercises/clock/Example.pm6 +2 -2
- data/tracks/perl6/exercises/flatten-array/Example.pm6 +13 -0
- data/tracks/perl6/exercises/flatten-array/FlattenArray.pm6 +4 -0
- data/tracks/perl6/exercises/flatten-array/example.yaml +6 -0
- data/tracks/perl6/exercises/flatten-array/flatten-array.t +80 -0
- data/tracks/php/LICENSE +2 -2
- data/tracks/php/README.md +0 -5
- data/tracks/powershell/.travis.yml +1 -0
- data/tracks/python/LICENSE +2 -2
- data/tracks/python/README.md +0 -5
- data/tracks/python/config.json +8 -0
- data/tracks/python/exercises/protein-translation/example.py +25 -0
- data/tracks/python/exercises/protein-translation/protein_translation.py +6 -0
- data/tracks/python/exercises/protein-translation/protein_translation_test.py +59 -0
- data/tracks/r/LICENSE +2 -2
- data/tracks/r/README.md +0 -5
- data/tracks/racket/LICENSE +2 -2
- data/tracks/racket/README.md +0 -5
- data/tracks/racket/config.json +5 -0
- data/tracks/racket/exercises/acronym/acronym-test.rkt +40 -0
- data/tracks/racket/exercises/acronym/acronym.rkt +3 -0
- data/tracks/racket/exercises/acronym/example.rkt +25 -0
- data/tracks/racket/exercises/grep/example.rkt +60 -26
- data/tracks/racket/exercises/grep/grep-test.rkt +154 -17
- data/tracks/racket/exercises/grep/grep.rkt +1 -18
- data/tracks/racket/exercises/grep/iliad.txt +9 -0
- data/tracks/racket/exercises/grep/midsummer-night.txt +7 -0
- data/tracks/racket/exercises/grep/paradise-lost.txt +8 -0
- data/tracks/ruby/README.md +4 -1
- data/tracks/ruby/exercises/acronym/.meta/.version +1 -1
- data/tracks/ruby/exercises/acronym/.meta/solutions/acronym.rb +1 -1
- data/tracks/ruby/exercises/acronym/acronym_test.rb +2 -7
- data/tracks/ruby/exercises/anagram/.meta/generator/anagram_case.rb +1 -1
- data/tracks/ruby/exercises/beer-song/.meta/generator/beer_song_case.rb +1 -1
- data/tracks/ruby/exercises/clock/.meta/generator/clock_case.rb +1 -1
- data/tracks/ruby/exercises/connect/.meta/generator/connect_case.rb +0 -3
- data/tracks/ruby/exercises/connect/.meta/generator/test_template.erb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/.version +1 -1
- data/tracks/ruby/exercises/difference-of-squares/.meta/solutions/difference_of_squares.rb +1 -1
- data/tracks/ruby/exercises/difference-of-squares/difference_of_squares_test.rb +12 -17
- data/tracks/ruby/exercises/triangle/.meta/generator/triangle_case.rb +10 -2
- data/tracks/ruby/exercises/triangle/triangle_test.rb +17 -17
- data/tracks/ruby/exercises/wordy/.meta/generator/wordy_case.rb +1 -1
- data/tracks/ruby/lib/generator/case_values.rb +1 -1
- data/tracks/ruby/lib/generator/exercise_case.rb +16 -2
- data/tracks/ruby/lib/generator/exercise_case/assertion.rb +4 -4
- data/tracks/ruby/test/fixtures/xruby/exercises/alpha/.meta/generator/alpha_case.rb +1 -1
- data/tracks/ruby/test/generator/case_values_test.rb +28 -7
- data/tracks/ruby/test/generator/exercise_case/assertion_test.rb +7 -7
- data/tracks/ruby/test/generator/exercise_case_test.rb +21 -25
- data/tracks/ruby/test/wordy_cases_test.rb +4 -4
- data/tracks/rust/LICENSE +2 -2
- data/tracks/rust/README.md +0 -5
- data/tracks/rust/config.json +1 -0
- data/tracks/rust/exercises/etl/Cargo.toml +1 -1
- data/tracks/rust/exercises/etl/example.rs +2 -2
- data/tracks/rust/exercises/etl/tests/etl.rs +26 -32
- data/tracks/rust/exercises/forth/tests/forth.rs +20 -22
- data/tracks/rust/exercises/minesweeper/Cargo.toml +1 -1
- data/tracks/rust/exercises/minesweeper/example.rs +3 -0
- data/tracks/rust/exercises/minesweeper/tests/minesweeper.rs +44 -46
- data/tracks/rust/exercises/raindrops/Cargo.toml +1 -1
- data/tracks/rust/exercises/raindrops/tests/raindrops.rs +12 -0
- data/tracks/rust/exercises/rna-transcription/Cargo.toml +1 -1
- data/tracks/rust/exercises/rna-transcription/example.rs +13 -9
- data/tracks/rust/exercises/rna-transcription/tests/rna-transcription.rs +23 -5
- data/tracks/scala/LICENSE +2 -2
- data/tracks/scala/README.md +0 -5
- data/tracks/scheme/LICENSE +2 -2
- data/tracks/scheme/README.org +0 -6
- data/tracks/swift/Dangerfile +1 -1
- data/tracks/swift/LICENSE +2 -2
- data/tracks/swift/README.md +0 -6
- data/tracks/vbnet/.travis.yml +1 -0
- data/tracks/vimscript/.travis.yml +4 -0
- data/tracks/vimscript/.vintrc.yaml +5 -0
- data/tracks/vimscript/TRACK_HINTS.md +19 -1
- data/tracks/vimscript/bin/pre-push +18 -0
- data/tracks/vimscript/config.json +8 -1
- data/tracks/vimscript/docs/ABOUT.md +7 -6
- data/tracks/vimscript/docs/TESTS.md +4 -4
- data/tracks/vimscript/exercises/allergies/allergies.vader +68 -0
- data/tracks/vimscript/exercises/allergies/allergies.vim +29 -0
- data/tracks/vimscript/exercises/allergies/example.vim +23 -0
- data/tracks/vimscript/lib/generate.vim +89 -0
- metadata +81 -6
- data/tracks/java/exercises/difference-of-squares/src/main/java/DifferenceOfSquaresCalculator.java +0 -15
- data/tracks/ocaml/.vscode/launch.json +0 -13
@@ -4,43 +4,43 @@ module Generator
|
|
4
4
|
class ExerciseCase
|
5
5
|
class AssertionTest < Minitest::Test
|
6
6
|
def test_assert
|
7
|
-
test_case = OpenStruct.new(expected
|
7
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => true}))
|
8
8
|
test_case.extend(Assertion)
|
9
9
|
assert_equal 'assert', test_case.assert
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_refute
|
13
|
-
test_case = OpenStruct.new(expected
|
13
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => false}))
|
14
14
|
test_case.extend(Assertion)
|
15
15
|
assert_equal 'refute', test_case.assert
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_assert_equal
|
19
|
-
test_case = OpenStruct.new(expected
|
19
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => 2}))
|
20
20
|
test_case.extend(Assertion)
|
21
21
|
assert_equal "assert_equal 2, 4", test_case.assert_equal { 1 + 3 }
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_assert_equal_when_nil
|
25
|
-
test_case = OpenStruct.new(expected
|
25
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => nil}))
|
26
26
|
test_case.extend(Assertion)
|
27
27
|
assert_equal "assert_nil 4", test_case.assert_equal { 1 + 3 }
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_raises_error
|
31
|
-
test_case = OpenStruct.new(expected
|
31
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => -1}))
|
32
32
|
test_case.extend(Assertion)
|
33
33
|
assert test_case.raises_error?
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_does_not_raise_error
|
37
|
-
test_case = OpenStruct.new(expected
|
37
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({'expected' => 'cute kitties'}))
|
38
38
|
test_case.extend(Assertion)
|
39
39
|
refute test_case.raises_error?
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_assert_raises
|
43
|
-
test_case = OpenStruct.new
|
43
|
+
test_case = ExerciseCase.new(canonical: OpenStruct.new({}))
|
44
44
|
test_case.extend(Assertion)
|
45
45
|
assert_equal(
|
46
46
|
"assert_raises(ArgumentError) { 4 }",
|
@@ -3,45 +3,41 @@ require_relative '../test_helper'
|
|
3
3
|
module Generator
|
4
4
|
class ExerciseCaseTest < Minitest::Test
|
5
5
|
def test_name
|
6
|
-
|
6
|
+
subject = ExerciseCase.new(canonical: OpenStruct.new(description: 'foo'))
|
7
|
+
assert_equal 'test_foo', subject.name
|
7
8
|
end
|
8
9
|
|
9
10
|
def test_skipped_index_zero
|
10
|
-
assert_equal '# skip', ExerciseCase.new.skipped(0)
|
11
|
+
assert_equal '# skip', ExerciseCase.new(canonical: nil).skipped(0)
|
11
12
|
end
|
12
13
|
|
13
14
|
def test_skipped_index_nonzero
|
14
|
-
assert_equal 'skip', ExerciseCase.new.skipped(1)
|
15
|
+
assert_equal 'skip', ExerciseCase.new(canonical: nil).skipped(1)
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
expected = "foo\n bar"
|
24
|
-
assert_equal expected, MultiLineCase.new.workload
|
18
|
+
def test_forwarding_to_canonical
|
19
|
+
mock_canonical = Minitest::Mock.new
|
20
|
+
mock_canonical.expect :key, 'fake value'
|
21
|
+
subject = ExerciseCase.new(canonical: mock_canonical)
|
22
|
+
subject.key
|
23
|
+
mock_canonical.verify
|
25
24
|
end
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
def test_method_mising_calls_super
|
27
|
+
subject = ExerciseCase.new(canonical: nil)
|
28
|
+
assert_raises NoMethodError do
|
29
|
+
subject.key
|
30
30
|
end
|
31
31
|
end
|
32
|
-
def test_indent_multiline_workloads_with_blank_lines
|
33
|
-
expected = "foo\n\n bar\n"
|
34
|
-
assert_equal expected, BlankLineCase.new.workload
|
35
|
-
end
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
33
|
+
def test_true_respond_to?
|
34
|
+
subject = ExerciseCase.new(canonical: OpenStruct.new(key: 'value'))
|
35
|
+
assert subject.respond_to?(:key)
|
41
36
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
|
38
|
+
def test_false_respond_to?
|
39
|
+
subject = ExerciseCase.new(canonical: OpenStruct.new())
|
40
|
+
refute subject.respond_to?(:key)
|
45
41
|
end
|
46
42
|
end
|
47
43
|
end
|
@@ -4,7 +4,7 @@ require_relative '../exercises/wordy/.meta/generator/wordy_case'
|
|
4
4
|
|
5
5
|
class WordyCaseTest < Minitest::Test
|
6
6
|
def test_workload_with_expected_and_no_message
|
7
|
-
test_case = WordyCase.new(expected: 1, input: 1)
|
7
|
+
test_case = WordyCase.new(canonical: OpenStruct.new(expected: 1, input: 1))
|
8
8
|
|
9
9
|
expected_workload = [
|
10
10
|
'question = \'1\'',
|
@@ -15,7 +15,7 @@ class WordyCaseTest < Minitest::Test
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_workload_with_expected_and_message
|
18
|
-
test_case = WordyCase.new(expected: 1, input: 'What is -3 plus 7 multiplied by -2?')
|
18
|
+
test_case = WordyCase.new(canonical: OpenStruct.new(expected: 1, input: 'What is -3 plus 7 multiplied by -2?'))
|
19
19
|
message = test_case.send(:message)
|
20
20
|
|
21
21
|
expected_workload = [
|
@@ -28,8 +28,8 @@ class WordyCaseTest < Minitest::Test
|
|
28
28
|
assert_equal expected_workload, test_case.workload
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
test_case = WordyCase.new(input: 1)
|
31
|
+
def test_workload_with_expected_false
|
32
|
+
test_case = WordyCase.new(canonical: OpenStruct.new(input: 1, expected: false))
|
33
33
|
|
34
34
|
expected_workload = [
|
35
35
|
'question = \'1\'',
|
data/tracks/rust/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT License
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2017 Exercism, Inc
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/tracks/rust/README.md
CHANGED
@@ -9,11 +9,6 @@ Exercism exercises in Rust
|
|
9
9
|
|
10
10
|
Please see the [contributing guide](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md)
|
11
11
|
|
12
|
-
## License
|
13
|
-
|
14
|
-
The MIT License (MIT)
|
15
|
-
|
16
|
-
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com
|
17
12
|
|
18
13
|
## Rust icon
|
19
14
|
The Rust Logo is created by the Mozilla Corporation, and has been released under the [Creative Commons Attribution 4.0 International license](https://creativecommons.org/licenses/by/4.0/).
|
data/tracks/rust/config.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
use std::ascii::AsciiExt;
|
2
2
|
use std::collections::BTreeMap;
|
3
3
|
|
4
|
-
pub fn transform(input: &BTreeMap<i32, Vec<
|
4
|
+
pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
|
5
5
|
input.iter().flat_map(|(&n, vec)| {
|
6
|
-
vec.iter().map(move |
|
6
|
+
vec.iter().map(move |c| (c.to_ascii_lowercase(), n))
|
7
7
|
}).collect()
|
8
8
|
}
|
@@ -5,11 +5,11 @@ use std::collections::BTreeMap;
|
|
5
5
|
#[test]
|
6
6
|
fn test_transform_one_value() {
|
7
7
|
let input = input_from(&[
|
8
|
-
(1, vec!(
|
8
|
+
(1, vec!('A')),
|
9
9
|
]);
|
10
10
|
|
11
11
|
let expected = expected_from(&[
|
12
|
-
(
|
12
|
+
('a', 1),
|
13
13
|
]);
|
14
14
|
|
15
15
|
assert_eq!(expected, etl::transform(&input));
|
@@ -19,11 +19,11 @@ fn test_transform_one_value() {
|
|
19
19
|
#[ignore]
|
20
20
|
fn test_transform_more_values() {
|
21
21
|
let input = input_from(&[
|
22
|
-
(1, vec!(
|
22
|
+
(1, vec!('A', 'E', 'I', 'O', 'U')),
|
23
23
|
]);
|
24
24
|
|
25
25
|
let expected = expected_from(&[
|
26
|
-
(
|
26
|
+
('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1),
|
27
27
|
]);
|
28
28
|
|
29
29
|
assert_eq!(expected, etl::transform(&input));
|
@@ -33,13 +33,13 @@ fn test_transform_more_values() {
|
|
33
33
|
#[ignore]
|
34
34
|
fn test_more_keys() {
|
35
35
|
let input = input_from(&[
|
36
|
-
(1, vec!(
|
37
|
-
(2, vec!(
|
36
|
+
(1, vec!('A', 'E')),
|
37
|
+
(2, vec!('D', 'G')),
|
38
38
|
]);
|
39
39
|
|
40
40
|
let expected = expected_from(&[
|
41
|
-
(
|
42
|
-
(
|
41
|
+
('a', 1), ('e', 1),
|
42
|
+
('d', 2), ('g', 2),
|
43
43
|
]);
|
44
44
|
|
45
45
|
assert_eq!(expected, etl::transform(&input));
|
@@ -49,38 +49,32 @@ fn test_more_keys() {
|
|
49
49
|
#[ignore]
|
50
50
|
fn test_full_dataset() {
|
51
51
|
let input = input_from(&[
|
52
|
-
(1, vec!(
|
53
|
-
(2, vec!(
|
54
|
-
(3, vec!(
|
55
|
-
(4, vec!(
|
56
|
-
(5, vec!(
|
57
|
-
(8, vec!(
|
58
|
-
(10, vec!(
|
52
|
+
(1, vec!('A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T')),
|
53
|
+
(2, vec!('D', 'G')),
|
54
|
+
(3, vec!('B', 'C', 'M', 'P')),
|
55
|
+
(4, vec!('F', 'H', 'V', 'W', 'Y')),
|
56
|
+
(5, vec!('K')),
|
57
|
+
(8, vec!('J', 'X')),
|
58
|
+
(10, vec!('Q', 'Z')),
|
59
59
|
]);
|
60
60
|
|
61
61
|
let expected = expected_from(&[
|
62
|
-
(
|
63
|
-
(
|
64
|
-
(
|
65
|
-
(
|
66
|
-
(
|
67
|
-
(
|
68
|
-
(
|
62
|
+
('a', 1), ('b', 3), ('c', 3), ('d', 2),
|
63
|
+
('e', 1), ('f', 4), ('g', 2), ('h', 4),
|
64
|
+
('i', 1), ('j', 8), ('k', 5), ('l', 1),
|
65
|
+
('m', 3), ('n', 1), ('o', 1), ('p', 3),
|
66
|
+
('q', 10), ('r', 1), ('s', 1), ('t', 1),
|
67
|
+
('u', 1), ('v', 4), ('w', 4), ('x', 8),
|
68
|
+
('y', 4), ('z', 10),
|
69
69
|
]);
|
70
70
|
|
71
71
|
assert_eq!(expected, etl::transform(&input));
|
72
72
|
}
|
73
73
|
|
74
|
-
fn input_from(v: &[(i32, Vec
|
75
|
-
v.iter().
|
76
|
-
acc.insert(n, v.iter().map(|s| s.to_string()).collect());
|
77
|
-
acc
|
78
|
-
})
|
74
|
+
fn input_from(v: &[(i32, Vec<char>)]) -> BTreeMap<i32, Vec<char>> {
|
75
|
+
v.iter().cloned().collect()
|
79
76
|
}
|
80
77
|
|
81
|
-
fn expected_from(v: &[(
|
82
|
-
v.iter().
|
83
|
-
acc.insert(s.to_string(), n);
|
84
|
-
acc
|
85
|
-
})
|
78
|
+
fn expected_from(v: &[(char, i32)]) -> BTreeMap<char, i32> {
|
79
|
+
v.iter().cloned().collect()
|
86
80
|
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
#![allow(unused_must_use)]
|
2
|
-
|
3
1
|
extern crate forth;
|
4
2
|
|
5
3
|
use forth::{Forth, Error};
|
@@ -13,7 +11,7 @@ fn no_input_no_stack() {
|
|
13
11
|
#[ignore]
|
14
12
|
fn numbers_just_get_pushed_onto_the_stack() {
|
15
13
|
let mut f = Forth::new();
|
16
|
-
f.eval("1 2 3 4 5 -1");
|
14
|
+
assert!(f.eval("1 2 3 4 5 -1").is_ok());
|
17
15
|
assert_eq!("1 2 3 4 5 -1", f.format_stack());
|
18
16
|
}
|
19
17
|
|
@@ -22,7 +20,7 @@ fn numbers_just_get_pushed_onto_the_stack() {
|
|
22
20
|
fn non_word_characters_are_separators() {
|
23
21
|
let mut f = Forth::new();
|
24
22
|
// Note the Ogham Space Mark ( ), this is a spacing character.
|
25
|
-
f.eval("1\u{0000}2\u{0001}3\n4\r5 6\t7");
|
23
|
+
assert!(f.eval("1\u{0000}2\u{0001}3\n4\r5 6\t7").is_ok());
|
26
24
|
assert_eq!("1 2 3 4 5 6 7", f.format_stack());
|
27
25
|
}
|
28
26
|
|
@@ -30,7 +28,7 @@ fn non_word_characters_are_separators() {
|
|
30
28
|
#[ignore]
|
31
29
|
fn basic_arithmetic_1() {
|
32
30
|
let mut f = Forth::new();
|
33
|
-
f.eval("1 2 + 4 -");
|
31
|
+
assert!(f.eval("1 2 + 4 -").is_ok());
|
34
32
|
assert_eq!("-1", f.format_stack());
|
35
33
|
}
|
36
34
|
|
@@ -38,7 +36,7 @@ fn basic_arithmetic_1() {
|
|
38
36
|
#[ignore]
|
39
37
|
fn basic_arithmetic_2() {
|
40
38
|
let mut f = Forth::new();
|
41
|
-
f.eval("2 4 * 3 /");
|
39
|
+
assert!(f.eval("2 4 * 3 /").is_ok());
|
42
40
|
assert_eq!("2", f.format_stack());
|
43
41
|
}
|
44
42
|
|
@@ -96,7 +94,7 @@ fn division_by_zero() {
|
|
96
94
|
#[ignore]
|
97
95
|
fn dup() {
|
98
96
|
let mut f = Forth::new();
|
99
|
-
f.eval("1 DUP");
|
97
|
+
assert!(f.eval("1 DUP").is_ok());
|
100
98
|
assert_eq!("1 1", f.format_stack());
|
101
99
|
}
|
102
100
|
|
@@ -104,7 +102,7 @@ fn dup() {
|
|
104
102
|
#[ignore]
|
105
103
|
fn dup_case_insensitive() {
|
106
104
|
let mut f = Forth::new();
|
107
|
-
f.eval("1 Dup");
|
105
|
+
assert!(f.eval("1 Dup").is_ok());
|
108
106
|
assert_eq!("1 1", f.format_stack());
|
109
107
|
}
|
110
108
|
|
@@ -122,7 +120,7 @@ fn dup_error() {
|
|
122
120
|
#[ignore]
|
123
121
|
fn drop() {
|
124
122
|
let mut f = Forth::new();
|
125
|
-
f.eval("1 drop");
|
123
|
+
assert!(f.eval("1 drop").is_ok());
|
126
124
|
assert_eq!("", f.format_stack());
|
127
125
|
}
|
128
126
|
|
@@ -130,7 +128,7 @@ fn drop() {
|
|
130
128
|
#[ignore]
|
131
129
|
fn drop_with_two() {
|
132
130
|
let mut f = Forth::new();
|
133
|
-
f.eval("1 2 drop");
|
131
|
+
assert!(f.eval("1 2 drop").is_ok());
|
134
132
|
assert_eq!("1", f.format_stack());
|
135
133
|
}
|
136
134
|
|
@@ -148,7 +146,7 @@ fn drop_error() {
|
|
148
146
|
#[ignore]
|
149
147
|
fn swap() {
|
150
148
|
let mut f = Forth::new();
|
151
|
-
f.eval("1 2 swap");
|
149
|
+
assert!(f.eval("1 2 swap").is_ok());
|
152
150
|
assert_eq!("2 1", f.format_stack());
|
153
151
|
}
|
154
152
|
|
@@ -156,7 +154,7 @@ fn swap() {
|
|
156
154
|
#[ignore]
|
157
155
|
fn swap_with_three() {
|
158
156
|
let mut f = Forth::new();
|
159
|
-
f.eval("1 2 3 swap");
|
157
|
+
assert!(f.eval("1 2 3 swap").is_ok());
|
160
158
|
assert_eq!("1 3 2", f.format_stack());
|
161
159
|
}
|
162
160
|
|
@@ -178,7 +176,7 @@ fn swap_error() {
|
|
178
176
|
#[ignore]
|
179
177
|
fn over() {
|
180
178
|
let mut f = Forth::new();
|
181
|
-
f.eval("1 2 over");
|
179
|
+
assert!(f.eval("1 2 over").is_ok());
|
182
180
|
assert_eq!("1 2 1", f.format_stack());
|
183
181
|
}
|
184
182
|
|
@@ -186,7 +184,7 @@ fn over() {
|
|
186
184
|
#[ignore]
|
187
185
|
fn over_with_three() {
|
188
186
|
let mut f = Forth::new();
|
189
|
-
f.eval("1 2 3 over");
|
187
|
+
assert!(f.eval("1 2 3 over").is_ok());
|
190
188
|
assert_eq!("1 2 3 2", f.format_stack());
|
191
189
|
}
|
192
190
|
|
@@ -208,8 +206,8 @@ fn over_error() {
|
|
208
206
|
#[ignore]
|
209
207
|
fn defining_a_new_word() {
|
210
208
|
let mut f = Forth::new();
|
211
|
-
f.eval(": CoUnT 1 2 3 ;");
|
212
|
-
f.eval("count COUNT");
|
209
|
+
assert!(f.eval(": CoUnT 1 2 3 ;").is_ok());
|
210
|
+
assert!(f.eval("count COUNT").is_ok());
|
213
211
|
assert_eq!("1 2 3 1 2 3", f.format_stack());
|
214
212
|
}
|
215
213
|
|
@@ -217,9 +215,9 @@ fn defining_a_new_word() {
|
|
217
215
|
#[ignore]
|
218
216
|
fn redefining_an_existing_word() {
|
219
217
|
let mut f = Forth::new();
|
220
|
-
f.eval(": foo dup ;");
|
221
|
-
f.eval(": foo dup dup ;");
|
222
|
-
f.eval("1 foo");
|
218
|
+
assert!(f.eval(": foo dup ;").is_ok());
|
219
|
+
assert!(f.eval(": foo dup dup ;").is_ok());
|
220
|
+
assert!(f.eval("1 foo").is_ok());
|
223
221
|
assert_eq!("1 1 1", f.format_stack());
|
224
222
|
}
|
225
223
|
|
@@ -227,8 +225,8 @@ fn redefining_an_existing_word() {
|
|
227
225
|
#[ignore]
|
228
226
|
fn redefining_an_existing_built_in_word() {
|
229
227
|
let mut f = Forth::new();
|
230
|
-
f.eval(": swap dup ;");
|
231
|
-
f.eval("1 swap");
|
228
|
+
assert!(f.eval(": swap dup ;").is_ok());
|
229
|
+
assert!(f.eval("1 swap").is_ok());
|
232
230
|
assert_eq!("1 1", f.format_stack());
|
233
231
|
}
|
234
232
|
|
@@ -236,7 +234,7 @@ fn redefining_an_existing_built_in_word() {
|
|
236
234
|
#[ignore]
|
237
235
|
fn defining_words_with_odd_characters() {
|
238
236
|
let mut f = Forth::new();
|
239
|
-
f.eval(": € 220371 ; €");
|
237
|
+
assert!(f.eval(": € 220371 ; €").is_ok());
|
240
238
|
assert_eq!("220371", f.format_stack());
|
241
239
|
}
|
242
240
|
|