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.
- checksums.yaml +4 -4
- data/fixtures/tracks/fake/docs/STRAY.md +1 -0
- data/lib/trackler/doc_file.rb +88 -0
- data/lib/trackler/track.rb +6 -40
- data/lib/trackler/version.rb +1 -1
- data/tracks/bash/README.md +2 -2
- data/tracks/bash/config.json +1 -1
- data/tracks/c/README.md +1 -1
- data/tracks/c/config.json +1 -1
- data/tracks/ceylon/README.md +4 -4
- data/tracks/ceylon/config.json +1 -1
- data/tracks/clojure/README.org +3 -3
- data/tracks/clojure/config.json +1 -1
- data/tracks/cpp/README.md +2 -2
- data/tracks/cpp/config.json +1 -1
- data/tracks/cpp/docs/INSTALLATION.md +2 -2
- data/tracks/crystal/config.json +1 -1
- data/tracks/csharp/config.json +1 -1
- data/tracks/delphi/README.md +2 -2
- data/tracks/delphi/config.json +1 -1
- data/tracks/delphi/exercises/bowling/uBowlingTests.pas +14 -14
- data/tracks/ecmascript/config.json +1 -1
- data/tracks/elisp/README.org +4 -4
- data/tracks/elisp/config.json +1 -1
- data/tracks/elixir/README.md +3 -3
- data/tracks/elixir/config.json +1 -1
- data/tracks/erlang/README.md +2 -2
- data/tracks/erlang/config.json +2 -2
- data/tracks/factor/README.md +9 -9
- data/tracks/factor/config.json +1 -1
- data/tracks/fsharp/config.json +1 -1
- data/tracks/go/README.md +16 -16
- data/tracks/go/config.json +1 -1
- data/tracks/go/exercises/gigasecond/gigasecond_test.go +2 -2
- data/tracks/go/gen/gen.go +2 -2
- data/tracks/haskell/.gitignore +1 -1
- data/tracks/haskell/README.md +12 -8
- data/tracks/haskell/config.json +1 -1
- data/tracks/haskell/docs/EXERCISE_README_INSERT.md +1 -1
- data/tracks/idris/README.md +1 -1
- data/tracks/idris/config.json +1 -1
- data/tracks/java/POLICIES.md +7 -7
- data/tracks/java/README.md +7 -7
- data/tracks/java/bin/journey-test.sh +1 -1
- data/tracks/java/config.json +1 -1
- data/tracks/java/docs/MAINTAINING.md +3 -20
- data/tracks/java/docs/TESTS.md +3 -3
- data/tracks/java/exercises/all-your-base/src/test/java/BaseConverterTest.java +23 -20
- data/tracks/java/exercises/hello-world/GETTING_STARTED.md +1 -1
- data/tracks/java/exercises/hello-world/TUTORIAL.md +2 -2
- data/tracks/javascript/config.json +1 -1
- data/tracks/julia/.travis.yml +0 -2
- data/tracks/julia/config.json +9 -0
- data/tracks/julia/exercises/custom-set/example.jl +1 -1
- data/tracks/julia/exercises/luhn/example.jl +1 -1
- data/tracks/julia/exercises/robot-name/HINTS.md +17 -0
- data/tracks/julia/exercises/robot-name/example.jl +14 -0
- data/tracks/julia/exercises/robot-name/robot-name.jl +8 -0
- data/tracks/julia/exercises/robot-name/runtests.jl +69 -0
- data/tracks/kotlin/README.md +7 -7
- data/tracks/kotlin/config.json +1 -1
- data/tracks/kotlin/docs/TESTS.md +3 -3
- data/tracks/kotlin/exercises/hello-world/GETTING_STARTED.md +1 -1
- data/tracks/kotlin/exercises/hello-world/TUTORIAL.md +1 -1
- data/tracks/lfe/README.md +2 -2
- data/tracks/lfe/config.json +1 -1
- data/tracks/lisp/README.md +1 -1
- data/tracks/lisp/config.json +2 -2
- data/tracks/lua/README.md +9 -9
- data/tracks/lua/config.json +1 -1
- data/tracks/lua/exercises/hamming/hamming_spec.lua +15 -7
- data/tracks/lua/exercises/raindrops/raindrops_spec.lua +46 -14
- data/tracks/mips/config.json +1 -1
- data/tracks/objective-c/Dangerfile +1 -1
- data/tracks/objective-c/README.md +1 -1
- data/tracks/objective-c/config.json +1 -1
- data/tracks/ocaml/README.md +2 -2
- data/tracks/ocaml/config.json +1 -1
- data/tracks/ocaml/docs/EXERCISE_README_INSERT.md +1 -1
- data/tracks/ocaml/tools/test-generator/README.md +2 -2
- data/tracks/perl5/README.md +1 -1
- data/tracks/perl5/config.json +1 -1
- data/tracks/perl6/README.md +2 -2
- data/tracks/perl6/config.json +1 -1
- data/tracks/perl6/exercises/all-your-base/all-your-base.t +43 -32
- data/tracks/perl6/exercises/all-your-base/example.yaml +19 -9
- data/tracks/php/config.json +1 -1
- data/tracks/pony/README.md +2 -2
- data/tracks/pony/config.json +1 -1
- data/tracks/powershell/README.md +1 -1
- data/tracks/powershell/config.json +1 -1
- data/tracks/purescript/README.md +5 -5
- data/tracks/purescript/config.json +1 -1
- data/tracks/r/README.md +3 -3
- data/tracks/r/config.json +1 -1
- data/tracks/racket/README.md +2 -2
- data/tracks/racket/config.json +1 -1
- data/tracks/ruby/README.md +9 -9
- data/tracks/ruby/config.json +1 -1
- data/tracks/rust/config.json +1 -1
- data/tracks/rust/exercises/gigasecond/src/lib.rs +7 -0
- data/tracks/rust/exercises/protein-translation/example.rs +11 -22
- data/tracks/rust/exercises/protein-translation/tests/proteins.rs +56 -36
- data/tracks/scala/config.json +1 -1
- data/tracks/scala/exercises/all-your-base/src/test/scala/AllYourBaseTest.scala +46 -64
- data/tracks/scala/exercises/rna-transcription/example.scala +1 -3
- data/tracks/scala/exercises/rna-transcription/src/test/scala/RnaTranscriptionTest.scala +19 -23
- data/tracks/scala/exercises/scrabble-score/example.scala +2 -2
- data/tracks/scala/exercises/scrabble-score/src/test/scala/ScrabbleScoreTest.scala +37 -16
- data/tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala +32 -42
- data/tracks/scala/testgen/src/main/scala/RnaTranscriptionTestGenerator.scala +34 -0
- data/tracks/scala/testgen/src/main/scala/ScrabbleScoreTestGenerator.scala +15 -0
- data/tracks/sml/README.md +1 -3
- data/tracks/sml/config.json +1 -1
- data/tracks/sml/docs/EXERCISE_README_INSERT.md +1 -1
- data/tracks/swift/config.json +1 -1
- data/tracks/typescript/README.md +1 -1
- data/tracks/typescript/config.json +1 -1
- data/tracks/vimscript/README.md +5 -5
- data/tracks/vimscript/config.json +8 -1
- data/tracks/vimscript/exercises/largest-series-product/example.vim +31 -0
- data/tracks/vimscript/exercises/largest-series-product/largest_series_product.vader +95 -0
- data/tracks/vimscript/exercises/largest-series-product/largest_series_product.vim +17 -0
- 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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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.
|
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": "
|
177
|
+
"description": "first base is one",
|
167
178
|
"property": "rebase",
|
168
|
-
"input_base":
|
169
|
-
"input_digits": [
|
179
|
+
"input_base": 1,
|
180
|
+
"input_digits": [],
|
170
181
|
"output_base": 10,
|
171
182
|
"expected": null
|
172
183
|
},
|
173
184
|
{
|
174
|
-
"description": "
|
185
|
+
"description": "first base is zero",
|
175
186
|
"property": "rebase",
|
176
|
-
"input_base":
|
177
|
-
"input_digits": [
|
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
|
193
|
+
"description": "first base is negative",
|
183
194
|
"property": "rebase",
|
184
|
-
"input_base":
|
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": "
|
201
|
+
"description": "negative digit",
|
191
202
|
"property": "rebase",
|
192
203
|
"input_base": 2,
|
193
|
-
"input_digits": [1,
|
194
|
-
"output_base":
|
204
|
+
"input_digits": [1, -1, 1, 0, 1, 0],
|
205
|
+
"output_base": 10,
|
195
206
|
"expected": null
|
196
207
|
},
|
197
208
|
{
|
198
|
-
"description": "
|
209
|
+
"description": "invalid positive digit",
|
199
210
|
"property": "rebase",
|
200
|
-
"input_base":
|
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
|
217
|
+
"description": "second base is one",
|
207
218
|
"property": "rebase",
|
208
|
-
"input_base":
|
209
|
-
"input_digits": [
|
210
|
-
"output_base":
|
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": "
|
225
|
+
"description": "second base is zero",
|
215
226
|
"property": "rebase",
|
216
|
-
"input_base":
|
217
|
-
"input_digits": [
|
218
|
-
"output_base":
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
data/tracks/php/config.json
CHANGED
data/tracks/pony/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Exercism Pony Track
|
2
2
|
|
3
|
-
[](https://travis-ci.org/exercism/pony)
|
4
4
|
|
5
5
|
Exercism exercises in Pony.
|
6
6
|
|
data/tracks/pony/config.json
CHANGED
data/tracks/powershell/README.md
CHANGED
data/tracks/purescript/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
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/
|
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/
|
49
|
-
[prs]: https://github.com/exercism/
|
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/
|
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
|
|
data/tracks/r/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Exercism R Track
|
2
2
|
|
3
|
-
[](https://travis-ci.org/exercism/r)
|
4
4
|
[](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/
|
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
data/tracks/racket/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
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/
|
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
|
|
data/tracks/racket/config.json
CHANGED
data/tracks/ruby/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Exercism Ruby Track
|
2
2
|
|
3
|
-
[](https://travis-ci.org/exercism/ruby)
|
4
4
|
[](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
|
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
|
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
|
-
└──
|
102
|
+
└── ruby
|
103
103
|
```
|
104
104
|
|
105
105
|
#### Regenerating a Test Suite
|
106
106
|
|
107
|
-
From within the
|
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/
|
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/
|
178
|
-
[helper](https://github.com/exercism/
|
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)
|
data/tracks/ruby/config.json
CHANGED
data/tracks/rust/config.json
CHANGED
@@ -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
|
-
|
16
|
-
|
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
|
-
|
37
|
-
|
38
|
-
|
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("
|
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("
|
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("
|
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("
|
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("
|
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("
|
53
|
-
assert_eq!(info.name_for("
|
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("
|
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!["
|
88
|
-
("
|
89
|
-
("
|
90
|
-
("
|
91
|
-
("
|
92
|
-
("
|
93
|
-
("
|
94
|
-
("
|
95
|
-
("
|
96
|
-
("
|
97
|
-
("
|
98
|
-
("
|
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!["
|
102
|
-
("histidine", vec!["
|
121
|
+
("asparagine", vec!["AAU", "AAC"]),
|
122
|
+
("histidine", vec!["CAU", "CAC"]),
|
103
123
|
("glutamic acid", vec!["GAA", "GAG"]),
|
104
|
-
("aspartic acid", vec!["
|
124
|
+
("aspartic acid", vec!["GAU", "GAC"]),
|
105
125
|
("lysine", vec!["AAA", "AAG"]),
|
106
|
-
("arginine", vec!["
|
107
|
-
("stop codon", vec!["
|
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 {
|