trackler 2.2.1.29 → 2.2.1.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/tracks/common-lisp/docs/ABOUT.md +5 -10
- data/tracks/csharp/.gitignore +6 -8
- data/tracks/csharp/generators/Options.cs +1 -1
- data/tracks/csharp/generators/Program.cs +5 -1
- data/tracks/delphi/config.json +157 -157
- data/tracks/delphi/config/maintainers.json +11 -11
- data/tracks/delphi/exercises/circular-buffer/README.md +13 -6
- data/tracks/ecmascript/config.json +12 -0
- data/tracks/ecmascript/exercises/custom-set/custom-set.spec.js +198 -91
- data/tracks/ecmascript/exercises/custom-set/example.js +22 -31
- data/tracks/ecmascript/exercises/simple-linked-list/README.md +57 -0
- data/tracks/ecmascript/exercises/simple-linked-list/example.js +111 -0
- data/tracks/ecmascript/exercises/simple-linked-list/package.json +69 -0
- data/tracks/ecmascript/exercises/simple-linked-list/simple-linked-list.spec.js +146 -0
- data/tracks/go/.travis.yml +2 -2
- data/tracks/go/exercises/perfect-numbers/perfect_numbers_test.go +8 -0
- data/tracks/powershell/docs/INSTRUCTIONS.md +14 -0
- data/tracks/scala/exercises/variable-length-quantity/src/main/scala/{VariableLengthQuantity.scala → .keep} +0 -0
- data/tracks/scala/exercises/variable-length-quantity/src/test/scala/VariableLengthQuantityTest.scala +73 -82
- data/tracks/scala/testgen/src/main/scala/VariableLengthQuantityTestGenerator.scala +58 -59
- metadata +8 -3
@@ -1,80 +1,79 @@
|
|
1
|
-
import
|
1
|
+
import java.io.File
|
2
2
|
|
3
|
-
import
|
3
|
+
import testgen.{CanonicalDataParser, TestCaseData, TestSuiteBuilder}
|
4
|
+
import TestSuiteBuilder._
|
4
5
|
|
5
|
-
|
6
|
-
class VariableLengthQuantityTestGenerator {
|
7
|
-
implicit val vlqTestCaseReader = Json.reads[VlqTestCase]
|
8
|
-
|
9
|
-
private val filename = "variable-length-quantity.json"
|
10
|
-
private val fileContents = Source.fromFile(filename).getLines.mkString
|
11
|
-
private val json = Json.parse(fileContents)
|
6
|
+
object VariableLengthQuantityTestGenerator {
|
12
7
|
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
private def mapListToString(arg: List[_]): String = {
|
9
|
+
s"List(${arg
|
10
|
+
.map {
|
11
|
+
case d: Double => "0x" + d.toLong.toHexString.toUpperCase
|
12
|
+
case i: Int => "0x" + i.toLong.toHexString.toUpperCase
|
13
|
+
case _ => throw new IllegalArgumentException()
|
14
|
+
}
|
15
|
+
.mkString(", ")})"
|
18
16
|
}
|
19
17
|
|
20
|
-
private def
|
21
|
-
|
22
|
-
|
23
|
-
case
|
24
|
-
case Right(
|
25
|
-
}
|
26
|
-
|
27
|
-
implicit def testCaseToGen(tc: VlqTestCase): TestCaseGen = {
|
28
|
-
val callSUT = s"""VariableLengthQuantity.encode(${listToStr(tc.input)})"""
|
29
|
-
val expected = listToStr(tc.expected)
|
30
|
-
val result = s"val encoded = $callSUT"
|
31
|
-
val checkResult = s"""encoded should be ($expected)"""
|
32
|
-
|
33
|
-
TestCaseGen("encode: " + tc.description, callSUT, expected, result, checkResult)
|
18
|
+
private def toEncodeString(expected: CanonicalDataParser.Expected): String = {
|
19
|
+
expected match {
|
20
|
+
case Left(_) => "None"
|
21
|
+
case Right(null) => "None"
|
22
|
+
case Right(n) => s"${mapListToString(n.asInstanceOf[List[_]])}"
|
34
23
|
}
|
35
|
-
|
36
|
-
testBuilder.addTestCases(encodeTestCases, Some(description))
|
37
24
|
}
|
38
25
|
|
39
|
-
private def
|
40
|
-
|
41
|
-
|
42
|
-
case
|
43
|
-
case Right(
|
26
|
+
private def toDecodeString(expected: CanonicalDataParser.Expected): String = {
|
27
|
+
expected match {
|
28
|
+
case Left(_) => "true"
|
29
|
+
case Right(null) => "true"
|
30
|
+
case Right(n) => s"Right(${mapListToString(n.asInstanceOf[List[Any]])})"
|
44
31
|
}
|
32
|
+
}
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
case
|
34
|
+
private def toSutCall(sut: String, property: String, args: String, expected: CanonicalDataParser.Expected): String = {
|
35
|
+
if (property.toString.equals("encode"))
|
36
|
+
s"""$sut.$property($args)"""
|
37
|
+
else {
|
38
|
+
expected match {
|
39
|
+
case Left(_) => s"""$sut.$property($args).isLeft"""
|
40
|
+
case Right(null) => s"""$sut.$property($args).isLeft"""
|
41
|
+
case Right(n) => s"""$sut.$property($args)"""
|
52
42
|
}
|
53
|
-
val result = s"val decoded = $callSUT"
|
54
|
-
|
55
|
-
TestCaseGen("decode: " + tc.description, callSUT, "", result, checkResult)
|
56
43
|
}
|
57
|
-
|
58
|
-
testBuilder.addTestCases(decodeTestCases, Some(description))
|
59
44
|
}
|
60
45
|
|
61
|
-
private def
|
62
|
-
|
63
|
-
case
|
64
|
-
case
|
46
|
+
private def toArgString(any: Any): String = {
|
47
|
+
any match {
|
48
|
+
case list: List[_] => s"${mapListToString(list)}"
|
49
|
+
case _ => any.toString
|
65
50
|
}
|
66
51
|
}
|
67
52
|
|
68
|
-
private def
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
53
|
+
private def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
|
54
|
+
argNames map (name => toArgString(parseResult(name))) mkString ", "
|
55
|
+
|
56
|
+
|
57
|
+
def fromLabeledTest(argNames: String*): ToTestCaseData =
|
58
|
+
withLabeledTest { sut =>
|
59
|
+
labeledTest =>
|
60
|
+
val args = sutArgs(labeledTest.result, argNames: _*)
|
61
|
+
val property = labeledTest.property
|
62
|
+
val sutCall = toSutCall(sut, property, args, labeledTest.expected)
|
63
|
+
val expected =
|
64
|
+
if (labeledTest.property.toString.equals("encode"))
|
65
|
+
toEncodeString(labeledTest.expected)
|
66
|
+
else
|
67
|
+
toDecodeString(labeledTest.expected)
|
68
|
+
TestCaseData(labeledTest.description, sutCall, expected)
|
69
|
+
}
|
75
70
|
|
76
|
-
object VariableLengthQuantityTestGenerator {
|
77
71
|
def main(args: Array[String]): Unit = {
|
78
|
-
new
|
72
|
+
val file = new File("src/main/resources/variable-length-quantity.json")
|
73
|
+
|
74
|
+
val code = TestSuiteBuilder.build(file, fromLabeledTest("input"))
|
75
|
+
println(s"-------------")
|
76
|
+
println(code)
|
77
|
+
println(s"-------------")
|
79
78
|
}
|
80
79
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trackler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.1.
|
4
|
+
version: 2.2.1.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katrina Owen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -3180,6 +3180,10 @@ files:
|
|
3180
3180
|
- tracks/ecmascript/exercises/simple-cipher/example.js
|
3181
3181
|
- tracks/ecmascript/exercises/simple-cipher/package.json
|
3182
3182
|
- tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js
|
3183
|
+
- tracks/ecmascript/exercises/simple-linked-list/README.md
|
3184
|
+
- tracks/ecmascript/exercises/simple-linked-list/example.js
|
3185
|
+
- tracks/ecmascript/exercises/simple-linked-list/package.json
|
3186
|
+
- tracks/ecmascript/exercises/simple-linked-list/simple-linked-list.spec.js
|
3183
3187
|
- tracks/ecmascript/exercises/space-age/README.md
|
3184
3188
|
- tracks/ecmascript/exercises/space-age/example.js
|
3185
3189
|
- tracks/ecmascript/exercises/space-age/package.json
|
@@ -9319,6 +9323,7 @@ files:
|
|
9319
9323
|
- tracks/powershell/config/exercise_readme.go.tmpl
|
9320
9324
|
- tracks/powershell/config/maintainers.json
|
9321
9325
|
- tracks/powershell/docs/EXERCISE_README_INSERT.md
|
9326
|
+
- tracks/powershell/docs/INSTRUCTIONS.md
|
9322
9327
|
- tracks/powershell/docs/SNIPPET.txt
|
9323
9328
|
- tracks/powershell/exercises/hamming/.version
|
9324
9329
|
- tracks/powershell/exercises/hamming/README.md
|
@@ -11536,7 +11541,7 @@ files:
|
|
11536
11541
|
- tracks/scala/exercises/variable-length-quantity/README.md
|
11537
11542
|
- tracks/scala/exercises/variable-length-quantity/build.sbt
|
11538
11543
|
- tracks/scala/exercises/variable-length-quantity/example.scala
|
11539
|
-
- tracks/scala/exercises/variable-length-quantity/src/main/scala
|
11544
|
+
- tracks/scala/exercises/variable-length-quantity/src/main/scala/.keep
|
11540
11545
|
- tracks/scala/exercises/variable-length-quantity/src/test/scala/VariableLengthQuantityTest.scala
|
11541
11546
|
- tracks/scala/exercises/word-count/README.md
|
11542
11547
|
- tracks/scala/exercises/word-count/build.sbt
|