trackler 2.2.1.171 → 2.2.1.172

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/go/exercises/dominoes/.meta/gen.go +1 -1
  4. data/tracks/go/exercises/dominoes/cases_test.go +11 -11
  5. data/tracks/ocaml/config.json +1 -1
  6. data/tracks/ocaml/docs/ABOUT.md +6 -4
  7. data/tracks/powershell/config.json +3 -2
  8. data/tracks/rust/bin/format_exercises +31 -0
  9. data/tracks/rust/config.json +10 -2
  10. data/tracks/rust/config/exercise_readme.go.tmpl +26 -5
  11. data/tracks/rust/exercises/accumulate/README.md +26 -5
  12. data/tracks/rust/exercises/accumulate/src/lib.rs +1 -0
  13. data/tracks/rust/exercises/accumulate/tests/accumulate.rs +7 -7
  14. data/tracks/rust/exercises/acronym/README.md +26 -5
  15. data/tracks/rust/exercises/acronym/src/lib.rs +1 -0
  16. data/tracks/rust/exercises/acronym/tests/acronym.rs +10 -5
  17. data/tracks/rust/exercises/all-your-base/README.md +26 -5
  18. data/tracks/rust/exercises/all-your-base/src/lib.rs +6 -1
  19. data/tracks/rust/exercises/all-your-base/tests/all-your-base.rs +68 -34
  20. data/tracks/rust/exercises/allergies/README.md +26 -5
  21. data/tracks/rust/exercises/allergies/src/lib.rs +1 -0
  22. data/tracks/rust/exercises/allergies/tests/allergies.rs +34 -26
  23. data/tracks/rust/exercises/alphametics/README.md +26 -5
  24. data/tracks/rust/exercises/alphametics/tests/alphametics.rs +44 -9
  25. data/tracks/rust/exercises/anagram/README.md +26 -5
  26. data/tracks/rust/exercises/anagram/src/lib.rs +1 -0
  27. data/tracks/rust/exercises/anagram/tests/anagram.rs +15 -4
  28. data/tracks/rust/exercises/armstrong-numbers/README.md +26 -5
  29. data/tracks/rust/exercises/atbash-cipher/README.md +26 -5
  30. data/tracks/rust/exercises/atbash-cipher/src/lib.rs +1 -1
  31. data/tracks/rust/exercises/atbash-cipher/tests/atbash-cipher.rs +16 -8
  32. data/tracks/rust/exercises/beer-song/README.md +26 -5
  33. data/tracks/rust/exercises/binary-search/README.md +26 -5
  34. data/tracks/rust/exercises/binary-search/src/lib.rs +1 -0
  35. data/tracks/rust/exercises/binary-search/tests/binary-search.rs +8 -4
  36. data/tracks/rust/exercises/bob/README.md +26 -5
  37. data/tracks/rust/exercises/bob/tests/bob.rs +32 -15
  38. data/tracks/rust/exercises/book-store/README.md +26 -5
  39. data/tracks/rust/exercises/book-store/src/lib.rs +4 -1
  40. data/tracks/rust/exercises/book-store/tests/book-store.rs +52 -24
  41. data/tracks/rust/exercises/bowling/README.md +26 -5
  42. data/tracks/rust/exercises/bowling/src/lib.rs +1 -2
  43. data/tracks/rust/exercises/bowling/tests/bowling.rs +2 -1
  44. data/tracks/rust/exercises/bracket-push/README.md +29 -7
  45. data/tracks/rust/exercises/bracket-push/src/lib.rs +1 -0
  46. data/tracks/rust/exercises/circular-buffer/README.md +26 -5
  47. data/tracks/rust/exercises/circular-buffer/src/lib.rs +1 -0
  48. data/tracks/rust/exercises/clock/README.md +26 -5
  49. data/tracks/rust/exercises/clock/src/lib.rs +1 -0
  50. data/tracks/rust/exercises/clock/tests/clock.rs +0 -1
  51. data/tracks/rust/exercises/collatz-conjecture/README.md +26 -5
  52. data/tracks/rust/exercises/crypto-square/README.md +53 -29
  53. data/tracks/rust/exercises/custom-set/README.md +26 -5
  54. data/tracks/rust/exercises/custom-set/src/lib.rs +1 -0
  55. data/tracks/rust/exercises/decimal/README.md +26 -5
  56. data/tracks/rust/exercises/decimal/tests/decimal.rs +4 -7
  57. data/tracks/rust/exercises/diamond/README.md +26 -5
  58. data/tracks/rust/exercises/difference-of-squares/README.md +26 -5
  59. data/tracks/rust/exercises/difference-of-squares/src/lib.rs +1 -1
  60. data/tracks/rust/exercises/diffie-hellman/README.md +26 -5
  61. data/tracks/rust/exercises/diffie-hellman/src/lib.rs +12 -2
  62. data/tracks/rust/exercises/diffie-hellman/tests/diffie-hellman.rs +3 -3
  63. data/tracks/rust/exercises/dominoes/README.md +26 -5
  64. data/tracks/rust/exercises/dominoes/src/lib.rs +1 -0
  65. data/tracks/rust/exercises/dominoes/tests/dominoes.rs +29 -13
  66. data/tracks/rust/exercises/etl/README.md +26 -5
  67. data/tracks/rust/exercises/etl/src/lib.rs +1 -0
  68. data/tracks/rust/exercises/etl/tests/etl.rs +39 -34
  69. data/tracks/rust/exercises/forth/README.md +26 -5
  70. data/tracks/rust/exercises/forth/tests/forth.rs +17 -65
  71. data/tracks/rust/exercises/gigasecond/README.md +26 -5
  72. data/tracks/rust/exercises/gigasecond/tests/gigasecond.rs +31 -10
  73. data/tracks/rust/exercises/grade-school/README.md +26 -5
  74. data/tracks/rust/exercises/grade-school/src/lib.rs +1 -2
  75. data/tracks/rust/exercises/grade-school/tests/grade-school.rs +5 -9
  76. data/tracks/rust/exercises/grains/README.md +26 -5
  77. data/tracks/rust/exercises/hamming/README.md +30 -8
  78. data/tracks/rust/exercises/hamming/src/lib.rs +1 -2
  79. data/tracks/rust/exercises/hello-world/README.md +26 -5
  80. data/tracks/rust/exercises/hexadecimal/README.md +26 -5
  81. data/tracks/rust/exercises/hexadecimal/src/lib.rs +1 -0
  82. data/tracks/rust/exercises/isbn-verifier/README.md +26 -5
  83. data/tracks/rust/exercises/isogram/README.md +26 -5
  84. data/tracks/rust/exercises/isogram/src/lib.rs +1 -1
  85. data/tracks/rust/exercises/isogram/tests/isogram.rs +36 -24
  86. data/tracks/rust/exercises/largest-series-product/README.md +26 -5
  87. data/tracks/rust/exercises/largest-series-product/src/lib.rs +5 -1
  88. data/tracks/rust/exercises/largest-series-product/tests/largest-series-product.rs +4 -2
  89. data/tracks/rust/exercises/leap/README.md +26 -5
  90. data/tracks/rust/exercises/luhn-from/README.md +26 -5
  91. data/tracks/rust/exercises/luhn-from/src/lib.rs +1 -0
  92. data/tracks/rust/exercises/luhn-trait/README.md +26 -5
  93. data/tracks/rust/exercises/luhn-trait/src/lib.rs +1 -0
  94. data/tracks/rust/exercises/luhn/README.md +26 -5
  95. data/tracks/rust/exercises/luhn/src/lib.rs +1 -1
  96. data/tracks/rust/exercises/macros/README.md +26 -5
  97. data/tracks/rust/exercises/minesweeper/README.md +26 -5
  98. data/tracks/rust/exercises/minesweeper/src/lib.rs +1 -0
  99. data/tracks/rust/exercises/nth-prime/README.md +26 -5
  100. data/tracks/rust/exercises/nucleotide-codons/README.md +26 -5
  101. data/tracks/rust/exercises/nucleotide-codons/src/lib.rs +1 -0
  102. data/tracks/rust/exercises/nucleotide-codons/tests/codons.rs +6 -5
  103. data/tracks/rust/exercises/nucleotide-count/README.md +26 -5
  104. data/tracks/rust/exercises/nucleotide-count/src/lib.rs +1 -0
  105. data/tracks/rust/exercises/nucleotide-count/tests/nucleotide-count.rs +5 -8
  106. data/tracks/rust/exercises/ocr-numbers/README.md +26 -5
  107. data/tracks/rust/exercises/ocr-numbers/tests/ocr-numbers.rs +0 -1
  108. data/tracks/rust/exercises/palindrome-products/README.md +26 -5
  109. data/tracks/rust/exercises/pangram/README.md +26 -5
  110. data/tracks/rust/exercises/pangram/src/lib.rs +1 -1
  111. data/tracks/rust/exercises/parallel-letter-frequency/README.md +26 -5
  112. data/tracks/rust/exercises/parallel-letter-frequency/benches/benchmark.rs +6 -3
  113. data/tracks/rust/exercises/parallel-letter-frequency/src/lib.rs +1 -0
  114. data/tracks/rust/exercises/parallel-letter-frequency/tests/parallel-letter-frequency.rs +6 -3
  115. data/tracks/rust/exercises/pascals-triangle/README.md +26 -5
  116. data/tracks/rust/exercises/pascals-triangle/tests/pascals-triangle.rs +36 -28
  117. data/tracks/rust/exercises/perfect-numbers/README.md +26 -5
  118. data/tracks/rust/exercises/perfect-numbers/src/lib.rs +1 -1
  119. data/tracks/rust/exercises/perfect-numbers/tests/perfect-numbers.rs +1 -2
  120. data/tracks/rust/exercises/phone-number/README.md +26 -5
  121. data/tracks/rust/exercises/phone-number/src/lib.rs +1 -0
  122. data/tracks/rust/exercises/pig-latin/README.md +26 -5
  123. data/tracks/rust/exercises/pig-latin/src/lib.rs +1 -0
  124. data/tracks/rust/exercises/poker/README.md +26 -5
  125. data/tracks/rust/exercises/poker/tests/poker.rs +27 -104
  126. data/tracks/rust/exercises/prime-factors/README.md +26 -5
  127. data/tracks/rust/exercises/protein-translation/README.md +26 -5
  128. data/tracks/rust/exercises/protein-translation/src/lib.rs +1 -0
  129. data/tracks/rust/exercises/protein-translation/tests/proteins.rs +16 -9
  130. data/tracks/rust/exercises/proverb/README.md +26 -5
  131. data/tracks/rust/exercises/proverb/tests/proverb.rs +1 -7
  132. data/tracks/rust/exercises/pythagorean-triplet/README.md +26 -5
  133. data/tracks/rust/exercises/queen-attack/README.md +26 -5
  134. data/tracks/rust/exercises/queen-attack/src/lib.rs +1 -0
  135. data/tracks/rust/exercises/raindrops/README.md +26 -5
  136. data/tracks/rust/exercises/raindrops/tests/raindrops.rs +57 -19
  137. data/tracks/rust/exercises/react/README.md +26 -5
  138. data/tracks/rust/exercises/react/src/lib.rs +16 -4
  139. data/tracks/rust/exercises/react/tests/react.rs +174 -43
  140. data/tracks/rust/exercises/rectangles/README.md +26 -5
  141. data/tracks/rust/exercises/rectangles/src/lib.rs +1 -0
  142. data/tracks/rust/exercises/reverse-string/README.md +26 -5
  143. data/tracks/rust/exercises/reverse-string/tests/reverse-string.rs +2 -11
  144. data/tracks/rust/exercises/rna-transcription/README.md +26 -5
  145. data/tracks/rust/exercises/rna-transcription/src/lib.rs +1 -0
  146. data/tracks/rust/exercises/robot-name/README.md +26 -5
  147. data/tracks/rust/exercises/robot-name/src/lib.rs +1 -0
  148. data/tracks/rust/exercises/robot-name/tests/robot-name.rs +8 -2
  149. data/tracks/rust/exercises/robot-simulator/README.md +26 -5
  150. data/tracks/rust/exercises/robot-simulator/src/lib.rs +5 -6
  151. data/tracks/rust/exercises/roman-numerals/README.md +26 -5
  152. data/tracks/rust/exercises/roman-numerals/src/lib.rs +1 -0
  153. data/tracks/rust/exercises/rotational-cipher/README.md +26 -5
  154. data/tracks/rust/exercises/rotational-cipher/src/lib.rs +1 -0
  155. data/tracks/rust/exercises/rotational-cipher/tests/rotational-cipher.rs +12 -4
  156. data/tracks/rust/exercises/run-length-encoding/README.md +26 -5
  157. data/tracks/rust/exercises/run-length-encoding/src/lib.rs +1 -1
  158. data/tracks/rust/exercises/run-length-encoding/tests/run-length-encoding.rs +12 -5
  159. data/tracks/rust/exercises/saddle-points/README.md +26 -5
  160. data/tracks/rust/exercises/saddle-points/src/lib.rs +4 -1
  161. data/tracks/rust/exercises/say/README.md +27 -6
  162. data/tracks/rust/exercises/say/src/lib.rs +1 -1
  163. data/tracks/rust/exercises/say/tests/say.rs +30 -14
  164. data/tracks/rust/exercises/scrabble-score/README.md +26 -5
  165. data/tracks/rust/exercises/scrabble-score/src/lib.rs +1 -1
  166. data/tracks/rust/exercises/series/README.md +32 -11
  167. data/tracks/rust/exercises/series/src/lib.rs +5 -1
  168. data/tracks/rust/exercises/sieve/README.md +31 -8
  169. data/tracks/rust/exercises/sieve/src/lib.rs +1 -0
  170. data/tracks/rust/exercises/sieve/tests/sieve.rs +11 -12
  171. data/tracks/rust/exercises/simple-cipher/README.md +26 -5
  172. data/tracks/rust/exercises/simple-cipher/src/lib.rs +6 -3
  173. data/tracks/rust/exercises/simple-cipher/tests/simple-cipher.rs +0 -1
  174. data/tracks/rust/exercises/simple-linked-list/README.md +26 -5
  175. data/tracks/rust/exercises/simple-linked-list/src/lib.rs +0 -1
  176. data/tracks/rust/exercises/simple-linked-list/tests/simple-linked-list.rs +0 -1
  177. data/tracks/rust/exercises/space-age/README.md +26 -5
  178. data/tracks/rust/exercises/space-age/tests/space-age.rs +4 -4
  179. data/tracks/rust/exercises/spiral-matrix/README.md +26 -5
  180. data/tracks/rust/exercises/sublist/README.md +26 -5
  181. data/tracks/rust/exercises/sublist/src/lib.rs +1 -0
  182. data/tracks/rust/exercises/sublist/tests/sublist.rs +17 -68
  183. data/tracks/rust/exercises/sum-of-multiples/README.md +26 -5
  184. data/tracks/rust/exercises/sum-of-multiples/src/lib.rs +5 -1
  185. data/tracks/rust/exercises/tournament/README.md +26 -5
  186. data/tracks/rust/exercises/tournament/src/lib.rs +1 -0
  187. data/tracks/rust/exercises/tournament/tests/tournament.rs +60 -60
  188. data/tracks/rust/exercises/triangle/README.md +26 -5
  189. data/tracks/rust/exercises/triangle/src/lib.rs +1 -0
  190. data/tracks/rust/exercises/two-bucket/README.md +26 -5
  191. data/tracks/rust/exercises/two-bucket/src/lib.rs +2 -6
  192. data/tracks/rust/exercises/two-bucket/tests/two-bucket.rs +49 -37
  193. data/tracks/rust/exercises/twofer/README.md +33 -7
  194. data/tracks/rust/exercises/twofer/src/lib.rs +2 -2
  195. data/tracks/rust/exercises/twofer/tests/two-fer.rs +2 -2
  196. data/tracks/rust/exercises/variable-length-quantity/README.md +26 -5
  197. data/tracks/rust/exercises/variable-length-quantity/tests/variable-length-quantity.rs +60 -32
  198. data/tracks/rust/exercises/word-count/README.md +26 -5
  199. data/tracks/rust/exercises/word-count/src/lib.rs +1 -1
  200. data/tracks/rust/exercises/word-count/tests/word-count.rs +15 -23
  201. data/tracks/rust/exercises/wordy/README.md +26 -5
  202. data/tracks/rust/exercises/wordy/src/lib.rs +1 -0
  203. metadata +3 -2
@@ -4,8 +4,9 @@ use diffie_hellman::*;
4
4
 
5
5
  #[test]
6
6
  fn test_private_key_in_range_key() {
7
- let primes: Vec<u64> = vec![5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 773, 967,
8
- 3461, 6131];
7
+ let primes: Vec<u64> = vec![
8
+ 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 773, 967, 3461, 6131,
9
+ ];
9
10
  let private_keys: Vec<u64> = primes.iter().map(|x| private_key(*x)).collect();
10
11
 
11
12
  for i in 0..primes.len() {
@@ -25,7 +26,6 @@ fn test_public_key_correct() {
25
26
  assert_eq!(public_key(p, g, private_key), expected);
26
27
  }
27
28
 
28
-
29
29
  #[test]
30
30
  #[ignore]
31
31
  fn test_secret_key_correct() {
@@ -27,11 +27,31 @@ Execute the tests with:
27
27
  $ cargo test
28
28
  ```
29
29
 
30
- All but the first test have been ignored. After you get the first test to
31
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
32
- to pass again. The test file is located in the `tests` directory. You can
33
- also remove the ignore flag from all the tests to get them to run all at once
34
- if you wish.
30
+ All but the first test have been ignored. After you get the first test to
31
+ pass, open the tests source file wich is located in the `tests` directory
32
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
33
+ again. Each separate test is a function with `#[test]` flag above it.
34
+ Continue, until you pass every test.
35
+
36
+ If you wish to run all tests without editing the tests source file, use:
37
+
38
+ ```bash
39
+ $ cargo test -- --ignored
40
+ ```
41
+
42
+ To run a specific test, for example `some_test`, you can use:
43
+
44
+ ```bash
45
+ $ cargo test some_test
46
+ ```
47
+
48
+ If the specfic test is ignored use:
49
+
50
+ ```bash
51
+ $ cargo test some_test -- --ignored
52
+ ```
53
+
54
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
35
55
 
36
56
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
37
57
  haven't already, it will help you with organizing your files.
@@ -45,6 +65,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
45
65
  [help-page]: http://exercism.io/languages/rust
46
66
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
47
67
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
68
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
48
69
 
49
70
  ## Submitting Incomplete Solutions
50
71
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -6,7 +6,7 @@ type Domino = (usize, usize);
6
6
 
7
7
  #[derive(Debug)]
8
8
  enum CheckResult {
9
- GotInvalid, // chain returned None
9
+ GotInvalid, // chain returned None
10
10
  Correct,
11
11
  ChainingFailure(Vec<Domino>), // failure to match the dots at the right side of one domino with
12
12
  // the one on the left side of the next
@@ -17,19 +17,19 @@ enum CheckResult {
17
17
  fn normalize(d: &Domino) -> Domino {
18
18
  match d {
19
19
  &(m, n) if m > n => (n, m),
20
- &(m, n) => (m, n)
20
+ &(m, n) => (m, n),
21
21
  }
22
22
  }
23
23
 
24
24
  fn check(input: &[Domino]) -> CheckResult {
25
25
  let output = match dominoes::chain(input) {
26
26
  None => return GotInvalid,
27
- Some(o) => o
27
+ Some(o) => o,
28
28
  };
29
29
  if input.len() != output.len() {
30
30
  return LengthMismatch(output);
31
- }
32
- else if input.len() == 0 { // and thus output.len() == 0
31
+ } else if input.len() == 0 {
32
+ // and thus output.len() == 0
33
33
  return Correct;
34
34
  }
35
35
 
@@ -51,15 +51,14 @@ fn check(input: &[Domino]) -> CheckResult {
51
51
  for &(first, second) in iter {
52
52
  if n != first {
53
53
  fail = true;
54
- break
54
+ break;
55
55
  }
56
56
  n = second
57
57
  }
58
58
  }
59
59
  if fail {
60
60
  ChainingFailure(output)
61
- }
62
- else {
61
+ } else {
63
62
  Correct
64
63
  }
65
64
  }
@@ -68,16 +67,23 @@ fn assert_correct(input: &[Domino]) {
68
67
  match check(&input) {
69
68
  Correct => (),
70
69
  GotInvalid => panic!("Unexpectedly got invalid on input {:?}", input),
71
- ChainingFailure(output) => panic!("Chaining failure for input {:?}, output {:?}", input, output),
72
- LengthMismatch(output) => panic!("Length mismatch for input {:?}, output {:?}", input, output),
73
- DominoMismatch(output) => panic!("Domino mismatch for input {:?}, output {:?}", input, output),
70
+ ChainingFailure(output) => panic!(
71
+ "Chaining failure for input {:?}, output {:?}",
72
+ input, output
73
+ ),
74
+ LengthMismatch(output) => {
75
+ panic!("Length mismatch for input {:?}, output {:?}", input, output)
76
+ }
77
+ DominoMismatch(output) => {
78
+ panic!("Domino mismatch for input {:?}, output {:?}", input, output)
79
+ }
74
80
  }
75
81
  }
76
82
 
77
83
  #[test]
78
84
  fn empty_input_empty_output() {
79
85
  let input = &[];
80
- assert_eq!(dominoes::chain(input), Some(vec!()));
86
+ assert_eq!(dominoes::chain(input), Some(vec![]));
81
87
  }
82
88
 
83
89
  #[test]
@@ -153,6 +159,16 @@ fn separate_loops() {
153
159
  #[test]
154
160
  #[ignore]
155
161
  fn nine_elements() {
156
- let input = &[(1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)];
162
+ let input = &[
163
+ (1, 2),
164
+ (5, 3),
165
+ (3, 1),
166
+ (1, 2),
167
+ (2, 4),
168
+ (1, 6),
169
+ (2, 3),
170
+ (3, 4),
171
+ (5, 6),
172
+ ];
157
173
  assert_correct(input);
158
174
  }
@@ -59,11 +59,31 @@ Execute the tests with:
59
59
  $ cargo test
60
60
  ```
61
61
 
62
- All but the first test have been ignored. After you get the first test to
63
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
64
- to pass again. The test file is located in the `tests` directory. You can
65
- also remove the ignore flag from all the tests to get them to run all at once
66
- if you wish.
62
+ All but the first test have been ignored. After you get the first test to
63
+ pass, open the tests source file wich is located in the `tests` directory
64
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
65
+ again. Each separate test is a function with `#[test]` flag above it.
66
+ Continue, until you pass every test.
67
+
68
+ If you wish to run all tests without editing the tests source file, use:
69
+
70
+ ```bash
71
+ $ cargo test -- --ignored
72
+ ```
73
+
74
+ To run a specific test, for example `some_test`, you can use:
75
+
76
+ ```bash
77
+ $ cargo test some_test
78
+ ```
79
+
80
+ If the specfic test is ignored use:
81
+
82
+ ```bash
83
+ $ cargo test some_test -- --ignored
84
+ ```
85
+
86
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
67
87
 
68
88
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
69
89
  haven't already, it will help you with organizing your files.
@@ -77,6 +97,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
77
97
  [help-page]: http://exercism.io/languages/rust
78
98
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
79
99
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
100
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
80
101
 
81
102
  ## Source
82
103
 
@@ -4,13 +4,9 @@ use std::collections::BTreeMap;
4
4
 
5
5
  #[test]
6
6
  fn test_transform_one_value() {
7
- let input = input_from(&[
8
- (1, vec!('A')),
9
- ]);
7
+ let input = input_from(&[(1, vec!['A'])]);
10
8
 
11
- let expected = expected_from(&[
12
- ('a', 1),
13
- ]);
9
+ let expected = expected_from(&[('a', 1)]);
14
10
 
15
11
  assert_eq!(expected, etl::transform(&input));
16
12
  }
@@ -18,13 +14,9 @@ fn test_transform_one_value() {
18
14
  #[test]
19
15
  #[ignore]
20
16
  fn test_transform_more_values() {
21
- let input = input_from(&[
22
- (1, vec!('A', 'E', 'I', 'O', 'U')),
23
- ]);
17
+ let input = input_from(&[(1, vec!['A', 'E', 'I', 'O', 'U'])]);
24
18
 
25
- let expected = expected_from(&[
26
- ('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1),
27
- ]);
19
+ let expected = expected_from(&[('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1)]);
28
20
 
29
21
  assert_eq!(expected, etl::transform(&input));
30
22
  }
@@ -32,15 +24,9 @@ fn test_transform_more_values() {
32
24
  #[test]
33
25
  #[ignore]
34
26
  fn test_more_keys() {
35
- let input = input_from(&[
36
- (1, vec!('A', 'E')),
37
- (2, vec!('D', 'G')),
38
- ]);
27
+ let input = input_from(&[(1, vec!['A', 'E']), (2, vec!['D', 'G'])]);
39
28
 
40
- let expected = expected_from(&[
41
- ('a', 1), ('e', 1),
42
- ('d', 2), ('g', 2),
43
- ]);
29
+ let expected = expected_from(&[('a', 1), ('e', 1), ('d', 2), ('g', 2)]);
44
30
 
45
31
  assert_eq!(expected, etl::transform(&input));
46
32
  }
@@ -49,23 +35,42 @@ fn test_more_keys() {
49
35
  #[ignore]
50
36
  fn test_full_dataset() {
51
37
  let input = input_from(&[
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')),
38
+ (1, vec!['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T']),
39
+ (2, vec!['D', 'G']),
40
+ (3, vec!['B', 'C', 'M', 'P']),
41
+ (4, vec!['F', 'H', 'V', 'W', 'Y']),
42
+ (5, vec!['K']),
43
+ (8, vec!['J', 'X']),
44
+ (10, vec!['Q', 'Z']),
59
45
  ]);
60
46
 
61
47
  let expected = expected_from(&[
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),
48
+ ('a', 1),
49
+ ('b', 3),
50
+ ('c', 3),
51
+ ('d', 2),
52
+ ('e', 1),
53
+ ('f', 4),
54
+ ('g', 2),
55
+ ('h', 4),
56
+ ('i', 1),
57
+ ('j', 8),
58
+ ('k', 5),
59
+ ('l', 1),
60
+ ('m', 3),
61
+ ('n', 1),
62
+ ('o', 1),
63
+ ('p', 3),
64
+ ('q', 10),
65
+ ('r', 1),
66
+ ('s', 1),
67
+ ('t', 1),
68
+ ('u', 1),
69
+ ('v', 4),
70
+ ('w', 4),
71
+ ('x', 8),
72
+ ('y', 4),
73
+ ('z', 10),
69
74
  ]);
70
75
 
71
76
  assert_eq!(expected, etl::transform(&input));
@@ -38,11 +38,31 @@ Execute the tests with:
38
38
  $ cargo test
39
39
  ```
40
40
 
41
- All but the first test have been ignored. After you get the first test to
42
- pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
43
- to pass again. The test file is located in the `tests` directory. You can
44
- also remove the ignore flag from all the tests to get them to run all at once
45
- if you wish.
41
+ All but the first test have been ignored. After you get the first test to
42
+ pass, open the tests source file wich is located in the `tests` directory
43
+ and remove the `#[ignore]` flag from the next test and get the tests to pass
44
+ again. Each separate test is a function with `#[test]` flag above it.
45
+ Continue, until you pass every test.
46
+
47
+ If you wish to run all tests without editing the tests source file, use:
48
+
49
+ ```bash
50
+ $ cargo test -- --ignored
51
+ ```
52
+
53
+ To run a specific test, for example `some_test`, you can use:
54
+
55
+ ```bash
56
+ $ cargo test some_test
57
+ ```
58
+
59
+ If the specfic test is ignored use:
60
+
61
+ ```bash
62
+ $ cargo test some_test -- --ignored
63
+ ```
64
+
65
+ To learn more about Rust tests refer to the [online test documentation][rust-tests]
46
66
 
47
67
  Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you
48
68
  haven't already, it will help you with organizing your files.
@@ -56,6 +76,7 @@ If you want to know more about Exercism, take a look at the [contribution guide]
56
76
  [help-page]: http://exercism.io/languages/rust
57
77
  [modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html
58
78
  [cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html
79
+ [rust-tests]: https://doc.rust-lang.org/book/second-edition/ch11-02-running-tests.html
59
80
 
60
81
  ## Submitting Incomplete Solutions
61
82
  It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -1,6 +1,6 @@
1
1
  extern crate forth;
2
2
 
3
- use forth::{Forth, Error, Value};
3
+ use forth::{Error, Forth, Value};
4
4
 
5
5
  #[test]
6
6
  fn no_input_no_stack() {
@@ -44,50 +44,35 @@ fn basic_arithmetic_2() {
44
44
  #[ignore]
45
45
  fn addition_error() {
46
46
  let mut f = Forth::new();
47
- assert_eq!(
48
- Err(Error::StackUnderflow),
49
- f.eval("+")
50
- );
47
+ assert_eq!(Err(Error::StackUnderflow), f.eval("+"));
51
48
  }
52
49
 
53
50
  #[test]
54
51
  #[ignore]
55
52
  fn subtraction_error() {
56
53
  let mut f = Forth::new();
57
- assert_eq!(
58
- Err(Error::StackUnderflow),
59
- f.eval("-")
60
- );
54
+ assert_eq!(Err(Error::StackUnderflow), f.eval("-"));
61
55
  }
62
56
 
63
57
  #[test]
64
58
  #[ignore]
65
59
  fn multiplication_error() {
66
60
  let mut f = Forth::new();
67
- assert_eq!(
68
- Err(Error::StackUnderflow),
69
- f.eval("*")
70
- );
61
+ assert_eq!(Err(Error::StackUnderflow), f.eval("*"));
71
62
  }
72
63
 
73
64
  #[test]
74
65
  #[ignore]
75
66
  fn division_error() {
76
67
  let mut f = Forth::new();
77
- assert_eq!(
78
- Err(Error::StackUnderflow),
79
- f.eval("/")
80
- );
68
+ assert_eq!(Err(Error::StackUnderflow), f.eval("/"));
81
69
  }
82
70
 
83
71
  #[test]
84
72
  #[ignore]
85
73
  fn division_by_zero() {
86
74
  let mut f = Forth::new();
87
- assert_eq!(
88
- Err(Error::DivisionByZero),
89
- f.eval("4 2 2 - /")
90
- );
75
+ assert_eq!(Err(Error::DivisionByZero), f.eval("4 2 2 - /"));
91
76
  }
92
77
 
93
78
  #[test]
@@ -110,10 +95,7 @@ fn dup_case_insensitive() {
110
95
  #[ignore]
111
96
  fn dup_error() {
112
97
  let mut f = Forth::new();
113
- assert_eq!(
114
- Err(Error::StackUnderflow),
115
- f.eval("dup")
116
- );
98
+ assert_eq!(Err(Error::StackUnderflow), f.eval("dup"));
117
99
  }
118
100
 
119
101
  #[test]
@@ -136,10 +118,7 @@ fn drop_with_two() {
136
118
  #[ignore]
137
119
  fn drop_error() {
138
120
  let mut f = Forth::new();
139
- assert_eq!(
140
- Err(Error::StackUnderflow),
141
- f.eval("drop")
142
- );
121
+ assert_eq!(Err(Error::StackUnderflow), f.eval("drop"));
143
122
  }
144
123
 
145
124
  #[test]
@@ -162,14 +141,8 @@ fn swap_with_three() {
162
141
  #[ignore]
163
142
  fn swap_error() {
164
143
  let mut f = Forth::new();
165
- assert_eq!(
166
- Err(Error::StackUnderflow),
167
- f.eval("1 swap")
168
- );
169
- assert_eq!(
170
- Err(Error::StackUnderflow),
171
- f.eval("swap")
172
- );
144
+ assert_eq!(Err(Error::StackUnderflow), f.eval("1 swap"));
145
+ assert_eq!(Err(Error::StackUnderflow), f.eval("swap"));
173
146
  }
174
147
 
175
148
  #[test]
@@ -192,14 +165,8 @@ fn over_with_three() {
192
165
  #[ignore]
193
166
  fn over_error() {
194
167
  let mut f = Forth::new();
195
- assert_eq!(
196
- Err(Error::StackUnderflow),
197
- f.eval("1 over")
198
- );
199
- assert_eq!(
200
- Err(Error::StackUnderflow),
201
- f.eval("over")
202
- );
168
+ assert_eq!(Err(Error::StackUnderflow), f.eval("1 over"));
169
+ assert_eq!(Err(Error::StackUnderflow), f.eval("over"));
203
170
  }
204
171
 
205
172
  #[test]
@@ -242,36 +209,21 @@ fn defining_words_with_odd_characters() {
242
209
  #[ignore]
243
210
  fn defining_a_number() {
244
211
  let mut f = Forth::new();
245
- assert_eq!(
246
- Err(Error::InvalidWord),
247
- f.eval(": 1 2 ;")
248
- );
212
+ assert_eq!(Err(Error::InvalidWord), f.eval(": 1 2 ;"));
249
213
  }
250
214
 
251
215
  #[test]
252
216
  #[ignore]
253
217
  fn malformed_word_definition() {
254
218
  let mut f = Forth::new();
255
- assert_eq!(
256
- Err(Error::InvalidWord),
257
- f.eval(":")
258
- );
259
- assert_eq!(
260
- Err(Error::InvalidWord),
261
- f.eval(": foo")
262
- );
263
- assert_eq!(
264
- Err(Error::InvalidWord),
265
- f.eval(": foo 1")
266
- );
219
+ assert_eq!(Err(Error::InvalidWord), f.eval(":"));
220
+ assert_eq!(Err(Error::InvalidWord), f.eval(": foo"));
221
+ assert_eq!(Err(Error::InvalidWord), f.eval(": foo 1"));
267
222
  }
268
223
 
269
224
  #[test]
270
225
  #[ignore]
271
226
  fn calling_non_existing_word() {
272
227
  let mut f = Forth::new();
273
- assert_eq!(
274
- Err(Error::UnknownWord),
275
- f.eval("1 foo")
276
- );
228
+ assert_eq!(Err(Error::UnknownWord), f.eval("1 foo"));
277
229
  }