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
@@ -1,128 +1,110 @@
|
|
1
|
-
import org.scalatest.{FunSuite, Matchers}
|
2
1
|
|
2
|
+
import org.scalatest.{Matchers, FunSuite}
|
3
|
+
|
4
|
+
/** @version 1.1.0 */
|
3
5
|
class AllYourBaseTest extends FunSuite with Matchers {
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
test("single bit one to decimal") {
|
8
|
+
AllYourBase.rebase(2, List(1), 10) should be (Some(List(1)))
|
7
9
|
}
|
8
10
|
|
9
|
-
test("binary to single decimal") {
|
11
|
+
test("binary to single decimal") {
|
10
12
|
pending
|
11
|
-
AllYourBase.rebase(2, List(1, 0, 1),
|
12
|
-
10) should be (Some(List(5)))
|
13
|
+
AllYourBase.rebase(2, List(1, 0, 1), 10) should be (Some(List(5)))
|
13
14
|
}
|
14
15
|
|
15
|
-
test("single decimal to binary") {
|
16
|
+
test("single decimal to binary") {
|
16
17
|
pending
|
17
|
-
AllYourBase.rebase(10, List(5),
|
18
|
-
2) should be (Some(List(1 ,0 ,1)))
|
18
|
+
AllYourBase.rebase(10, List(5), 2) should be (Some(List(1, 0, 1)))
|
19
19
|
}
|
20
20
|
|
21
|
-
test("binary to multiple decimal") {
|
21
|
+
test("binary to multiple decimal") {
|
22
22
|
pending
|
23
|
-
AllYourBase.rebase(2, List(1, 0, 1, 0, 1, 0),
|
24
|
-
10) should be (Some(List(4 ,2)))
|
23
|
+
AllYourBase.rebase(2, List(1, 0, 1, 0, 1, 0), 10) should be (Some(List(4, 2)))
|
25
24
|
}
|
26
25
|
|
27
|
-
test("decimal to binary") {
|
26
|
+
test("decimal to binary") {
|
28
27
|
pending
|
29
|
-
AllYourBase.rebase(10, List(4, 2),
|
30
|
-
2) should be (Some(List(1 ,0 ,1 ,0 ,1 ,0)))
|
28
|
+
AllYourBase.rebase(10, List(4, 2), 2) should be (Some(List(1, 0, 1, 0, 1, 0)))
|
31
29
|
}
|
32
30
|
|
33
|
-
test("trinary to hexadecimal") {
|
31
|
+
test("trinary to hexadecimal") {
|
34
32
|
pending
|
35
|
-
AllYourBase.rebase(3, List(1, 1, 2, 0),
|
36
|
-
16) should be (Some(List(2 ,10)))
|
33
|
+
AllYourBase.rebase(3, List(1, 1, 2, 0), 16) should be (Some(List(2, 10)))
|
37
34
|
}
|
38
35
|
|
39
|
-
test("hexadecimal to trinary") {
|
36
|
+
test("hexadecimal to trinary") {
|
40
37
|
pending
|
41
|
-
AllYourBase.rebase(16, List(2, 10),
|
42
|
-
3) should be (Some(List(1 ,1 ,2 ,0)))
|
38
|
+
AllYourBase.rebase(16, List(2, 10), 3) should be (Some(List(1, 1, 2, 0)))
|
43
39
|
}
|
44
40
|
|
45
|
-
test("15-bit integer") {
|
41
|
+
test("15-bit integer") {
|
46
42
|
pending
|
47
|
-
AllYourBase.rebase(97, List(3, 46, 60),
|
48
|
-
73) should be (Some(List(6 ,10 ,45)))
|
43
|
+
AllYourBase.rebase(97, List(3, 46, 60), 73) should be (Some(List(6, 10, 45)))
|
49
44
|
}
|
50
45
|
|
51
|
-
test("empty list") {
|
46
|
+
test("empty list") {
|
52
47
|
pending
|
53
|
-
AllYourBase.rebase(2, List(),
|
54
|
-
10) should be (Some(List()))
|
48
|
+
AllYourBase.rebase(2, List(), 10) should be (None)
|
55
49
|
}
|
56
50
|
|
57
|
-
test("single zero") {
|
51
|
+
test("single zero") {
|
58
52
|
pending
|
59
|
-
AllYourBase.rebase(10, List(0),
|
60
|
-
2) should be (Some(List()))
|
53
|
+
AllYourBase.rebase(10, List(0), 2) should be (None)
|
61
54
|
}
|
62
55
|
|
63
|
-
test("multiple zeros") {
|
56
|
+
test("multiple zeros") {
|
64
57
|
pending
|
65
|
-
AllYourBase.rebase(10, List(0, 0, 0),
|
66
|
-
2) should be (Some(List()))
|
58
|
+
AllYourBase.rebase(10, List(0, 0, 0), 2) should be (None)
|
67
59
|
}
|
68
60
|
|
69
|
-
test("leading zeros") {
|
61
|
+
test("leading zeros") {
|
70
62
|
pending
|
71
|
-
AllYourBase.rebase(7, List(0, 6, 0),
|
72
|
-
10) should be (Some(List(4, 2)))
|
63
|
+
AllYourBase.rebase(7, List(0, 6, 0), 10) should be (None)
|
73
64
|
}
|
74
65
|
|
75
|
-
test("
|
66
|
+
test("first base is one") {
|
76
67
|
pending
|
77
|
-
AllYourBase.rebase(
|
78
|
-
10) should be (None)
|
68
|
+
AllYourBase.rebase(1, List(), 10) should be (None)
|
79
69
|
}
|
80
70
|
|
81
|
-
test("
|
71
|
+
test("first base is zero") {
|
82
72
|
pending
|
83
|
-
AllYourBase.rebase(
|
84
|
-
10) should be (None)
|
73
|
+
AllYourBase.rebase(0, List(), 10) should be (None)
|
85
74
|
}
|
86
75
|
|
87
|
-
test("first base is
|
76
|
+
test("first base is negative") {
|
88
77
|
pending
|
89
|
-
AllYourBase.rebase(
|
90
|
-
10) should be (None)
|
78
|
+
AllYourBase.rebase(-2, List(1), 10) should be (None)
|
91
79
|
}
|
92
80
|
|
93
|
-
test("
|
81
|
+
test("negative digit") {
|
94
82
|
pending
|
95
|
-
AllYourBase.rebase(2, List(1,
|
96
|
-
1) should be (None)
|
83
|
+
AllYourBase.rebase(2, List(1, -1, 1, 0, 1, 0), 10) should be (None)
|
97
84
|
}
|
98
85
|
|
99
|
-
test("
|
86
|
+
test("invalid positive digit") {
|
100
87
|
pending
|
101
|
-
AllYourBase.rebase(
|
102
|
-
10) should be (None)
|
88
|
+
AllYourBase.rebase(2, List(1, 2, 1, 0, 1, 0), 10) should be (None)
|
103
89
|
}
|
104
90
|
|
105
|
-
test("second base is
|
91
|
+
test("second base is one") {
|
106
92
|
pending
|
107
|
-
AllYourBase.rebase(
|
108
|
-
0) should be (None)
|
93
|
+
AllYourBase.rebase(2, List(1, 0, 1, 0, 1, 0), 1) should be (None)
|
109
94
|
}
|
110
95
|
|
111
|
-
test("
|
96
|
+
test("second base is zero") {
|
112
97
|
pending
|
113
|
-
AllYourBase.rebase(
|
114
|
-
10) should be (None)
|
98
|
+
AllYourBase.rebase(10, List(7), 0) should be (None)
|
115
99
|
}
|
116
100
|
|
117
|
-
test("second base is negative") {
|
101
|
+
test("second base is negative") {
|
118
102
|
pending
|
119
|
-
AllYourBase.rebase(2, List(1),
|
120
|
-
-7) should be (None)
|
103
|
+
AllYourBase.rebase(2, List(1), -7) should be (None)
|
121
104
|
}
|
122
105
|
|
123
|
-
test("both bases are negative") {
|
106
|
+
test("both bases are negative") {
|
124
107
|
pending
|
125
|
-
AllYourBase.rebase(-2, List(1),
|
126
|
-
-7) should be (None)
|
108
|
+
AllYourBase.rebase(-2, List(1), -7) should be (None)
|
127
109
|
}
|
128
110
|
}
|
@@ -1,48 +1,44 @@
|
|
1
1
|
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Dna.toRna("") should be (Some(""))
|
6
|
-
}
|
3
|
+
/** @version 1.0.0 */
|
4
|
+
class RnaTranscriptionTest extends FunSuite with Matchers {
|
7
5
|
|
8
|
-
test("
|
9
|
-
|
10
|
-
Dna.toRna("C") should be (Some("G"))
|
6
|
+
test("rna complement of cytosine is guanine") {
|
7
|
+
RnaTranscription.toRna("C") should be (Some("G"))
|
11
8
|
}
|
12
9
|
|
13
|
-
test("
|
10
|
+
test("rna complement of guanine is cytosine") {
|
14
11
|
pending
|
15
|
-
|
12
|
+
RnaTranscription.toRna("G") should be (Some("C"))
|
16
13
|
}
|
17
14
|
|
18
|
-
test("
|
15
|
+
test("rna complement of thymine is adenine") {
|
19
16
|
pending
|
20
|
-
|
17
|
+
RnaTranscription.toRna("T") should be (Some("A"))
|
21
18
|
}
|
22
19
|
|
23
|
-
test("
|
20
|
+
test("rna complement of adenine is uracil") {
|
24
21
|
pending
|
25
|
-
|
22
|
+
RnaTranscription.toRna("A") should be (Some("U"))
|
26
23
|
}
|
27
24
|
|
28
|
-
test("
|
25
|
+
test("rna complement") {
|
29
26
|
pending
|
30
|
-
|
27
|
+
RnaTranscription.toRna("ACGTGGTCTTAA") should be (Some("UGCACCAGAAUU"))
|
31
28
|
}
|
32
29
|
|
33
|
-
test("
|
30
|
+
test("dna correctly handles invalid input") {
|
34
31
|
pending
|
35
|
-
|
32
|
+
RnaTranscription.toRna("U") should be (None)
|
36
33
|
}
|
37
34
|
|
38
|
-
test("
|
35
|
+
test("dna correctly handles completely invalid input") {
|
39
36
|
pending
|
40
|
-
|
37
|
+
RnaTranscription.toRna("XXX") should be (None)
|
41
38
|
}
|
42
39
|
|
43
|
-
test("
|
40
|
+
test("dna correctly handles partially invalid input") {
|
44
41
|
pending
|
45
|
-
|
42
|
+
RnaTranscription.toRna("ACGTXXXCTTAA") should be (None)
|
46
43
|
}
|
47
|
-
}
|
48
|
-
|
44
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
object
|
1
|
+
object ScrabbleScore {
|
2
2
|
|
3
|
-
def
|
3
|
+
def score(word: String): Int = word.foldLeft(0)((score, c) => score + scoreLetter(c))
|
4
4
|
|
5
5
|
def scoreLetter(c: Char): Int = letterScores.getOrElse(c.toUpper, 0)
|
6
6
|
|
@@ -1,38 +1,59 @@
|
|
1
1
|
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
/** @version 1.0.0 */
|
4
|
+
class ScrabbleScoreTest extends FunSuite with Matchers {
|
5
|
+
|
6
|
+
test("lowercase letter") {
|
7
|
+
ScrabbleScore.score("a") should be (1)
|
8
|
+
}
|
9
|
+
|
10
|
+
test("uppercase letter") {
|
11
|
+
pending
|
12
|
+
ScrabbleScore.score("A") should be (1)
|
13
|
+
}
|
14
|
+
|
15
|
+
test("valuable letter") {
|
16
|
+
pending
|
17
|
+
ScrabbleScore.score("f") should be (4)
|
18
|
+
}
|
19
|
+
|
20
|
+
test("short word") {
|
21
|
+
pending
|
22
|
+
ScrabbleScore.score("at") should be (2)
|
6
23
|
}
|
7
24
|
|
8
|
-
test("
|
25
|
+
test("short, valuable word") {
|
9
26
|
pending
|
10
|
-
|
27
|
+
ScrabbleScore.score("zoo") should be (12)
|
11
28
|
}
|
12
29
|
|
13
|
-
test("
|
30
|
+
test("medium word") {
|
14
31
|
pending
|
15
|
-
|
32
|
+
ScrabbleScore.score("street") should be (6)
|
16
33
|
}
|
17
34
|
|
18
|
-
test("
|
35
|
+
test("medium, valuable word") {
|
19
36
|
pending
|
20
|
-
|
37
|
+
ScrabbleScore.score("quirky") should be (22)
|
21
38
|
}
|
22
39
|
|
23
|
-
test("
|
40
|
+
test("long, mixed-case word") {
|
24
41
|
pending
|
25
|
-
|
42
|
+
ScrabbleScore.score("OxyphenButazone") should be (41)
|
26
43
|
}
|
27
44
|
|
28
|
-
test("
|
45
|
+
test("english-like word") {
|
29
46
|
pending
|
30
|
-
|
47
|
+
ScrabbleScore.score("pinata") should be (8)
|
31
48
|
}
|
32
49
|
|
33
|
-
test("
|
50
|
+
test("empty input") {
|
34
51
|
pending
|
35
|
-
|
52
|
+
ScrabbleScore.score("") should be (0)
|
36
53
|
}
|
37
|
-
}
|
38
54
|
|
55
|
+
test("entire alphabet available") {
|
56
|
+
pending
|
57
|
+
ScrabbleScore.score("abcdefghijklmnopqrstuvwxyz") should be (87)
|
58
|
+
}
|
59
|
+
}
|
@@ -1,48 +1,38 @@
|
|
1
|
-
import
|
1
|
+
import java.io.File
|
2
2
|
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
class AllYourBaseTestGenerator {
|
7
|
-
implicit val testCaseReader = Json.reads[AllYourBaseTestCase]
|
8
|
-
|
9
|
-
private val filename = "all-your-base.json"
|
10
|
-
private val fileContents = Source.fromFile(filename).getLines.mkString
|
11
|
-
private val json = Json.parse(fileContents)
|
12
|
-
|
13
|
-
def write {
|
14
|
-
val testCases: List[AllYourBaseTestCase] = (json \ "cases").get.as[List[AllYourBaseTestCase]]
|
15
|
-
|
16
|
-
implicit def testCaseToGen(tc: AllYourBaseTestCase): TestCaseGen = {
|
17
|
-
val callSUT =
|
18
|
-
s"AllYourBase.rebase(${tc.input_base}, ${toListString(tc.input_digits)}, ${tc.output_base})"
|
19
|
-
val expected = toListString(tc.output_digits)
|
20
|
-
|
21
|
-
TestCaseGen(tc.description, callSUT, expected)
|
22
|
-
}
|
23
|
-
|
24
|
-
val testBuilder = new TestBuilder("AllYourBaseTest")
|
25
|
-
testBuilder.addTestCases(testCases)
|
26
|
-
testBuilder.toFile
|
27
|
-
}
|
28
|
-
|
29
|
-
private def toListString(a: Array[Int]): String =
|
30
|
-
"List(" + a.mkString(", ") + ")"
|
31
|
-
|
32
|
-
private def toListString(o: Option[Array[Int]]): String = {
|
33
|
-
o match {
|
34
|
-
case Some(a) => "Some(List(" + a.mkString(" ,") + "))"
|
35
|
-
case None => "None"
|
36
|
-
}
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
case class AllYourBaseTestCase(description: String,
|
41
|
-
input_base: Int, input_digits: Array[Int],
|
42
|
-
output_base: Int, output_digits: Option[Array[Int]])
|
3
|
+
import testgen.TestSuiteBuilder.{toString, _}
|
4
|
+
import testgen._
|
43
5
|
|
44
6
|
object AllYourBaseTestGenerator {
|
45
7
|
def main(args: Array[String]): Unit = {
|
46
|
-
new
|
8
|
+
val file = new File("src/main/resources/all-your-base.json")
|
9
|
+
|
10
|
+
def toString(expected: CanonicalDataParser.Expected): String = {
|
11
|
+
expected match {
|
12
|
+
case Left(_) => "None"
|
13
|
+
case Right(null) => "None"
|
14
|
+
case Right(n) => s"Some($n)"
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
def fromLabeledTest(argNames: String*): ToTestCaseData =
|
19
|
+
withLabeledTest { sut =>
|
20
|
+
labeledTest =>
|
21
|
+
val args = sutArgs(labeledTest.result, argNames: _*)
|
22
|
+
val property = labeledTest.property
|
23
|
+
val sutCall =
|
24
|
+
s"""AllYourBase.$property($args)"""
|
25
|
+
val expected = toString(labeledTest.expected)
|
26
|
+
TestCaseData(labeledTest.description, sutCall, expected)
|
27
|
+
}
|
28
|
+
|
29
|
+
val code =
|
30
|
+
TestSuiteBuilder.build(file,
|
31
|
+
fromLabeledTest("input_base", "input_digits", "output_base"))
|
32
|
+
println(s"-------------")
|
33
|
+
println(code)
|
34
|
+
println(s"-------------")
|
35
|
+
|
36
|
+
TestSuiteBuilder.writeToFile(code, new File("AllYourBaseTest.scala"))
|
47
37
|
}
|
48
38
|
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder._
|
4
|
+
import testgen._
|
5
|
+
|
6
|
+
object RnaTranscriptionTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("src/main/resources/rna-transcription.json")
|
9
|
+
|
10
|
+
def toString(expected: CanonicalDataParser.Expected): String = {
|
11
|
+
expected match {
|
12
|
+
case Left(_) => "None"
|
13
|
+
case Right(null) => "None"
|
14
|
+
case Right(n) => s"""Some(\"$n\")"""
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
def fromLabeledTest(argNames: String*): ToTestCaseData =
|
19
|
+
withLabeledTest { sut =>
|
20
|
+
labeledTest =>
|
21
|
+
val args = sutArgs(labeledTest.result, argNames: _*)
|
22
|
+
val property = labeledTest.property
|
23
|
+
val sutCall =
|
24
|
+
s"""RnaTranscription.$property($args)"""
|
25
|
+
val expected = toString(labeledTest.expected)
|
26
|
+
TestCaseData(labeledTest.description, sutCall, expected)
|
27
|
+
}
|
28
|
+
|
29
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("dna"))
|
30
|
+
println(s"-------------")
|
31
|
+
println(code)
|
32
|
+
println(s"-------------")
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import java.io.File
|
2
|
+
|
3
|
+
import testgen.TestSuiteBuilder
|
4
|
+
import testgen.TestSuiteBuilder.fromLabeledTest
|
5
|
+
|
6
|
+
object ScrabbleScoreTestGenerator {
|
7
|
+
def main(args: Array[String]): Unit = {
|
8
|
+
val file = new File("src/main/resources/scrabble-score.json")
|
9
|
+
|
10
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
|
11
|
+
println(s"-------------")
|
12
|
+
println(code)
|
13
|
+
println(s"-------------")
|
14
|
+
}
|
15
|
+
}
|
data/tracks/sml/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Exercism Standard ML Track
|
2
2
|
|
3
3
|
Exercism problems in the Standard ML programming language
|
4
4
|
|
@@ -9,5 +9,3 @@ Please see SETUP.md for instructions on how to get started solving the SML exerc
|
|
9
9
|
## Contributing Guide
|
10
10
|
|
11
11
|
Please see the [contributing guide](https://github.com/exercism/x-api/blob/master/CONTRIBUTING.md#the-exercise-data)
|
12
|
-
|
13
|
-
|
data/tracks/sml/config.json
CHANGED
data/tracks/swift/config.json
CHANGED
data/tracks/typescript/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# TypeScript [](https://travis-ci.org/exercism/typescript)
|
2
2
|
|
3
3
|
Exercism exercises in TypeScript
|
4
4
|
|
data/tracks/vimscript/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# Exercism Vim script Track
|
2
2
|
|
3
|
-

|
4
4
|
[](https://gitter.im/exercism/xvimscript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
5
5
|
|
6
6
|
Exercism exercises in Vim script.
|
@@ -10,12 +10,12 @@ Exercism exercises in Vim script.
|
|
10
10
|
We welcome any kind of contribution!
|
11
11
|
|
12
12
|
If you have a suggestion or question, create a new
|
13
|
-
[issue](https://github.com/exercism/
|
13
|
+
[issue](https://github.com/exercism/vimscript/issues).
|
14
14
|
|
15
15
|
For code or fixing typos and similar things, open a
|
16
|
-
[pull request](https://github.com/exercism/
|
16
|
+
[pull request](https://github.com/exercism/vimscript/pulls).
|
17
17
|
|
18
|
-
Look at recent [commits](https://github.com/exercism/
|
18
|
+
Look at recent [commits](https://github.com/exercism/vimscript/commits/master)
|
19
19
|
to get a feeling on how to format your own ones.
|
20
20
|
|
21
21
|
Even if there are any uncertainties, go for it nevertheless. We can straighten
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"slug": "vimscript",
|
3
3
|
"language": "Vim script",
|
4
|
-
"repository": "https://github.com/exercism/
|
4
|
+
"repository": "https://github.com/exercism/vimscript",
|
5
5
|
"active": true,
|
6
6
|
"test_pattern": "\\.vader$",
|
7
7
|
"exercises": [
|
@@ -129,6 +129,13 @@
|
|
129
129
|
"difficulty": 1,
|
130
130
|
"topics": [
|
131
131
|
|
132
|
+
]
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"slug": "largest-series-product",
|
136
|
+
"difficulty": 1,
|
137
|
+
"topics": [
|
138
|
+
|
132
139
|
]
|
133
140
|
}
|
134
141
|
],
|
@@ -0,0 +1,31 @@
|
|
1
|
+
function! LargestProduct(digits, span) abort
|
2
|
+
if a:span == 0
|
3
|
+
return 1
|
4
|
+
elseif a:span < 0 || empty(a:digits)
|
5
|
+
return -1
|
6
|
+
endif
|
7
|
+
|
8
|
+
let max = -1
|
9
|
+
|
10
|
+
for i in range(len(a:digits) - a:span + 1)
|
11
|
+
let tmp = s:product(a:digits[i : i + a:span - 1])
|
12
|
+
if tmp > max
|
13
|
+
let max = tmp
|
14
|
+
endif
|
15
|
+
endfor
|
16
|
+
|
17
|
+
return max
|
18
|
+
endfunction
|
19
|
+
|
20
|
+
function! s:product(digits) abort
|
21
|
+
let prod = a:digits[0]
|
22
|
+
|
23
|
+
for digit in split(a:digits[1:], '\zs')
|
24
|
+
if digit !~? '\d'
|
25
|
+
throw 'invalid input'
|
26
|
+
endif
|
27
|
+
let prod = prod * digit
|
28
|
+
endfor
|
29
|
+
|
30
|
+
return prod
|
31
|
+
endfunction
|