trackler 2.2.1.42 → 2.2.1.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/change/metadata.yml +2 -0
  4. data/problem-specifications/exercises/crypto-square/canonical-data.json +10 -65
  5. data/tracks/c/bin/run-tests +3 -0
  6. data/tracks/c/exercises/acronym/test/test_acronym.c +8 -0
  7. data/tracks/c/exercises/all-your-base/test/test_all_your_base.c +19 -0
  8. data/tracks/c/exercises/allergies/test/test_allergies.c +13 -0
  9. data/tracks/c/exercises/anagram/src/anagram.h +2 -2
  10. data/tracks/c/exercises/anagram/src/example.c +5 -5
  11. data/tracks/c/exercises/anagram/test/test_anagram.c +39 -29
  12. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +12 -0
  13. data/tracks/c/exercises/beer-song/test/test_beer_song.c +5 -0
  14. data/tracks/c/exercises/binary-search/test/test_binary_search.c +10 -0
  15. data/tracks/c/exercises/binary/test/test_binary.c +14 -0
  16. data/tracks/c/exercises/bob/test/test_bob.c +16 -0
  17. data/tracks/c/exercises/clock/test/test_clock.c +34 -0
  18. data/tracks/c/exercises/difference-of-squares/test/test_difference_of_squares.c +9 -0
  19. data/tracks/c/exercises/gigasecond/test/test_gigasecond.c +4 -0
  20. data/tracks/c/exercises/grains/test/test_grains.c +9 -0
  21. data/tracks/c/exercises/hamming/test/test_hamming.c +12 -0
  22. data/tracks/c/exercises/isogram/src/example.c +6 -6
  23. data/tracks/c/exercises/isogram/src/example.h +1 -1
  24. data/tracks/c/exercises/isogram/test/test_isogram.c +17 -9
  25. data/tracks/c/exercises/largest-series-product/test/test_largest_series_product.c +15 -0
  26. data/tracks/c/exercises/leap/test/test_leap.c +4 -0
  27. data/tracks/c/exercises/nth-prime/test/test_nth_prime.c +4 -0
  28. data/tracks/c/exercises/nucleotide-count/test/test_nucleotide_count.c +4 -0
  29. data/tracks/c/exercises/palindrome-products/test/test_palindrome_products.c +1 -0
  30. data/tracks/c/exercises/pangram/test/test_pangram.c +11 -0
  31. data/tracks/c/exercises/pascals-triangle/test/test_pascals_triangle.c +5 -0
  32. data/tracks/c/exercises/perfect-numbers/test/test_perfect_numbers.c +12 -0
  33. data/tracks/c/exercises/phone-number/test/test_phone_number.c +13 -0
  34. data/tracks/c/exercises/raindrops/test/test_raindrops.c +17 -0
  35. data/tracks/c/exercises/react/test/test_react.c +14 -0
  36. data/tracks/c/exercises/rna-transcription/test/test_rna_transcription.c +7 -0
  37. data/tracks/c/exercises/robot-simulator/test/test_robot_simulator.c +11 -0
  38. data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +17 -0
  39. data/tracks/c/exercises/scrabble-score/test/test_scrabble_score.c +10 -0
  40. data/tracks/c/exercises/sieve/test/test_sieve.c +4 -0
  41. data/tracks/c/exercises/space-age/test/test_space_age.c +7 -0
  42. data/tracks/c/exercises/sum-of-multiples/test/test_sum_of_multiples.c +11 -0
  43. data/tracks/c/exercises/triangle/test/test_triangle.c +15 -0
  44. data/tracks/c/exercises/word-count/test/test_word_count.c +10 -0
  45. data/tracks/dart/.travis.yml +2 -7
  46. data/tracks/dart/bin/check_formatting +9 -0
  47. data/tracks/dart/exercises/bob/pubspec.lock +26 -26
  48. data/tracks/dart/exercises/difference-of-squares/pubspec.lock +26 -26
  49. data/tracks/dart/exercises/gigasecond/pubspec.lock +26 -26
  50. data/tracks/dart/exercises/hamming/pubspec.lock +26 -26
  51. data/tracks/dart/exercises/hello-world/pubspec.lock +26 -26
  52. data/tracks/dart/exercises/leap/pubspec.lock +26 -26
  53. data/tracks/dart/exercises/rna-transcription/pubspec.lock +26 -26
  54. data/tracks/dart/exercises/rna-transcription/test/rna_transcription_test.dart +1 -1
  55. data/tracks/dart/pubspec.lock +42 -30
  56. data/tracks/dart/pubspec.yaml +3 -3
  57. data/tracks/dart/test/exercises_test.dart +52 -14
  58. data/tracks/dart/tool/create-exercise +1 -1
  59. data/tracks/erlang/.travis.yml +2 -2
  60. data/tracks/erlang/config.json +10 -0
  61. data/tracks/erlang/exercises/bank-account/src/example.erl +67 -41
  62. data/tracks/erlang/exercises/bank-account/test/bank_account_tests.erl +0 -6
  63. data/tracks/erlang/exercises/luhn/src/example.erl +32 -14
  64. data/tracks/erlang/exercises/luhn/test/luhn_tests.erl +36 -10
  65. data/tracks/erlang/exercises/two-fer/README.md +19 -0
  66. data/tracks/erlang/exercises/two-fer/include/exercism.hrl +11 -0
  67. data/tracks/erlang/exercises/two-fer/rebar.config +30 -0
  68. data/tracks/erlang/exercises/two-fer/src/example.erl +11 -0
  69. data/tracks/erlang/exercises/two-fer/src/two_fer.app.src +9 -0
  70. data/tracks/erlang/exercises/two-fer/src/two_fer.erl +11 -0
  71. data/tracks/erlang/exercises/two-fer/test/two_fer_tests.erl +15 -0
  72. data/tracks/java/config.json +26 -3
  73. data/tracks/java/exercises/list-ops/.meta/hints.md +4 -0
  74. data/tracks/javascript/config.json +14 -0
  75. data/tracks/javascript/docs/ABOUT.md +16 -9
  76. data/tracks/javascript/exercises/diffie-hellman/README.md +73 -0
  77. data/tracks/javascript/exercises/diffie-hellman/diffie-hellman.spec.js +73 -0
  78. data/tracks/javascript/exercises/diffie-hellman/example.js +48 -0
  79. data/tracks/julia/config.json +1 -1
  80. data/tracks/python/exercises/accumulate/accumulate.py +1 -1
  81. data/tracks/python/exercises/allergies/allergies.py +2 -2
  82. data/tracks/python/exercises/alphametics/alphametics.py +1 -1
  83. data/tracks/python/exercises/anagram/anagram.py +1 -1
  84. data/tracks/python/exercises/binary-search/binary_search.py +1 -1
  85. data/tracks/python/exercises/binary/binary.py +1 -1
  86. data/tracks/python/exercises/collatz-conjecture/collatz_conjecture.py +1 -1
  87. data/tracks/python/exercises/crypto-square/crypto_square.py +1 -1
  88. data/tracks/python/exercises/diamond/diamond.py +1 -1
  89. data/tracks/python/exercises/grep/grep.py +2 -0
  90. data/tracks/python/exercises/hello-world/hello_world.py +1 -1
  91. data/tracks/python/exercises/largest-series-product/largest_series_product.py +1 -1
  92. data/tracks/python/exercises/minesweeper/minesweeper.py +2 -1
  93. data/tracks/python/exercises/nucleotide-count/nucleotide_count.py +2 -2
  94. data/tracks/python/exercises/ocr-numbers/ocr_numbers.py +2 -2
  95. data/tracks/python/exercises/octal/octal.py +1 -1
  96. data/tracks/python/exercises/pangram/pangram.py +1 -1
  97. data/tracks/python/exercises/pascals-triangle/pascals_triangle.py +3 -3
  98. data/tracks/python/exercises/poker/poker.py +1 -1
  99. data/tracks/python/exercises/prime-factors/prime_factors.py +1 -1
  100. data/tracks/python/exercises/protein-translation/protein_translation.py +2 -2
  101. data/tracks/python/exercises/proverb/proverb.py +1 -1
  102. data/tracks/python/exercises/queen-attack/queen_attack.py +2 -2
  103. data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher.py +3 -3
  104. data/tracks/python/exercises/roman-numerals/roman_numerals.py +1 -1
  105. data/tracks/python/exercises/rotational-cipher/rotational_cipher.py +1 -1
  106. data/tracks/python/exercises/say/say.py +1 -1
  107. data/tracks/python/exercises/secret-handshake/secret_handshake.py +2 -2
  108. data/tracks/python/exercises/space-age/space_age.py +1 -1
  109. data/tracks/python/exercises/tournament/tournament.py +1 -1
  110. data/tracks/python/exercises/trinary/trinary.py +1 -1
  111. data/tracks/python/exercises/two-fer/two_fer.py +1 -1
  112. data/tracks/python/exercises/word-count/word_count.py +1 -1
  113. data/tracks/ruby/lib/generator/exercise_case.rb +1 -1
  114. data/tracks/ruby/test/generator/exercise_case_test.rb +10 -0
  115. data/tracks/scala/testgen/src/main/resources/version-check-ignore.txt +1 -2
  116. data/tracks/sml/exercises/accumulate/README.md +19 -14
  117. data/tracks/sml/exercises/accumulate/accumulate.sml +1 -1
  118. data/tracks/sml/exercises/accumulate/example.sml +2 -2
  119. data/tracks/sml/exercises/accumulate/test.sml +26 -56
  120. data/tracks/sml/exercises/accumulate/testlib.sml +159 -0
  121. metadata +15 -2
@@ -6,5 +6,5 @@
6
6
  Caveats: an empty list cannot be transformed
7
7
  do not use List.map from the standard basis
8
8
  *)
9
- fun accumulate (f: 'a -> 'b) (xs: 'a list): 'b list =
9
+ fun accumulate (f: 'a -> 'b, xs: 'a list) : 'b list =
10
10
  raise Fail "'accumulate' has not been implemented"
@@ -1,2 +1,2 @@
1
- fun accumulate _ [] = []
2
- | accumulate f (x::xs) = f x :: accumulate f xs
1
+ fun accumulate (_, []) = []
2
+ | accumulate (f, x::xs) = f x :: accumulate (f, xs)
@@ -1,58 +1,28 @@
1
1
  use "accumulate.sml";
2
+ use "testlib.sml";
2
3
 
3
- val test_cases = [
4
- {
5
- description = "Applying a function the empty-list ([]) does nothing",
6
- input = [],
7
- function = fn x => x,
8
- expected = []
9
- },
10
- {
11
- description = "Applying a square function to [1,2,3] produces [1,4,9]",
12
- input = [1, 2, 3],
13
- function = fn x => x*x,
14
- expected = [1, 4, 9]
15
- },
16
- {
17
- description = "Applying a cube function to[1,2,3] produces [1,8,27]",
18
- input = [1, 2, 3],
19
- function = fn x => x*x*x,
20
- expected = [1, 8, 27]
21
- },
22
- {
23
- description = "Applying an increment function to [1,2,3] produces [2,3,4]",
24
- input = [1, 2, 3],
25
- function = fn x => x+1,
26
- expected = [2, 3, 4]
27
- },
28
- {
29
- description = "Applying an decrement function to [1,2,3] produces [0,1,2]",
30
- input = [1, 2, 3],
31
- function = fn x => x-1,
32
- expected = [0, 1, 2]
33
- }
34
- ];
35
-
36
- fun run_tests _ [] = []
37
- | run_tests f (x :: xs) =
38
- let
39
- fun aux { description, input, function, expected } =
40
- let
41
- val output = f function input
42
- val is_correct = output = expected
43
- val expl = description ^ ": " ^
44
- (if is_correct then "PASSED" else "FAILED") ^ "\n"
45
- in
46
- (print (expl); is_correct)
47
- end
48
- in
49
- (aux x) :: run_tests f xs
50
- end
51
-
52
- val testResults = run_tests accumulate test_cases;
53
- val passedTests = List.filter (fn x => x) testResults;
54
- val failedTests = List.filter (fn x => not x) testResults;
55
-
56
- if (List.length testResults) = (List.length passedTests)
57
- then (print "ALL TESTS PASSED")
58
- else (print (Int.toString (List.length failedTests) ^ " TEST(S) FAILED"));
4
+ infixr |>
5
+ fun x |> f = f x
6
+
7
+ val testsuite =
8
+ describe "accumulate" [
9
+ test "applying a function to the empty-list does nothing"
10
+ (fn _ => accumulate (fn x => x, []) |> Expect.equalTo []),
11
+
12
+ test "applying an identify function to any list returns the source list"
13
+ (fn _ => accumulate (fn x => x, [1,2,3]) |> Expect.equalTo [1,2,3]),
14
+
15
+ test "applying a square function to [1,2,3] produces [1,4,9]"
16
+ (fn _ => accumulate (fn x => x * x, [1,2,3]) |> Expect.equalTo [1,4,9]),
17
+
18
+ test "applying a cube function to [1,2,3] produces [1,8,27]"
19
+ (fn _ => accumulate (fn x => x * x * x, [1,2,3]) |> Expect.equalTo [1,8,27]),
20
+
21
+ test "applying an increment function to [1,2,3] produces [2,3,4]"
22
+ (fn _ => accumulate (fn x => x + 1, [1,2,3]) |> Expect.equalTo [2,3,4]),
23
+
24
+ test "applying an decrement function to [1,2,3] produces [0,1,2]"
25
+ (fn _ => accumulate (fn x => x - 1, [1,2,3]) |> Expect.equalTo [0,1,2])
26
+ ]
27
+
28
+ val _ = Test.run testsuite
@@ -0,0 +1,159 @@
1
+ structure Expect =
2
+ struct
3
+ datatype expectation = Pass | Fail of string * string
4
+
5
+ local
6
+ fun failEq b a =
7
+ Fail ("Expected: " ^ b, "Got: " ^ a)
8
+
9
+ fun failExn b a =
10
+ Fail ("Expected: " ^ b, "Raised: " ^ a)
11
+
12
+ fun exnName (e: exn): string = General.exnName e
13
+ in
14
+ fun truthy a =
15
+ if a
16
+ then Pass
17
+ else failEq "true" "false"
18
+
19
+ fun falsy a =
20
+ if a
21
+ then failEq "false" "true"
22
+ else Pass
23
+
24
+ fun equalTo b a =
25
+ if a = b
26
+ then Pass
27
+ else failEq (PolyML.makestring b) (PolyML.makestring a)
28
+
29
+ fun nearTo b a =
30
+ if Real.== (a, b)
31
+ then Pass
32
+ else failEq (Real.toString b) (Real.toString a)
33
+
34
+ fun anyError f =
35
+ (
36
+ f ();
37
+ failExn "an exception" "Nothing"
38
+ ) handle _ => Pass
39
+
40
+ fun error e f =
41
+ (
42
+ f ();
43
+ failExn (exnName e) "Nothing"
44
+ ) handle e' => if exnMessage e' = exnMessage e
45
+ then Pass
46
+ else failExn (exnMessage e) (exnMessage e')
47
+ end
48
+ end
49
+
50
+ structure TermColor =
51
+ struct
52
+ datatype color = Red | Green | Yellow | Normal
53
+
54
+ fun f Red = "\027[31m"
55
+ | f Green = "\027[32m"
56
+ | f Yellow = "\027[33m"
57
+ | f Normal = "\027[0m"
58
+
59
+ fun colorize color s = (f color) ^ s ^ (f Normal)
60
+
61
+ val redit = colorize Red
62
+
63
+ val greenit = colorize Green
64
+
65
+ val yellowit = colorize Yellow
66
+ end
67
+
68
+ structure Test =
69
+ struct
70
+ datatype testnode = TestGroup of string * testnode list
71
+ | Test of string * (unit -> Expect.expectation)
72
+
73
+ local
74
+ datatype evaluation = Success of string
75
+ | Failure of string * string * string
76
+ | Error of string * string
77
+
78
+ fun indent n s = (implode (List.tabulate (n, fn _ => #" "))) ^ s
79
+
80
+ fun fmt indentlvl ev =
81
+ let
82
+ val check = TermColor.greenit "\226\156\148 " (* ✔ *)
83
+ val cross = TermColor.redit "\226\156\150 " (* ✖ *)
84
+ val indentlvl = indentlvl * 2
85
+ in
86
+ case ev of
87
+ Success descr => indent indentlvl (check ^ descr)
88
+ | Failure (descr, exp, got) =>
89
+ String.concatWith "\n" [indent indentlvl (cross ^ descr),
90
+ indent (indentlvl + 2) exp,
91
+ indent (indentlvl + 2) got]
92
+ | Error (descr, reason) =>
93
+ String.concatWith "\n" [indent indentlvl (cross ^ descr),
94
+ indent (indentlvl + 2) (TermColor.redit reason)]
95
+ end
96
+
97
+ fun eval (TestGroup _) = raise Fail "Only a 'Test' can be evaluated"
98
+ | eval (Test (descr, thunk)) =
99
+ (
100
+ case thunk () of
101
+ Expect.Pass => ((1, 0, 0), Success descr)
102
+ | Expect.Fail (s, s') => ((0, 1, 0), Failure (descr, s, s'))
103
+ )
104
+ handle e => ((0, 0, 1), Error (descr, "Unexpected error: " ^ exnMessage e))
105
+
106
+ fun flatten depth testnode =
107
+ let
108
+ fun sum (x, y, z) (a, b, c) = (x + a, y + b, z + c)
109
+
110
+ fun aux (t, (counter, acc)) =
111
+ let
112
+ val (counter', texts) = flatten (depth + 1) t
113
+ in
114
+ (sum counter' counter, texts :: acc)
115
+ end
116
+ in
117
+ case testnode of
118
+ TestGroup (descr, ts) =>
119
+ let
120
+ val (counter, texts) = foldr aux ((0, 0, 0), []) ts
121
+ in
122
+ (counter, (indent (depth * 2) descr) :: List.concat texts)
123
+ end
124
+ | Test _ =>
125
+ let
126
+ val (counter, evaluation) = eval testnode
127
+ in
128
+ (counter, [fmt depth evaluation])
129
+ end
130
+ end
131
+
132
+ fun println s = print (s ^ "\n")
133
+ in
134
+ fun run suite =
135
+ let
136
+ val ((succeeded, failed, errored), texts) = flatten 0 suite
137
+
138
+ val summary = String.concatWith ", " [
139
+ TermColor.greenit ((Int.toString succeeded) ^ " passed"),
140
+ TermColor.redit ((Int.toString failed) ^ " failed"),
141
+ TermColor.redit ((Int.toString errored) ^ " errored"),
142
+ (Int.toString (succeeded + failed + errored)) ^ " total"
143
+ ]
144
+
145
+ val status = if failed = 0 andalso errored = 0
146
+ then OS.Process.success
147
+ else OS.Process.failure
148
+
149
+ in
150
+ List.app println texts;
151
+ println "";
152
+ println ("Tests: " ^ summary);
153
+ OS.Process.exit status
154
+ end
155
+ end
156
+ end
157
+
158
+ fun describe description tests = Test.TestGroup (description, tests)
159
+ fun test description thunk = Test.Test (description, thunk)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.42
4
+ version: 2.2.1.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2017-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -2940,6 +2940,7 @@ files:
2940
2940
  - tracks/dart/LICENSE
2941
2941
  - tracks/dart/README.md
2942
2942
  - tracks/dart/analysis_options.yaml
2943
+ - tracks/dart/bin/check_formatting
2943
2944
  - tracks/dart/bin/fetch-configlet
2944
2945
  - tracks/dart/config.json
2945
2946
  - tracks/dart/config/exercise_readme.go.tmpl
@@ -4489,6 +4490,13 @@ files:
4489
4490
  - tracks/erlang/exercises/triangle/src/triangle.app.src
4490
4491
  - tracks/erlang/exercises/triangle/src/triangle.erl
4491
4492
  - tracks/erlang/exercises/triangle/test/triangle_tests.erl
4493
+ - tracks/erlang/exercises/two-fer/README.md
4494
+ - tracks/erlang/exercises/two-fer/include/exercism.hrl
4495
+ - tracks/erlang/exercises/two-fer/rebar.config
4496
+ - tracks/erlang/exercises/two-fer/src/example.erl
4497
+ - tracks/erlang/exercises/two-fer/src/two_fer.app.src
4498
+ - tracks/erlang/exercises/two-fer/src/two_fer.erl
4499
+ - tracks/erlang/exercises/two-fer/test/two_fer_tests.erl
4492
4500
  - tracks/erlang/exercises/word-count/README.md
4493
4501
  - tracks/erlang/exercises/word-count/include/exercism.hrl
4494
4502
  - tracks/erlang/exercises/word-count/rebar.config
@@ -7085,6 +7093,9 @@ files:
7085
7093
  - tracks/javascript/exercises/difference-of-squares/README.md
7086
7094
  - tracks/javascript/exercises/difference-of-squares/difference-of-squares.spec.js
7087
7095
  - tracks/javascript/exercises/difference-of-squares/example.js
7096
+ - tracks/javascript/exercises/diffie-hellman/README.md
7097
+ - tracks/javascript/exercises/diffie-hellman/diffie-hellman.spec.js
7098
+ - tracks/javascript/exercises/diffie-hellman/example.js
7088
7099
  - tracks/javascript/exercises/etl/README.md
7089
7100
  - tracks/javascript/exercises/etl/etl.spec.js
7090
7101
  - tracks/javascript/exercises/etl/example.js
@@ -9974,6 +9985,7 @@ files:
9974
9985
  - tracks/python/exercises/grains/grains_test.py
9975
9986
  - tracks/python/exercises/grep/README.md
9976
9987
  - tracks/python/exercises/grep/example.py
9988
+ - tracks/python/exercises/grep/grep.py
9977
9989
  - tracks/python/exercises/grep/grep_test.py
9978
9990
  - tracks/python/exercises/hamming/README.md
9979
9991
  - tracks/python/exercises/hamming/example.py
@@ -12071,6 +12083,7 @@ files:
12071
12083
  - tracks/sml/exercises/accumulate/accumulate.sml
12072
12084
  - tracks/sml/exercises/accumulate/example.sml
12073
12085
  - tracks/sml/exercises/accumulate/test.sml
12086
+ - tracks/sml/exercises/accumulate/testlib.sml
12074
12087
  - tracks/sml/exercises/all-your-base/README.md
12075
12088
  - tracks/sml/exercises/all-your-base/all-your-base.sml
12076
12089
  - tracks/sml/exercises/all-your-base/example.sml