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.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/change/metadata.yml +2 -0
- data/problem-specifications/exercises/crypto-square/canonical-data.json +10 -65
- data/tracks/c/bin/run-tests +3 -0
- data/tracks/c/exercises/acronym/test/test_acronym.c +8 -0
- data/tracks/c/exercises/all-your-base/test/test_all_your_base.c +19 -0
- data/tracks/c/exercises/allergies/test/test_allergies.c +13 -0
- data/tracks/c/exercises/anagram/src/anagram.h +2 -2
- data/tracks/c/exercises/anagram/src/example.c +5 -5
- data/tracks/c/exercises/anagram/test/test_anagram.c +39 -29
- data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +12 -0
- data/tracks/c/exercises/beer-song/test/test_beer_song.c +5 -0
- data/tracks/c/exercises/binary-search/test/test_binary_search.c +10 -0
- data/tracks/c/exercises/binary/test/test_binary.c +14 -0
- data/tracks/c/exercises/bob/test/test_bob.c +16 -0
- data/tracks/c/exercises/clock/test/test_clock.c +34 -0
- data/tracks/c/exercises/difference-of-squares/test/test_difference_of_squares.c +9 -0
- data/tracks/c/exercises/gigasecond/test/test_gigasecond.c +4 -0
- data/tracks/c/exercises/grains/test/test_grains.c +9 -0
- data/tracks/c/exercises/hamming/test/test_hamming.c +12 -0
- data/tracks/c/exercises/isogram/src/example.c +6 -6
- data/tracks/c/exercises/isogram/src/example.h +1 -1
- data/tracks/c/exercises/isogram/test/test_isogram.c +17 -9
- data/tracks/c/exercises/largest-series-product/test/test_largest_series_product.c +15 -0
- data/tracks/c/exercises/leap/test/test_leap.c +4 -0
- data/tracks/c/exercises/nth-prime/test/test_nth_prime.c +4 -0
- data/tracks/c/exercises/nucleotide-count/test/test_nucleotide_count.c +4 -0
- data/tracks/c/exercises/palindrome-products/test/test_palindrome_products.c +1 -0
- data/tracks/c/exercises/pangram/test/test_pangram.c +11 -0
- data/tracks/c/exercises/pascals-triangle/test/test_pascals_triangle.c +5 -0
- data/tracks/c/exercises/perfect-numbers/test/test_perfect_numbers.c +12 -0
- data/tracks/c/exercises/phone-number/test/test_phone_number.c +13 -0
- data/tracks/c/exercises/raindrops/test/test_raindrops.c +17 -0
- data/tracks/c/exercises/react/test/test_react.c +14 -0
- data/tracks/c/exercises/rna-transcription/test/test_rna_transcription.c +7 -0
- data/tracks/c/exercises/robot-simulator/test/test_robot_simulator.c +11 -0
- data/tracks/c/exercises/roman-numerals/test/test_roman_numerals.c +17 -0
- data/tracks/c/exercises/scrabble-score/test/test_scrabble_score.c +10 -0
- data/tracks/c/exercises/sieve/test/test_sieve.c +4 -0
- data/tracks/c/exercises/space-age/test/test_space_age.c +7 -0
- data/tracks/c/exercises/sum-of-multiples/test/test_sum_of_multiples.c +11 -0
- data/tracks/c/exercises/triangle/test/test_triangle.c +15 -0
- data/tracks/c/exercises/word-count/test/test_word_count.c +10 -0
- data/tracks/dart/.travis.yml +2 -7
- data/tracks/dart/bin/check_formatting +9 -0
- data/tracks/dart/exercises/bob/pubspec.lock +26 -26
- data/tracks/dart/exercises/difference-of-squares/pubspec.lock +26 -26
- data/tracks/dart/exercises/gigasecond/pubspec.lock +26 -26
- data/tracks/dart/exercises/hamming/pubspec.lock +26 -26
- data/tracks/dart/exercises/hello-world/pubspec.lock +26 -26
- data/tracks/dart/exercises/leap/pubspec.lock +26 -26
- data/tracks/dart/exercises/rna-transcription/pubspec.lock +26 -26
- data/tracks/dart/exercises/rna-transcription/test/rna_transcription_test.dart +1 -1
- data/tracks/dart/pubspec.lock +42 -30
- data/tracks/dart/pubspec.yaml +3 -3
- data/tracks/dart/test/exercises_test.dart +52 -14
- data/tracks/dart/tool/create-exercise +1 -1
- data/tracks/erlang/.travis.yml +2 -2
- data/tracks/erlang/config.json +10 -0
- data/tracks/erlang/exercises/bank-account/src/example.erl +67 -41
- data/tracks/erlang/exercises/bank-account/test/bank_account_tests.erl +0 -6
- data/tracks/erlang/exercises/luhn/src/example.erl +32 -14
- data/tracks/erlang/exercises/luhn/test/luhn_tests.erl +36 -10
- data/tracks/erlang/exercises/two-fer/README.md +19 -0
- data/tracks/erlang/exercises/two-fer/include/exercism.hrl +11 -0
- data/tracks/erlang/exercises/two-fer/rebar.config +30 -0
- data/tracks/erlang/exercises/two-fer/src/example.erl +11 -0
- data/tracks/erlang/exercises/two-fer/src/two_fer.app.src +9 -0
- data/tracks/erlang/exercises/two-fer/src/two_fer.erl +11 -0
- data/tracks/erlang/exercises/two-fer/test/two_fer_tests.erl +15 -0
- data/tracks/java/config.json +26 -3
- data/tracks/java/exercises/list-ops/.meta/hints.md +4 -0
- data/tracks/javascript/config.json +14 -0
- data/tracks/javascript/docs/ABOUT.md +16 -9
- data/tracks/javascript/exercises/diffie-hellman/README.md +73 -0
- data/tracks/javascript/exercises/diffie-hellman/diffie-hellman.spec.js +73 -0
- data/tracks/javascript/exercises/diffie-hellman/example.js +48 -0
- data/tracks/julia/config.json +1 -1
- data/tracks/python/exercises/accumulate/accumulate.py +1 -1
- data/tracks/python/exercises/allergies/allergies.py +2 -2
- data/tracks/python/exercises/alphametics/alphametics.py +1 -1
- data/tracks/python/exercises/anagram/anagram.py +1 -1
- data/tracks/python/exercises/binary-search/binary_search.py +1 -1
- data/tracks/python/exercises/binary/binary.py +1 -1
- data/tracks/python/exercises/collatz-conjecture/collatz_conjecture.py +1 -1
- data/tracks/python/exercises/crypto-square/crypto_square.py +1 -1
- data/tracks/python/exercises/diamond/diamond.py +1 -1
- data/tracks/python/exercises/grep/grep.py +2 -0
- data/tracks/python/exercises/hello-world/hello_world.py +1 -1
- data/tracks/python/exercises/largest-series-product/largest_series_product.py +1 -1
- data/tracks/python/exercises/minesweeper/minesweeper.py +2 -1
- data/tracks/python/exercises/nucleotide-count/nucleotide_count.py +2 -2
- data/tracks/python/exercises/ocr-numbers/ocr_numbers.py +2 -2
- data/tracks/python/exercises/octal/octal.py +1 -1
- data/tracks/python/exercises/pangram/pangram.py +1 -1
- data/tracks/python/exercises/pascals-triangle/pascals_triangle.py +3 -3
- data/tracks/python/exercises/poker/poker.py +1 -1
- data/tracks/python/exercises/prime-factors/prime_factors.py +1 -1
- data/tracks/python/exercises/protein-translation/protein_translation.py +2 -2
- data/tracks/python/exercises/proverb/proverb.py +1 -1
- data/tracks/python/exercises/queen-attack/queen_attack.py +2 -2
- data/tracks/python/exercises/rail-fence-cipher/rail_fence_cipher.py +3 -3
- data/tracks/python/exercises/roman-numerals/roman_numerals.py +1 -1
- data/tracks/python/exercises/rotational-cipher/rotational_cipher.py +1 -1
- data/tracks/python/exercises/say/say.py +1 -1
- data/tracks/python/exercises/secret-handshake/secret_handshake.py +2 -2
- data/tracks/python/exercises/space-age/space_age.py +1 -1
- data/tracks/python/exercises/tournament/tournament.py +1 -1
- data/tracks/python/exercises/trinary/trinary.py +1 -1
- data/tracks/python/exercises/two-fer/two_fer.py +1 -1
- data/tracks/python/exercises/word-count/word_count.py +1 -1
- data/tracks/ruby/lib/generator/exercise_case.rb +1 -1
- data/tracks/ruby/test/generator/exercise_case_test.rb +10 -0
- data/tracks/scala/testgen/src/main/resources/version-check-ignore.txt +1 -2
- data/tracks/sml/exercises/accumulate/README.md +19 -14
- data/tracks/sml/exercises/accumulate/accumulate.sml +1 -1
- data/tracks/sml/exercises/accumulate/example.sml +2 -2
- data/tracks/sml/exercises/accumulate/test.sml +26 -56
- data/tracks/sml/exercises/accumulate/testlib.sml +159 -0
- metadata +15 -2
@@ -1,2 +1,2 @@
|
|
1
|
-
fun accumulate
|
2
|
-
| accumulate f
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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.
|
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-
|
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
|