trackler 2.1.0.41 → 2.1.0.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/fixtures/tracks/fake/docs/STRAY.md +1 -0
  3. data/lib/trackler/doc_file.rb +88 -0
  4. data/lib/trackler/track.rb +6 -40
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/bash/README.md +2 -2
  7. data/tracks/bash/config.json +1 -1
  8. data/tracks/c/README.md +1 -1
  9. data/tracks/c/config.json +1 -1
  10. data/tracks/ceylon/README.md +4 -4
  11. data/tracks/ceylon/config.json +1 -1
  12. data/tracks/clojure/README.org +3 -3
  13. data/tracks/clojure/config.json +1 -1
  14. data/tracks/cpp/README.md +2 -2
  15. data/tracks/cpp/config.json +1 -1
  16. data/tracks/cpp/docs/INSTALLATION.md +2 -2
  17. data/tracks/crystal/config.json +1 -1
  18. data/tracks/csharp/config.json +1 -1
  19. data/tracks/delphi/README.md +2 -2
  20. data/tracks/delphi/config.json +1 -1
  21. data/tracks/delphi/exercises/bowling/uBowlingTests.pas +14 -14
  22. data/tracks/ecmascript/config.json +1 -1
  23. data/tracks/elisp/README.org +4 -4
  24. data/tracks/elisp/config.json +1 -1
  25. data/tracks/elixir/README.md +3 -3
  26. data/tracks/elixir/config.json +1 -1
  27. data/tracks/erlang/README.md +2 -2
  28. data/tracks/erlang/config.json +2 -2
  29. data/tracks/factor/README.md +9 -9
  30. data/tracks/factor/config.json +1 -1
  31. data/tracks/fsharp/config.json +1 -1
  32. data/tracks/go/README.md +16 -16
  33. data/tracks/go/config.json +1 -1
  34. data/tracks/go/exercises/gigasecond/gigasecond_test.go +2 -2
  35. data/tracks/go/gen/gen.go +2 -2
  36. data/tracks/haskell/.gitignore +1 -1
  37. data/tracks/haskell/README.md +12 -8
  38. data/tracks/haskell/config.json +1 -1
  39. data/tracks/haskell/docs/EXERCISE_README_INSERT.md +1 -1
  40. data/tracks/idris/README.md +1 -1
  41. data/tracks/idris/config.json +1 -1
  42. data/tracks/java/POLICIES.md +7 -7
  43. data/tracks/java/README.md +7 -7
  44. data/tracks/java/bin/journey-test.sh +1 -1
  45. data/tracks/java/config.json +1 -1
  46. data/tracks/java/docs/MAINTAINING.md +3 -20
  47. data/tracks/java/docs/TESTS.md +3 -3
  48. data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +23 -20
  49. data/tracks/java/exercises/hello-world/GETTING_STARTED.md +1 -1
  50. data/tracks/java/exercises/hello-world/TUTORIAL.md +2 -2
  51. data/tracks/javascript/config.json +1 -1
  52. data/tracks/julia/.travis.yml +0 -2
  53. data/tracks/julia/config.json +9 -0
  54. data/tracks/julia/exercises/custom-set/example.jl +1 -1
  55. data/tracks/julia/exercises/luhn/example.jl +1 -1
  56. data/tracks/julia/exercises/robot-name/HINTS.md +17 -0
  57. data/tracks/julia/exercises/robot-name/example.jl +14 -0
  58. data/tracks/julia/exercises/robot-name/robot-name.jl +8 -0
  59. data/tracks/julia/exercises/robot-name/runtests.jl +69 -0
  60. data/tracks/kotlin/README.md +7 -7
  61. data/tracks/kotlin/config.json +1 -1
  62. data/tracks/kotlin/docs/TESTS.md +3 -3
  63. data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +1 -1
  64. data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +1 -1
  65. data/tracks/lfe/README.md +2 -2
  66. data/tracks/lfe/config.json +1 -1
  67. data/tracks/lisp/README.md +1 -1
  68. data/tracks/lisp/config.json +2 -2
  69. data/tracks/lua/README.md +9 -9
  70. data/tracks/lua/config.json +1 -1
  71. data/tracks/lua/exercises/hamming/hamming_spec.lua +15 -7
  72. data/tracks/lua/exercises/raindrops/raindrops_spec.lua +46 -14
  73. data/tracks/mips/config.json +1 -1
  74. data/tracks/objective-c/Dangerfile +1 -1
  75. data/tracks/objective-c/README.md +1 -1
  76. data/tracks/objective-c/config.json +1 -1
  77. data/tracks/ocaml/README.md +2 -2
  78. data/tracks/ocaml/config.json +1 -1
  79. data/tracks/ocaml/docs/EXERCISE_README_INSERT.md +1 -1
  80. data/tracks/ocaml/tools/test-generator/README.md +2 -2
  81. data/tracks/perl5/README.md +1 -1
  82. data/tracks/perl5/config.json +1 -1
  83. data/tracks/perl6/README.md +2 -2
  84. data/tracks/perl6/config.json +1 -1
  85. data/tracks/perl6/exercises/all-your-base/all-your-base.t +43 -32
  86. data/tracks/perl6/exercises/all-your-base/example.yaml +19 -9
  87. data/tracks/php/config.json +1 -1
  88. data/tracks/pony/README.md +2 -2
  89. data/tracks/pony/config.json +1 -1
  90. data/tracks/powershell/README.md +1 -1
  91. data/tracks/powershell/config.json +1 -1
  92. data/tracks/purescript/README.md +5 -5
  93. data/tracks/purescript/config.json +1 -1
  94. data/tracks/r/README.md +3 -3
  95. data/tracks/r/config.json +1 -1
  96. data/tracks/racket/README.md +2 -2
  97. data/tracks/racket/config.json +1 -1
  98. data/tracks/ruby/README.md +9 -9
  99. data/tracks/ruby/config.json +1 -1
  100. data/tracks/rust/config.json +1 -1
  101. data/tracks/rust/exercises/gigasecond/src/lib.rs +7 -0
  102. data/tracks/rust/exercises/protein-translation/example.rs +11 -22
  103. data/tracks/rust/exercises/protein-translation/tests/proteins.rs +56 -36
  104. data/tracks/scala/config.json +1 -1
  105. data/tracks/scala/exercises/all-your-base/src/test/scala/AllYourBaseTest.scala +46 -64
  106. data/tracks/scala/exercises/rna-transcription/example.scala +1 -3
  107. data/tracks/scala/exercises/rna-transcription/src/test/scala/RnaTranscriptionTest.scala +19 -23
  108. data/tracks/scala/exercises/scrabble-score/example.scala +2 -2
  109. data/tracks/scala/exercises/scrabble-score/src/test/scala/ScrabbleScoreTest.scala +37 -16
  110. data/tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala +32 -42
  111. data/tracks/scala/testgen/src/main/scala/RnaTranscriptionTestGenerator.scala +34 -0
  112. data/tracks/scala/testgen/src/main/scala/ScrabbleScoreTestGenerator.scala +15 -0
  113. data/tracks/sml/README.md +1 -3
  114. data/tracks/sml/config.json +1 -1
  115. data/tracks/sml/docs/EXERCISE_README_INSERT.md +1 -1
  116. data/tracks/swift/config.json +1 -1
  117. data/tracks/typescript/README.md +1 -1
  118. data/tracks/typescript/config.json +1 -1
  119. data/tracks/vimscript/README.md +5 -5
  120. data/tracks/vimscript/config.json +8 -1
  121. data/tracks/vimscript/exercises/largest-series-product/example.vim +31 -0
  122. data/tracks/vimscript/exercises/largest-series-product/largest_series_product.vader +95 -0
  123. data/tracks/vimscript/exercises/largest-series-product/largest_series_product.vim +17 -0
  124. metadata +13 -2
@@ -22,15 +22,26 @@ if ::($exercise).^ver !~~ $version {
22
22
  require ::($module) <&convert-base>;
23
23
 
24
24
  my $c-data;
25
- sub test ($case, $expected) { is-deeply &::('convert-base')(|$case<input_base input_digits output_base>), $expected, $case<description> }
26
25
 
27
- for @($c-data<cases>) {
28
- when .<expected> ~~ Array { test $_, .<expected> }
29
- when .<description> ~~ /base|digit/ { throws-like {&::('convert-base')(|.<input_base input_digits output_base>)}, Exception, .<description> }
30
- when .<description> eq 'leading zeros' { test $_, [4,2] }
31
- when .<description> eq 'empty list' { test $_, [] }
32
- when .<description> ~~ /zero/ { test $_, [0] }
33
- default { flunk .<description> } # To ensure that no canonical-data cases are missed.
26
+ for @($c-data<cases>) -> $case {
27
+ if $case<expected> ~~ Array:D { test }
28
+ else {
29
+ given $case<description> {
30
+ when 'empty list' { test [] }
31
+ when /base|digit/ { throws-like {call-convert-base}, Exception, $_ }
32
+ when /zero/ {
33
+ when 'leading zeros' { test [4,2] }
34
+ default { test [0] }
35
+ }
36
+ flunk "$_; not tested" if %*ENV<EXERCISM>; # To ensure that no canonical-data cases are missed.
37
+ }
38
+ }
39
+
40
+ sub test (Array:D $expected = $case<expected>) {
41
+ is-deeply call-convert-base, $expected, $case<description>
42
+ }
43
+
44
+ sub call-convert-base { &::('convert-base')(|$case<input_base input_digits output_base>) }
34
45
  }
35
46
 
36
47
  if %*ENV<EXERCISM> && (my $c-data-file =
@@ -44,7 +55,7 @@ $c-data := from-json q:to/END/;
44
55
 
45
56
  {
46
57
  "exercise": "all-your-base",
47
- "version": "1.0.0",
58
+ "version": "1.1.0",
48
59
  "comments": [
49
60
  "It's up to each track do decide:",
50
61
  "",
@@ -163,59 +174,59 @@ $c-data := from-json q:to/END/;
163
174
  "expected": null
164
175
  },
165
176
  {
166
- "description": "negative digit",
177
+ "description": "first base is one",
167
178
  "property": "rebase",
168
- "input_base": 2,
169
- "input_digits": [1, -1, 1, 0, 1, 0],
179
+ "input_base": 1,
180
+ "input_digits": [],
170
181
  "output_base": 10,
171
182
  "expected": null
172
183
  },
173
184
  {
174
- "description": "invalid positive digit",
185
+ "description": "first base is zero",
175
186
  "property": "rebase",
176
- "input_base": 2,
177
- "input_digits": [1, 2, 1, 0, 1, 0],
187
+ "input_base": 0,
188
+ "input_digits": [],
178
189
  "output_base": 10,
179
190
  "expected": null
180
191
  },
181
192
  {
182
- "description": "first base is one",
193
+ "description": "first base is negative",
183
194
  "property": "rebase",
184
- "input_base": 1,
185
- "input_digits": [],
195
+ "input_base": -2,
196
+ "input_digits": [1],
186
197
  "output_base": 10,
187
198
  "expected": null
188
199
  },
189
200
  {
190
- "description": "second base is one",
201
+ "description": "negative digit",
191
202
  "property": "rebase",
192
203
  "input_base": 2,
193
- "input_digits": [1, 0, 1, 0, 1, 0],
194
- "output_base": 1,
204
+ "input_digits": [1, -1, 1, 0, 1, 0],
205
+ "output_base": 10,
195
206
  "expected": null
196
207
  },
197
208
  {
198
- "description": "first base is zero",
209
+ "description": "invalid positive digit",
199
210
  "property": "rebase",
200
- "input_base": 0,
201
- "input_digits": [],
211
+ "input_base": 2,
212
+ "input_digits": [1, 2, 1, 0, 1, 0],
202
213
  "output_base": 10,
203
214
  "expected": null
204
215
  },
205
216
  {
206
- "description": "second base is zero",
217
+ "description": "second base is one",
207
218
  "property": "rebase",
208
- "input_base": 10,
209
- "input_digits": [7],
210
- "output_base": 0,
219
+ "input_base": 2,
220
+ "input_digits": [1, 0, 1, 0, 1, 0],
221
+ "output_base": 1,
211
222
  "expected": null
212
223
  },
213
224
  {
214
- "description": "first base is negative",
225
+ "description": "second base is zero",
215
226
  "property": "rebase",
216
- "input_base": -2,
217
- "input_digits": [1],
218
- "output_base": 10,
227
+ "input_base": 10,
228
+ "input_digits": [7],
229
+ "output_base": 0,
219
230
  "expected": null
220
231
  },
221
232
  {
@@ -3,15 +3,26 @@ version: 2
3
3
  plan: 23
4
4
  imports: '&convert-base'
5
5
  tests: |
6
- sub test ($case, $expected) { is-deeply &::('convert-base')(|$case<input_base input_digits output_base>), $expected, $case<description> }
7
6
 
8
- for @($c-data<cases>) {
9
- when .<expected> ~~ Array { test $_, .<expected> }
10
- when .<description> ~~ /base|digit/ { throws-like {&::('convert-base')(|.<input_base input_digits output_base>)}, Exception, .<description> }
11
- when .<description> eq 'leading zeros' { test $_, [4,2] }
12
- when .<description> eq 'empty list' { test $_, [] }
13
- when .<description> ~~ /zero/ { test $_, [0] }
14
- default { flunk .<description> } # To ensure that no canonical-data cases are missed.
7
+ for @($c-data<cases>) -> $case {
8
+ if $case<expected> ~~ Array:D { test }
9
+ else {
10
+ given $case<description> {
11
+ when 'empty list' { test [] }
12
+ when /base|digit/ { throws-like {call-convert-base}, Exception, $_ }
13
+ when /zero/ {
14
+ when 'leading zeros' { test [4,2] }
15
+ default { test [0] }
16
+ }
17
+ flunk "$_; not tested" if %*ENV<EXERCISM>; # To ensure that no canonical-data cases are missed.
18
+ }
19
+ }
20
+
21
+ sub test (Array:D $expected = $case<expected>) {
22
+ is-deeply call-convert-base, $expected, $case<description>
23
+ }
24
+
25
+ sub call-convert-base { &::('convert-base')(|$case<input_base input_digits output_base>) }
15
26
  }
16
27
 
17
28
  unit: module
@@ -60,4 +71,3 @@ example: |
60
71
  unshift @output-digits, $num;
61
72
  return @output-digits;
62
73
  }
63
-
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "php",
3
3
  "language": "PHP",
4
- "repository": "https://github.com/exercism/xphp",
4
+ "repository": "https://github.com/exercism/php",
5
5
  "active": true,
6
6
  "deprecated": [
7
7
 
@@ -1,6 +1,6 @@
1
- # xPony
1
+ # Exercism Pony Track
2
2
 
3
- [![Build Status](https://travis-ci.org/exercism/xpony.svg?branch=master)](https://travis-ci.org/exercism/xpony)
3
+ [![Build Status](https://travis-ci.org/exercism/pony.svg?branch=master)](https://travis-ci.org/exercism/pony)
4
4
 
5
5
  Exercism exercises in Pony.
6
6
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "pony",
3
3
  "language": "Pony",
4
- "repository": "https://github.com/exercism/xpony",
4
+ "repository": "https://github.com/exercism/pony",
5
5
  "active": false,
6
6
  "exercises": [
7
7
  {
@@ -1,4 +1,4 @@
1
- # xPowerShell
1
+ # PowerShell
2
2
 
3
3
  Exercism Exercises for Windows PowerShell
4
4
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "powershell",
3
3
  "language": "Windows PowerShell",
4
- "repository": "https://github.com/exercism/xpowershell",
4
+ "repository": "https://github.com/exercism/powershell",
5
5
  "checklist_issue": 4,
6
6
  "active": false,
7
7
  "deprecated": [
@@ -1,4 +1,4 @@
1
- # xpurescript
1
+ # purescript
2
2
 
3
3
  Exercism problems in PureScript.
4
4
 
@@ -20,7 +20,7 @@ Thank you so much for contributing! :tada:
20
20
  When in doubt just [open a GitHub issue][new-issue] and ask! In any case,
21
21
  don't be afraid or shy! We promise to be friendly and as helpful as possible.
22
22
 
23
- [new-issue]: https://github.com/exercism/xpurescript/issues/new
23
+ [new-issue]: https://github.com/exercism/purescript/issues/new
24
24
 
25
25
 
26
26
  ### How to contribute
@@ -45,8 +45,8 @@ please do [write a comment][write-comment] for an [issue][issues] or a
45
45
  [pull request][prs]. Feedback is extremely useful to us.
46
46
 
47
47
  [write-comment]: https://help.github.com/articles/commenting-on-a-pull-request/
48
- [issues]: https://github.com/exercism/xpurescript/issue
49
- [prs]: https://github.com/exercism/xpurescript/pull
48
+ [issues]: https://github.com/exercism/purescript/issue
49
+ [prs]: https://github.com/exercism/purescript/pull
50
50
 
51
51
  Please be detailed and include any links or arguments to support your
52
52
  opinion.
@@ -70,7 +70,7 @@ explicitly described below.
70
70
 
71
71
 
72
72
  ### Writing a pull request
73
- To fix a bug you should [create a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) [here](https://github.com/exercism/xpurescript/pull). See also [here](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#git-basics) for more information.
73
+ To fix a bug you should [create a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) [here](https://github.com/exercism/purescript/pull). See also [here](https://github.com/exercism/x-common/blob/master/CONTRIBUTING.md#git-basics) for more information.
74
74
 
75
75
 
76
76
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "purescript",
3
3
  "language": "PureScript",
4
- "repository": "https://github.com/exercism/xpurescript",
4
+ "repository": "https://github.com/exercism/purescript",
5
5
  "active": false,
6
6
  "exercises": [
7
7
  {
data/tracks/r/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # xR
1
+ # Exercism R Track
2
2
 
3
- [![Build Status](https://travis-ci.org/exercism/xr.svg?branch=master)](https://travis-ci.org/exercism/xr)
3
+ [![Build Status](https://travis-ci.org/exercism/r.svg?branch=master)](https://travis-ci.org/exercism/r)
4
4
  [![Gitter](https://badges.gitter.im/exercism/dev.svg)](https://gitter.im/exercism/dev?utm_source=share-link&utm_medium=link&utm_campaign=share-link)
5
5
 
6
6
  Exercism problems in R
@@ -39,7 +39,7 @@ Typical examples for a bug: A typo, a missing test case, an unclear or ambiguous
39
39
  - If you have a fix you can [write a pull request](#writing-a-pull-request).
40
40
 
41
41
  #### Reviewing issues and pull requests
42
- If you have a dedicated opinion you are welcome to [write a comment](https://help.github.com/articles/commenting-on-a-pull-request/) for an [issue](https://github.com/exercism/xr/issues) or a [pull request](https://github.com/exercism/xr/pulls).
42
+ If you have a dedicated opinion you are welcome to [write a comment](https://help.github.com/articles/commenting-on-a-pull-request/) for an [issue](https://github.com/exercism/r/issues) or a [pull request](https://github.com/exercism/r/pulls).
43
43
  Please be detailed and include motivations or relevant links to support your opinion.
44
44
 
45
45
  #### Porting exercises
data/tracks/r/config.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "r",
3
3
  "language": "R",
4
- "repository": "https://github.com/exercism/xr",
4
+ "repository": "https://github.com/exercism/r",
5
5
  "checklist_issue": 5,
6
6
  "active": false,
7
7
  "deprecated": [
@@ -1,4 +1,4 @@
1
- # xRacket
1
+ # Exercism Racket Track
2
2
 
3
3
  Exercism problems in Racket.
4
4
 
@@ -49,7 +49,7 @@ Prior to submitting a pull request, ensure that your test requires the stub file
49
49
 
50
50
  (run-tests suite))
51
51
  ```
52
- The exercise should also be added as a value for the `problems` key in [config.json](https://github.com/exercism/xracket/blob/master/config.json); otherwise, the pull request will not pass the Travis CI build. Use [Order of exercises](https://github.com/exercism/xracket/wiki/Order-of-exercises) in our wiki to find a good place for the new exercise in the curriculum.
52
+ The exercise should also be added as a value for the `problems` key in [config.json](https://github.com/exercism/racket/blob/master/config.json); otherwise, the pull request will not pass the Travis CI build. Use [Order of exercises](https://github.com/exercism/racket/wiki/Order-of-exercises) in our wiki to find a good place for the new exercise in the curriculum.
53
53
 
54
54
  You can perform additional checks by running the following in your terminal:
55
55
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "racket",
3
3
  "language": "Racket",
4
- "repository": "https://github.com/exercism/xracket",
4
+ "repository": "https://github.com/exercism/racket",
5
5
  "active": true,
6
6
  "exercises": [
7
7
  {
@@ -1,6 +1,6 @@
1
- # xRuby
1
+ # Exercism Ruby Track
2
2
 
3
- [![Build Status](https://travis-ci.org/exercism/xruby.svg?branch=master)](https://travis-ci.org/exercism/xruby)
3
+ [![Build Status](https://travis-ci.org/exercism/ruby.svg?branch=master)](https://travis-ci.org/exercism/ruby)
4
4
  [![Join the chat at https://gitter.im/exercism/xruby](https://badges.gitter.im/exercism/xruby.svg)](https://gitter.im/exercism/xruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5
5
 
6
6
  Exercism Exercises in Ruby
@@ -78,7 +78,7 @@ Note that flags which have an attached value, like above, must take the form
78
78
  Generated test suites use the `bin/generator` cli.
79
79
 
80
80
  Before using the cli it is recommended you run `bundle install` from within
81
- the xruby directory to install/update any required gems.
81
+ the ruby directory to install/update any required gems.
82
82
 
83
83
  While many of the exercises which have canonical data already have generators,
84
84
  some do not. To find out whether an exercise has a generator, run
@@ -94,17 +94,17 @@ generator. If a generator is available for your exercise, you can
94
94
  If not, you will need to [implement a new generator](#implementing-a-generator)
95
95
 
96
96
  Generated exercises depend on the [the shared metadata][x-common], which must be
97
- cloned to the same directory that contains your clone of the xruby repository:
97
+ cloned to the same directory that contains your clone of the ruby repository:
98
98
 
99
99
  ```
100
100
  tree -L 1 ~/code/exercism
101
101
  ├── x-common
102
- └── xruby
102
+ └── ruby
103
103
  ```
104
104
 
105
105
  #### Regenerating a Test Suite
106
106
 
107
- From within the xruby directory, run the following command:
107
+ From within the ruby directory, run the following command:
108
108
 
109
109
  bin/generate <slug>
110
110
 
@@ -167,15 +167,15 @@ important, since the generator script will infer the name of the class from
167
167
 
168
168
  This class must provide the methods used by the test
169
169
  template. A
170
- [default template](https://github.com/exercism/xruby/blob/master/lib/generator/test_template.erb) that
170
+ [default template](https://github.com/exercism/ruby/blob/master/lib/generator/test_template.erb) that
171
171
  most exercises can (and do) use lives in `lib/generator/test_template.erb`. The
172
172
  base class provides methods for the default template for everything except
173
173
  `#workload`.
174
174
 
175
175
  `#workload` generates the code for the body of a test, including the assertion
176
176
  and any setup required. The base class provides a variety of
177
- [assertion](https://github.com/exercism/xruby/blob/master/lib/generator/exercise_case/assertion.rb) and
178
- [helper](https://github.com/exercism/xruby/blob/master/lib/generator/exercise_case.rb) methods.
177
+ [assertion](https://github.com/exercism/ruby/blob/master/lib/generator/exercise_case/assertion.rb) and
178
+ [helper](https://github.com/exercism/ruby/blob/master/lib/generator/exercise_case.rb) methods.
179
179
  Beyond that, you can implement any helper methods that you need
180
180
  as private methods in your derived class. See below for more information
181
181
  about [the intention of #workload](#workload-philosophy)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "ruby",
3
3
  "language": "Ruby",
4
- "repository": "https://github.com/exercism/xruby",
4
+ "repository": "https://github.com/exercism/ruby",
5
5
  "active": true,
6
6
  "gitter": "xruby",
7
7
  "solution_pattern": "[Ee]xample|\\.meta/solutions/[^/]*\\.rb",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "rust",
3
3
  "language": "Rust",
4
- "repository": "https://github.com/exercism/xrust",
4
+ "repository": "https://github.com/exercism/rust",
5
5
  "active": true,
6
6
  "exercises": [
7
7
  {
@@ -0,0 +1,7 @@
1
+ extern crate chrono;
2
+ use chrono::*;
3
+
4
+ // Returns a UTC DateTime one billion seconds after start.
5
+ pub fn after(start: DateTime<UTC>) -> DateTime<UTC> {
6
+ unimplemented!()
7
+ }
@@ -12,29 +12,18 @@ pub fn parse<'a>(pairs: Vec<(&'a str, &'a str)>) -> CodonInfo<'a> {
12
12
 
13
13
  impl<'a> CodonInfo<'a> {
14
14
  pub fn name_for(&self, codon: &str) -> Result<&'a str, &'static str> {
15
- if codon.len() != 3 {
16
- return Err("invalid length")
17
- }
18
-
19
- let mut valid = true;
20
- let lookup: String = codon.chars().map(|l| {
21
- // Get an example of a "letter" represented by the possibly encoded letter.
22
- // Since every codon represented by the compressed notation has to be of
23
- // the desired amino acid just picking one at random will do.
24
- match l {
25
- 'A' | 'W' | 'M' | 'R' | 'D' | 'H' | 'V' | 'N' => 'A',
26
- 'C' | 'S' | 'Y' | 'B' => 'C',
27
- 'G' | 'K' => 'G',
28
- 'T' => 'T',
29
- _ => { valid = false; ' ' }
30
- }
31
- }).collect();
32
- if !valid {
33
- return Err("invalid char")
15
+ match self.actual_codons.get(&codon) {
16
+ Some(name) => Ok(name),
17
+ None => Err("Invalid")
34
18
  }
19
+ }
35
20
 
36
- // If the input table is correct (which it is) every valid codon is in it
37
- // so unwrap() shouldn't panic.
38
- Ok(self.actual_codons.get(&lookup.as_ref()).unwrap())
21
+ pub fn of_rna(&self, strand: &str) -> Result<Vec<&'a str>, &'static str> {
22
+ strand.chars()
23
+ .collect::<Vec<char>>()
24
+ .chunks(3)
25
+ .map(|chars| self.name_for(&chars.iter().collect::<String>()))
26
+ .take_while(|result| result.is_err() || result.unwrap() != "stop codon")
27
+ .collect()
39
28
  }
40
29
  }
@@ -3,54 +3,44 @@ extern crate protein_translation as proteins;
3
3
  #[test]
4
4
  fn test_methionine() {
5
5
  let info = proteins::parse(make_pairs());
6
- assert_eq!(info.name_for("ATG"), Ok("methionine"));
6
+ assert_eq!(info.name_for("AUG"), Ok("methionine"));
7
7
  }
8
8
 
9
9
  #[test]
10
10
  #[ignore]
11
11
  fn test_cysteine_tgt() {
12
12
  let info = proteins::parse(make_pairs());
13
- assert_eq!(info.name_for("TGT"), Ok("cysteine"));
14
- }
15
-
16
- #[test]
17
- #[ignore]
18
- fn test_cysteine_tgy() { // "compressed" name for TGT and TGC
19
- let info = proteins::parse(make_pairs());
20
- assert_eq!(info.name_for("TGT"), info.name_for("TGY"));
21
- assert_eq!(info.name_for("TGC"), info.name_for("TGY"));
13
+ assert_eq!(info.name_for("UGU"), Ok("cysteine"));
22
14
  }
23
15
 
24
16
  #[test]
25
17
  #[ignore]
26
18
  fn test_stop() {
27
19
  let info = proteins::parse(make_pairs());
28
- assert_eq!(info.name_for("TAA"), Ok("stop codon"));
20
+ assert_eq!(info.name_for("UAA"), Ok("stop codon"));
29
21
  }
30
22
 
31
23
  #[test]
32
24
  #[ignore]
33
25
  fn test_valine() {
34
26
  let info = proteins::parse(make_pairs());
35
- assert_eq!(info.name_for("GTN"), Ok("valine"));
27
+ assert_eq!(info.name_for("GUU"), Ok("valine"));
36
28
  }
37
29
 
38
-
39
30
  #[test]
40
31
  #[ignore]
41
32
  fn test_isoleucine() {
42
33
  let info = proteins::parse(make_pairs());
43
- assert_eq!(info.name_for("ATH"), Ok("isoleucine"));
34
+ assert_eq!(info.name_for("AUU"), Ok("isoleucine"));
44
35
  }
45
36
 
46
37
  #[test]
47
38
  #[ignore]
48
39
  fn test_arginine_name() {
49
- // In arginine CGA can be "compresed" both as CGN and as MGR
50
40
  let info = proteins::parse(make_pairs());
51
41
  assert_eq!(info.name_for("CGA"), Ok("arginine"));
52
- assert_eq!(info.name_for("CGN"), Ok("arginine"));
53
- assert_eq!(info.name_for("MGR"), Ok("arginine"));
42
+ assert_eq!(info.name_for("AGA"), Ok("arginine"));
43
+ assert_eq!(info.name_for("AGG"), Ok("arginine"));
54
44
  }
55
45
 
56
46
  #[test]
@@ -71,7 +61,7 @@ fn x_is_not_shorthand_so_is_invalid() {
71
61
  #[ignore]
72
62
  fn too_short_is_invalid() {
73
63
  let info = proteins::parse(make_pairs());
74
- assert!(info.name_for("AT").is_err());
64
+ assert!(info.name_for("AU").is_err());
75
65
  }
76
66
 
77
67
  #[test]
@@ -81,30 +71,60 @@ fn too_long_is_invalid() {
81
71
  assert!(info.name_for("ATTA").is_err());
82
72
  }
83
73
 
74
+ #[test]
75
+ #[ignore]
76
+ fn test_translates_rna_strand_into_correct_protein() {
77
+ let info = proteins::parse(make_pairs());
78
+ assert_eq!(info.of_rna("AUGUUUUGG").unwrap(),
79
+ vec!["methionine", "phenylalanine", "tryptophan"]);
80
+ }
81
+
82
+ #[test]
83
+ #[ignore]
84
+ fn test_stops_translation_if_stop_codon_present() {
85
+ let info = proteins::parse(make_pairs());
86
+ assert_eq!(info.of_rna("AUGUUUUAA").unwrap(),
87
+ vec!["methionine", "phenylalanine"]);
88
+ }
89
+
90
+ #[test]
91
+ #[ignore]
92
+ fn test_stops_translation_of_longer_strand() {
93
+ let info = proteins::parse(make_pairs());
94
+ assert_eq!(info.of_rna("UGGUGUUAUUAAUGGUUU").unwrap(),
95
+ vec!["tryptophan", "cysteine", "tyrosine"]);
96
+ }
97
+
98
+ #[test]
99
+ #[ignore]
100
+ fn test_invalid_codons() {
101
+ let info = proteins::parse(make_pairs());
102
+ assert!(info.of_rna("CARROT").is_err());
103
+ }
104
+
84
105
  // The input data constructor. Returns a list of codon, name pairs.
85
106
  fn make_pairs() -> Vec<(&'static str, &'static str)> {
86
107
  let grouped = vec![
87
- ("isoleucine", vec!["ATT", "ATC", "ATA"]),
88
- ("leucine", vec!["CTT", "CTC", "CTA", "CTG", "TTA", "TTG"]),
89
- ("valine", vec!["GTT", "GTC", "GTA", "GTG"]),
90
- ("phenylalanine", vec!["TTT", "TTC"]),
91
- ("methionine", vec!["ATG"]),
92
- ("cysteine", vec!["TGT", "TGC"]),
93
- ("alanine", vec!["GCT", "GCC", "GCA", "GCG"]),
94
- ("glycine", vec!["GGT", "GGC", "GGA", "GGG"]),
95
- ("proline", vec!["CCT", "CCC", "CCA", "CCG"]),
96
- ("threonine", vec!["ACT", "ACC", "ACA", "ACG"]),
97
- ("serine", vec!["TCT", "TCC", "TCA", "TCG", "AGT", "AGC"]),
98
- ("tyrosine", vec!["TAT", "TAC"]),
99
- ("tryptophan", vec!["TGG"]),
108
+ ("isoleucine", vec!["AUU", "AUC", "AUA"]),
109
+ ("valine", vec!["GUU", "GUC", "GUA", "GUG"]),
110
+ ("phenylalanine", vec!["UUU", "UUC"]),
111
+ ("methionine", vec!["AUG"]),
112
+ ("cysteine", vec!["UGU", "UGC"]),
113
+ ("alanine", vec!["GCU", "GCC", "GCA", "GCG"]),
114
+ ("glycine", vec!["GGU", "GGC", "GGA", "GGG"]),
115
+ ("proline", vec!["CCU", "CCC", "CCA", "CCG"]),
116
+ ("threonine", vec!["ACU", "ACC", "ACA", "ACG"]),
117
+ ("serine", vec!["AGU", "AGC"]),
118
+ ("tyrosine", vec!["UAU", "UAC"]),
119
+ ("tryptophan", vec!["UGG"]),
100
120
  ("glutamine", vec!["CAA", "CAG"]),
101
- ("asparagine", vec!["AAT", "AAC"]),
102
- ("histidine", vec!["CAT", "CAC"]),
121
+ ("asparagine", vec!["AAU", "AAC"]),
122
+ ("histidine", vec!["CAU", "CAC"]),
103
123
  ("glutamic acid", vec!["GAA", "GAG"]),
104
- ("aspartic acid", vec!["GAT", "GAC"]),
124
+ ("aspartic acid", vec!["GAU", "GAC"]),
105
125
  ("lysine", vec!["AAA", "AAG"]),
106
- ("arginine", vec!["CGT", "CGC", "CGA", "CGG", "AGA", "AGG"]),
107
- ("stop codon", vec!["TAA", "TAG", "TGA"])];
126
+ ("arginine", vec!["CGU", "CGC", "CGA", "CGG", "AGA", "AGG"]),
127
+ ("stop codon", vec!["UAA", "UAG", "UGA"])];
108
128
  let mut pairs = Vec::<(&'static str, &'static str)>::new();
109
129
  for (name, codons) in grouped.into_iter() {
110
130
  for codon in codons {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "slug": "scala",
3
3
  "language": "Scala",
4
- "repository": "https://github.com/exercism/xscala",
4
+ "repository": "https://github.com/exercism/scala",
5
5
  "active": true,
6
6
  "exercises": [
7
7
  {