trackler 2.2.1.16 → 2.2.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/delphi/config/maintainers.json +1 -1
  4. data/tracks/objective-c/docs/SNIPPET.txt +10 -0
  5. data/tracks/python/.gitignore +1 -0
  6. data/tracks/python/exercises/accumulate/accumulate.py +1 -1
  7. data/tracks/python/exercises/allergies/allergies.py +9 -1
  8. data/tracks/python/exercises/alphametics/alphametics.py +1 -1
  9. data/tracks/python/exercises/anagram/anagram.py +1 -1
  10. data/tracks/python/exercises/atbash-cipher/atbash_cipher.py +2 -2
  11. data/tracks/python/exercises/beer-song/beer_song.py +2 -2
  12. data/tracks/python/exercises/binary/binary.py +1 -1
  13. data/tracks/python/exercises/binary-search/binary_search.py +1 -1
  14. data/tracks/python/exercises/bob/bob.py +1 -1
  15. data/tracks/python/exercises/book-store/book_store.py +1 -1
  16. data/tracks/python/exercises/bracket-push/bracket_push.py +1 -1
  17. data/tracks/python/requirements-travis.txt +1 -1
  18. data/tracks/rust/config.json +21 -7
  19. data/tracks/rust/exercises/crypto-square/.gitignore +7 -0
  20. data/tracks/rust/exercises/crypto-square/Cargo-example.toml +7 -0
  21. data/tracks/rust/exercises/crypto-square/Cargo.toml +6 -0
  22. data/tracks/rust/exercises/crypto-square/README.md +106 -0
  23. data/tracks/rust/exercises/crypto-square/example.rs +114 -0
  24. data/tracks/rust/exercises/crypto-square/src/lib.rs +3 -0
  25. data/tracks/rust/exercises/crypto-square/tests/crypto-square.rs +81 -0
  26. data/tracks/sml/Makefile +1 -1
  27. data/tracks/sml/config.json +30 -0
  28. data/tracks/sml/exercises/atbash-cipher/README.md +64 -0
  29. data/tracks/sml/exercises/atbash-cipher/atbash-cipher.sml +5 -0
  30. data/tracks/sml/exercises/atbash-cipher/example.sml +32 -0
  31. data/tracks/sml/exercises/atbash-cipher/test.sml +52 -0
  32. data/tracks/sml/exercises/atbash-cipher/testlib.sml +159 -0
  33. data/tracks/sml/exercises/pangram/README.md +45 -0
  34. data/tracks/sml/exercises/pangram/example.sml +18 -0
  35. data/tracks/sml/exercises/pangram/pangram.sml +2 -0
  36. data/tracks/sml/exercises/pangram/test.sml +41 -0
  37. data/tracks/sml/exercises/pangram/testlib.sml +159 -0
  38. data/tracks/sml/exercises/perfect-numbers/README.md +54 -0
  39. data/tracks/sml/exercises/perfect-numbers/example.sml +26 -0
  40. data/tracks/sml/exercises/perfect-numbers/perfect-numbers.sml +6 -0
  41. data/tracks/sml/exercises/perfect-numbers/test.sml +59 -0
  42. data/tracks/sml/exercises/perfect-numbers/testlib.sml +159 -0
  43. metadata +24 -1
@@ -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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1.16
4
+ version: 2.2.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
@@ -7751,6 +7751,7 @@ files:
7751
7751
  - tracks/objective-c/docs/ABOUT.md
7752
7752
  - tracks/objective-c/docs/EXERCISE_README_INSERT.md
7753
7753
  - tracks/objective-c/docs/INSTALLATION.md
7754
+ - tracks/objective-c/docs/SNIPPET.txt
7754
7755
  - tracks/objective-c/docs/TESTS.md
7755
7756
  - tracks/objective-c/exercises/acronym/AcronymExample.h
7756
7757
  - tracks/objective-c/exercises/acronym/AcronymExample.m
@@ -10333,6 +10334,13 @@ files:
10333
10334
  - tracks/rust/exercises/clock/example.rs
10334
10335
  - tracks/rust/exercises/clock/src/lib.rs
10335
10336
  - tracks/rust/exercises/clock/tests/clock.rs
10337
+ - tracks/rust/exercises/crypto-square/.gitignore
10338
+ - tracks/rust/exercises/crypto-square/Cargo-example.toml
10339
+ - tracks/rust/exercises/crypto-square/Cargo.toml
10340
+ - tracks/rust/exercises/crypto-square/README.md
10341
+ - tracks/rust/exercises/crypto-square/example.rs
10342
+ - tracks/rust/exercises/crypto-square/src/lib.rs
10343
+ - tracks/rust/exercises/crypto-square/tests/crypto-square.rs
10336
10344
  - tracks/rust/exercises/custom-set/.gitignore
10337
10345
  - tracks/rust/exercises/custom-set/Cargo.lock
10338
10346
  - tracks/rust/exercises/custom-set/Cargo.toml
@@ -11319,6 +11327,11 @@ files:
11319
11327
  - tracks/sml/exercises/anagram/anagram.sml
11320
11328
  - tracks/sml/exercises/anagram/example.sml
11321
11329
  - tracks/sml/exercises/anagram/test.sml
11330
+ - tracks/sml/exercises/atbash-cipher/README.md
11331
+ - tracks/sml/exercises/atbash-cipher/atbash-cipher.sml
11332
+ - tracks/sml/exercises/atbash-cipher/example.sml
11333
+ - tracks/sml/exercises/atbash-cipher/test.sml
11334
+ - tracks/sml/exercises/atbash-cipher/testlib.sml
11322
11335
  - tracks/sml/exercises/binary/README.md
11323
11336
  - tracks/sml/exercises/binary/example.sml
11324
11337
  - tracks/sml/exercises/binary/test.sml
@@ -11349,6 +11362,16 @@ files:
11349
11362
  - tracks/sml/exercises/nth-prime/example.sml
11350
11363
  - tracks/sml/exercises/nth-prime/nth-prime.sml
11351
11364
  - tracks/sml/exercises/nth-prime/test.sml
11365
+ - tracks/sml/exercises/pangram/README.md
11366
+ - tracks/sml/exercises/pangram/example.sml
11367
+ - tracks/sml/exercises/pangram/pangram.sml
11368
+ - tracks/sml/exercises/pangram/test.sml
11369
+ - tracks/sml/exercises/pangram/testlib.sml
11370
+ - tracks/sml/exercises/perfect-numbers/README.md
11371
+ - tracks/sml/exercises/perfect-numbers/example.sml
11372
+ - tracks/sml/exercises/perfect-numbers/perfect-numbers.sml
11373
+ - tracks/sml/exercises/perfect-numbers/test.sml
11374
+ - tracks/sml/exercises/perfect-numbers/testlib.sml
11352
11375
  - tracks/sml/exercises/raindrops/README.md
11353
11376
  - tracks/sml/exercises/raindrops/example.sml
11354
11377
  - tracks/sml/exercises/raindrops/raindrops.sml