trackler 2.0.6.40 → 2.0.6.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/exercises/book-store/canonical-data.json +7 -1
- data/common/exercises/rotational-cipher/{cannonical-data.json → canonical-data.json} +0 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/config.json +9 -0
- data/tracks/c/exercises/triangle/makefile +16 -0
- data/tracks/c/exercises/triangle/src/example.c +33 -0
- data/tracks/c/exercises/triangle/src/example.h +15 -0
- data/tracks/c/exercises/triangle/src/triangle.h +10 -0
- data/tracks/c/exercises/triangle/test/test_triangle.c +121 -0
- data/tracks/c/exercises/triangle/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/triangle/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/triangle/test/vendor/unity_internals.h +701 -0
- data/tracks/clojure/.gitignore +1 -0
- data/tracks/clojure/_src/clock_generator.clj +5 -0
- data/tracks/clojure/_src/generator.clj +72 -0
- data/tracks/clojure/config.json +6 -0
- data/tracks/clojure/exercises/clock/clock.mustache +34 -0
- data/tracks/clojure/exercises/clock/project.clj +4 -0
- data/tracks/clojure/exercises/clock/src/example.clj +19 -0
- data/tracks/clojure/exercises/clock/test/clock_test.clj +177 -0
- data/tracks/clojure/project.clj +4 -1
- data/tracks/csharp/exercises/poker/Example.cs +1 -1
- data/tracks/csharp/exercises/poker/PokerTest.cs +10 -0
- data/tracks/erlang/docs/INSTALLATION.md +14 -3
- data/tracks/erlang/docs/LEARNING.md +1 -0
- data/tracks/go/exercises/gigasecond/gigasecond_test.go +5 -2
- data/tracks/go/exercises/grade-school/example.go +2 -0
- data/tracks/go/exercises/grade-school/grade_school_test.go +8 -0
- data/tracks/go/exercises/hamming/hamming_test.go +1 -1
- data/tracks/go/exercises/hello-world/hello_test.go +6 -4
- data/tracks/haskell/exercises/accumulate/src/Accumulate.hs +1 -1
- data/tracks/haskell/exercises/anagram/src/Anagram.hs +1 -1
- data/tracks/java/bin/journey-test.sh +21 -4
- data/tracks/java/exercises/allergies/src/example/java/Allergen.java +20 -0
- data/tracks/java/exercises/hamming/src/test/java/HammingTest.java +10 -3
- data/tracks/java/exercises/luhn/src/example/java/LuhnValidator.java +19 -11
- data/tracks/java/exercises/luhn/src/test/java/LuhnValidatorTest.java +43 -1
- data/tracks/java/exercises/meetup/src/example/java/MeetupSchedule.java +8 -0
- data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +91 -91
- data/tracks/java/exercises/perfect-numbers/src/example/java/Classification.java +5 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +29 -0
- data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +5 -0
- data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +5 -0
- data/tracks/java/exercises/sublist/src/example/java/Relationship.java +5 -0
- data/tracks/java/exercises/triangle/src/example/java/TriangleException.java +5 -0
- data/tracks/java/exercises/triangle/src/example/java/TriangleKind.java +5 -0
- data/tracks/julia/config.json +10 -1
- data/tracks/julia/exercises/atbash-cipher/runtests.jl +36 -36
- data/tracks/julia/exercises/pangram/example.jl +2 -0
- data/tracks/julia/exercises/pangram/pangram.jl +4 -0
- data/tracks/julia/exercises/pangram/runtests.jl +40 -0
- data/tracks/perl5/exercises/bob/Example.pm +1 -1
- data/tracks/perl5/exercises/bob/bob.t +27 -31
- data/tracks/php/exercises/accumulate/accumulate_test.php +1 -1
- data/tracks/php/exercises/acronym/acronym_test.php +1 -1
- data/tracks/php/exercises/allergies/allergies_test.php +1 -1
- data/tracks/php/exercises/anagram/anagram_test.php +1 -1
- data/tracks/php/exercises/atbash-cipher/atbash-cipher_test.php +1 -1
- data/tracks/php/exercises/beer-song/beer-song_test.php +1 -1
- data/tracks/php/exercises/binary/binary_test.php +2 -2
- data/tracks/php/exercises/bob/bob_test.php +1 -1
- data/tracks/php/exercises/book-store/book-store_test.php +1 -1
- data/tracks/php/exercises/bowling/bowling_test.php +1 -1
- data/tracks/php/exercises/bracket-push/bracket-push_test.php +1 -1
- data/tracks/php/exercises/change/change_test.php +3 -3
- data/tracks/php/exercises/clock/clock_test.php +1 -1
- data/tracks/php/exercises/connect/connect_test.php +1 -1
- data/tracks/php/exercises/difference-of-squares/difference-of-squares_test.php +1 -1
- data/tracks/php/exercises/etl/etl_test.php +1 -1
- data/tracks/php/exercises/gigasecond/gigasecond_test.php +1 -1
- data/tracks/php/exercises/grains/grains_test.php +1 -1
- data/tracks/php/exercises/hamming/hamming_test.php +2 -2
- data/tracks/php/exercises/hello-world/hello-world_test.php +1 -1
- data/tracks/php/exercises/isogram/isogram_test.php +1 -1
- data/tracks/php/exercises/largest-series-product/largest-series-product_test.php +1 -1
- data/tracks/php/exercises/leap/leap_test.php +1 -1
- data/tracks/php/exercises/markdown/markdown_test.php +1 -1
- data/tracks/php/exercises/minesweeper/minesweeper_test.php +7 -7
- data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +1 -1
- data/tracks/php/exercises/ocr-numbers/ocr-numbers_test.php +1 -1
- data/tracks/php/exercises/pangram/pangram_test.php +1 -1
- data/tracks/php/exercises/phone-number/phone-number_test.php +1 -1
- data/tracks/php/exercises/pig-latin/pig-latin_test.php +1 -1
- data/tracks/php/exercises/raindrops/raindrops_test.php +1 -1
- data/tracks/php/exercises/rna-transcription/rna-transcription_test.php +1 -1
- data/tracks/php/exercises/robot-name/robot-name_test.php +1 -1
- data/tracks/php/exercises/robot-simulator/robot-simulator_test.php +1 -1
- data/tracks/php/exercises/roman-numerals/roman-numerals_test.php +1 -1
- data/tracks/php/exercises/sieve/sieve_test.php +1 -1
- data/tracks/php/exercises/space-age/space-age_test.php +1 -1
- data/tracks/php/exercises/triangle/triangle_test.php +1 -1
- data/tracks/php/exercises/trinary/trinary_test.php +1 -1
- data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +3 -3
- data/tracks/php/exercises/word-count/word-count_test.php +1 -1
- data/tracks/php/exercises/wordy/wordy_test.php +3 -3
- data/tracks/python/config.json +3 -13
- data/tracks/python/exercises/rectangles/rectangles_count_test.py +15 -22
- data/tracks/scala/config.json +684 -665
- data/tracks/scala/exercises/binary-search/build.sbt +3 -0
- data/tracks/scala/exercises/binary-search/example.scala +23 -0
- data/tracks/scala/exercises/binary-search/src/main/scala/BinarySearch.scala +0 -0
- data/tracks/scala/exercises/binary-search/src/test/scala/BinarySearchTest.scala +63 -0
- data/tracks/scala/exercises/strain/build.sbt +3 -0
- data/tracks/scala/exercises/strain/example.scala +22 -0
- data/tracks/scala/exercises/strain/src/main/scala/Strain.scala +0 -0
- data/tracks/scala/exercises/strain/src/test/scala/StrainTest.scala +78 -0
- data/tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala +13 -20
- data/tracks/scala/testgen/src/main/scala/BinarySearchTestGenerator.scala +48 -0
- data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +24 -32
- data/tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala +148 -112
- data/tracks/scala/testgen/src/main/scala/TestBuilder.scala +86 -0
- metadata +30 -3
- data/tracks/java/exercises/allergies/src/example/java/Allergen.java +0 -1
- data/tracks/java/exercises/meetup/src/example/java/MeetupSchedule.java +0 -1
- data/tracks/java/exercises/perfect-numbers/src/example/java/Classification.java +0 -1
- data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +0 -1
- data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +0 -1
- data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +0 -1
- data/tracks/java/exercises/sublist/src/example/java/Relationship.java +0 -1
- data/tracks/java/exercises/triangle/src/example/java/TriangleException.java +0 -1
- data/tracks/java/exercises/triangle/src/example/java/TriangleKind.java +0 -1
@@ -2,7 +2,7 @@ import play.api.libs.json.Json
|
|
2
2
|
|
3
3
|
import scala.io.Source
|
4
4
|
|
5
|
-
// Generates test suite from json test
|
5
|
+
// Generates test suite from json test definition for the CustomSet exercise.
|
6
6
|
class CustomSetTestGenerator {
|
7
7
|
implicit val emptyTestCaseReader = Json.reads[EmptyTestCase]
|
8
8
|
implicit val containsTestCasesReader = Json.reads[ContainsTestCase]
|
@@ -19,175 +19,211 @@ class CustomSetTestGenerator {
|
|
19
19
|
private val json = Json.parse(fileContents)
|
20
20
|
|
21
21
|
def write {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
writeDifferenceTests()
|
34
|
-
writeUnionTests()
|
35
|
-
|
36
|
-
print("}" + System.lineSeparator())
|
22
|
+
val testBuilder = new TestBuilder("CustomSetTest")
|
23
|
+
addEmptyTests(testBuilder)
|
24
|
+
addContainsTests(testBuilder)
|
25
|
+
addSubsetTests(testBuilder)
|
26
|
+
addDisjointTests(testBuilder)
|
27
|
+
addEqualTests(testBuilder)
|
28
|
+
addAddTests(testBuilder)
|
29
|
+
addIntersectionTests(testBuilder)
|
30
|
+
addDifferenceTests(testBuilder)
|
31
|
+
addUnionTests(testBuilder)
|
32
|
+
testBuilder.toFile
|
37
33
|
}
|
38
34
|
|
39
|
-
private def
|
40
|
-
|
35
|
+
private def addEmptyTests(testBuilder: TestBuilder): Unit = {
|
36
|
+
val description =
|
37
|
+
"Empty test cases - " + (json \ "empty" \ "description").get.as[String]
|
41
38
|
|
42
39
|
val emptyTestCases = (json \ "empty" \ "cases").get.as[List[EmptyTestCase]]
|
43
40
|
|
44
|
-
|
45
|
-
|
41
|
+
implicit def testCaseToGen(tc: EmptyTestCase): TestCaseGen = {
|
42
|
+
val set = s"CustomSet.fromList(${tc.set})"
|
43
|
+
val callSUT = s"CustomSet.empty(set)"
|
44
|
+
val expected = tc.expected.toString
|
45
|
+
val result = s"val set = $callSUT"
|
46
|
+
val checkResult = s"$callSUT should be ($expected)"
|
46
47
|
|
47
|
-
|
48
|
-
|
48
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
49
|
+
}
|
49
50
|
|
50
|
-
|
51
|
-
print(System.lineSeparator())
|
52
|
-
})
|
51
|
+
testBuilder.addTestCases(emptyTestCases, Some(description))
|
53
52
|
}
|
54
53
|
|
55
|
-
private def
|
56
|
-
|
54
|
+
private def addContainsTests(testBuilder: TestBuilder): Unit = {
|
55
|
+
val description =
|
56
|
+
"Contains test cases - " + (json \ "contains" \ "description").get.as[String]
|
57
57
|
|
58
58
|
val containsTestCases = (json \ "contains" \ "cases").get.as[List[ContainsTestCase]]
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
implicit def testCaseToGen(tc: ContainsTestCase): TestCaseGen = {
|
61
|
+
val set = s"CustomSet.fromList(${tc.set})"
|
62
|
+
val callSUT = s"CustomSet.member(set, ${tc.element})"
|
63
|
+
val expected = tc.expected.toString
|
64
|
+
val result = s"val set = $set"
|
65
|
+
val checkResult = s"$callSUT should be ($expected)"
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
68
|
+
}
|
65
69
|
|
66
|
-
|
67
|
-
print(System.lineSeparator())
|
68
|
-
})
|
70
|
+
testBuilder.addTestCases(containsTestCases, Some(description))
|
69
71
|
}
|
70
72
|
|
71
|
-
private def
|
72
|
-
|
73
|
+
private def addSubsetTests(testBuilder: TestBuilder): Unit = {
|
74
|
+
val description =
|
75
|
+
"Subset test cases - " + (json \ "subset" \ "description").get.as[String]
|
73
76
|
|
74
77
|
val subsetTestCases = (json \ "subset" \ "cases").get.as[List[SubsetTestCase]]
|
75
78
|
|
76
|
-
|
77
|
-
|
79
|
+
implicit def testCaseToGen(tc: SubsetTestCase): TestCaseGen = {
|
80
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
81
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
82
|
+
val callSUT = s"CustomSet.isSubsetOf(set1, set2)"
|
83
|
+
val expected = tc.expected.toString
|
84
|
+
val result =
|
85
|
+
s"""val set1 = $set1
|
86
|
+
val set2 = $set2"""
|
87
|
+
val checkResult = s"$callSUT should be ($expected)"
|
78
88
|
|
79
|
-
|
80
|
-
|
81
|
-
println("CustomSet.isSubsetOf(set1, set2) should be (" + tc.expected + ")")
|
89
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
90
|
+
}
|
82
91
|
|
83
|
-
|
84
|
-
print(System.lineSeparator())
|
85
|
-
})
|
92
|
+
testBuilder.addTestCases(subsetTestCases, Some(description))
|
86
93
|
}
|
87
94
|
|
88
|
-
private def
|
89
|
-
|
95
|
+
private def addDisjointTests(testBuilder: TestBuilder): Unit = {
|
96
|
+
val description =
|
97
|
+
"Disjoint test cases - " + (json \ "disjoint" \ "description").get.as[String]
|
90
98
|
|
91
99
|
val disjointTestCases = (json \ "disjoint" \ "cases").get.as[List[DisjointTestCase]]
|
92
100
|
|
93
|
-
|
94
|
-
|
101
|
+
implicit def testCaseToGen(tc: DisjointTestCase): TestCaseGen = {
|
102
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
103
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
104
|
+
val callSUT = s"CustomSet.isDisjointFrom(set1, set2)"
|
105
|
+
val expected = tc.expected.toString
|
106
|
+
val result =
|
107
|
+
s"""val set1 = $set1
|
108
|
+
val set2 = $set2"""
|
109
|
+
val checkResult = s"$callSUT should be ($expected)"
|
95
110
|
|
96
|
-
|
97
|
-
|
98
|
-
println("CustomSet.isDisjointFrom(set1, set2) should be (" + tc.expected + ")")
|
111
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
112
|
+
}
|
99
113
|
|
100
|
-
|
101
|
-
print(System.lineSeparator())
|
102
|
-
})
|
114
|
+
testBuilder.addTestCases(disjointTestCases, Some(description))
|
103
115
|
}
|
104
116
|
|
105
|
-
private def
|
106
|
-
|
117
|
+
private def addEqualTests(testBuilder: TestBuilder): Unit = {
|
118
|
+
val description =
|
119
|
+
"Equal test cases - " + (json \ "equal" \ "description").get.as[String]
|
107
120
|
|
108
121
|
val equalTestCases = (json \ "equal" \ "cases").get.as[List[EqualTestCase]]
|
109
122
|
|
110
|
-
|
111
|
-
|
123
|
+
implicit def testCaseToGen(tc: EqualTestCase): TestCaseGen = {
|
124
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
125
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
126
|
+
val callSUT = s"CustomSet.isEqual(set1, set2)"
|
127
|
+
val expected = tc.expected.toString
|
128
|
+
val result =
|
129
|
+
s"""val set1 = $set1
|
130
|
+
val set2 = $set2"""
|
131
|
+
val checkResult = s"$callSUT should be ($expected)"
|
112
132
|
|
113
|
-
|
114
|
-
|
115
|
-
println("CustomSet.isEqual(set1, set2) should be (" + tc.expected + ")")
|
133
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
134
|
+
}
|
116
135
|
|
117
|
-
|
118
|
-
print(System.lineSeparator())
|
119
|
-
})
|
136
|
+
testBuilder.addTestCases(equalTestCases, Some(description))
|
120
137
|
}
|
121
138
|
|
122
|
-
private def
|
123
|
-
|
139
|
+
private def addAddTests(testBuilder: TestBuilder): Unit = {
|
140
|
+
val description =
|
141
|
+
"Add test cases - " + (json \ "add" \ "description").get.as[String]
|
124
142
|
|
125
143
|
val addTestCases = (json \ "add" \ "cases").get.as[List[AddTestCase]]
|
126
144
|
|
127
|
-
|
128
|
-
|
145
|
+
implicit def testCaseToGen(tc: AddTestCase): TestCaseGen = {
|
146
|
+
val set = s"CustomSet.fromList(${tc.set})"
|
147
|
+
val callSUT = s"CustomSet.insert(set, ${tc.element})"
|
148
|
+
val expected = s"CustomSet.fromList(${tc.expected})"
|
149
|
+
val result =
|
150
|
+
s"""val set = $set
|
151
|
+
val expected = $expected"""
|
152
|
+
val checkResult = s"CustomSet.isEqual($callSUT, expected) should be (true)"
|
129
153
|
|
130
|
-
|
131
|
-
|
132
|
-
println("CustomSet.isEqual(CustomSet.insert(set, " + tc.element + " ), expected) should be (true)")
|
154
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
155
|
+
}
|
133
156
|
|
134
|
-
|
135
|
-
print(System.lineSeparator())
|
136
|
-
})
|
157
|
+
testBuilder.addTestCases(addTestCases, Some(description))
|
137
158
|
}
|
138
159
|
|
139
|
-
private def
|
140
|
-
|
160
|
+
private def addIntersectionTests(testBuilder: TestBuilder): Unit = {
|
161
|
+
val description =
|
162
|
+
"Intersection test cases - " + (json \ "intersection" \ "description").get.as[String]
|
141
163
|
|
142
164
|
val intersectionTestCases = (json \ "intersection" \ "cases").get.as[List[IntersectionTestCase]]
|
143
165
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
166
|
+
implicit def testCaseToGen(tc: IntersectionTestCase): TestCaseGen = {
|
167
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
168
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
169
|
+
val callSUT = s"CustomSet.intersection(set1, set2)"
|
170
|
+
val expected = s"CustomSet.fromList(${tc.expected})"
|
171
|
+
val result =
|
172
|
+
s"""val set1 = $set1
|
173
|
+
val set2 = $set2
|
174
|
+
val expected = $expected"""
|
175
|
+
val checkResult = s"CustomSet.isEqual($callSUT, expected) should be (true)"
|
176
|
+
|
177
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
178
|
+
}
|
179
|
+
|
180
|
+
testBuilder.addTestCases(intersectionTestCases, Some(description))
|
155
181
|
}
|
156
182
|
|
157
|
-
private def
|
158
|
-
|
183
|
+
private def addDifferenceTests(testBuilder: TestBuilder): Unit = {
|
184
|
+
val description =
|
185
|
+
"Difference test cases - " + (json \ "difference" \ "description").get.as[String]
|
159
186
|
|
160
187
|
val differenceTestCases = (json \ "difference" \ "cases").get.as[List[DifferenceTestCase]]
|
161
188
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
189
|
+
implicit def testCaseToGen(tc: DifferenceTestCase): TestCaseGen = {
|
190
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
191
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
192
|
+
val callSUT = s"CustomSet.difference(set1, set2)"
|
193
|
+
val expected = s"CustomSet.fromList(${tc.expected})"
|
194
|
+
val result =
|
195
|
+
s"""val set1 = $set1
|
196
|
+
val set2 = $set2
|
197
|
+
val expected = $expected"""
|
198
|
+
val checkResult = s"CustomSet.isEqual($callSUT, expected) should be (true)"
|
199
|
+
|
200
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
201
|
+
}
|
202
|
+
|
203
|
+
testBuilder.addTestCases(differenceTestCases, Some(description))
|
173
204
|
}
|
174
205
|
|
175
|
-
private def
|
176
|
-
|
206
|
+
private def addUnionTests(testBuilder: TestBuilder): Unit = {
|
207
|
+
val description =
|
208
|
+
"Union test cases - " + (json \ "union" \ "description").get.as[String]
|
177
209
|
|
178
|
-
val
|
210
|
+
val unionTestCases = (json \ "union" \ "cases").get.as[List[UnionTestCase]]
|
179
211
|
|
180
|
-
|
181
|
-
|
212
|
+
implicit def testCaseToGen(tc: UnionTestCase): TestCaseGen = {
|
213
|
+
val set1 = s"CustomSet.fromList(${tc.set1})"
|
214
|
+
val set2 = s"CustomSet.fromList(${tc.set2})"
|
215
|
+
val callSUT = s"CustomSet.union(set1, set2)"
|
216
|
+
val expected = s"CustomSet.fromList(${tc.expected})"
|
217
|
+
val result =
|
218
|
+
s"""val set1 = $set1
|
219
|
+
val set2 = $set2
|
220
|
+
val expected = $expected"""
|
221
|
+
val checkResult = s"CustomSet.isEqual($callSUT, expected) should be (true)"
|
182
222
|
|
183
|
-
|
184
|
-
|
185
|
-
println("val expected = CustomSet.fromList(" + tc.expected + ")")
|
186
|
-
println("CustomSet.isEqual(CustomSet.union(set1, set2), expected) should be (true)")
|
223
|
+
TestCaseGen(tc.description, callSUT, expected, result, checkResult)
|
224
|
+
}
|
187
225
|
|
188
|
-
|
189
|
-
print(System.lineSeparator())
|
190
|
-
})
|
226
|
+
testBuilder.addTestCases(unionTestCases, Some(description))
|
191
227
|
}
|
192
228
|
|
193
229
|
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import java.io.FileWriter
|
2
|
+
import java.io.File
|
3
|
+
|
4
|
+
case class TestCaseGen(description: String, callSUT: String, expected: String,
|
5
|
+
result: String, checkResult: String)
|
6
|
+
|
7
|
+
object TestCaseGen {
|
8
|
+
def apply(description: String, callSUT: String, expected: String): TestCaseGen =
|
9
|
+
TestCaseGen(description, callSUT, expected,
|
10
|
+
s"val result = $callSUT", s"result should be ($expected)")
|
11
|
+
|
12
|
+
implicit def toTestCaseGenSeq[T](ts: Seq[T])(
|
13
|
+
implicit toGen: T => TestCaseGen): Seq[TestCaseGen] =
|
14
|
+
ts map toGen
|
15
|
+
}
|
16
|
+
|
17
|
+
class TestBuilder(testName: String) {
|
18
|
+
|
19
|
+
private var imports: Seq[String] = Seq()
|
20
|
+
def addImport(imprt: String): Unit = imports = imports :+ imprt
|
21
|
+
|
22
|
+
private var testCases: Seq[(Seq[TestCaseGen], Option[String])] = Seq()
|
23
|
+
def addTestCases(testCases: Seq[TestCaseGen], description: Option[String] = None): Unit =
|
24
|
+
this.testCases = this.testCases :+ (testCases, description)
|
25
|
+
|
26
|
+
def toFile: Unit = {
|
27
|
+
val file = new File(s"$testName.scala")
|
28
|
+
val fileWriter = new FileWriter(file)
|
29
|
+
try { fileWriter.write(build) } finally fileWriter.close
|
30
|
+
|
31
|
+
println(s"file ${file.getAbsolutePath} created")
|
32
|
+
}
|
33
|
+
|
34
|
+
def build: String =
|
35
|
+
s"""$printImports
|
36
|
+
class $testName extends FunSuite with Matchers {
|
37
|
+
$printTestCases
|
38
|
+
}
|
39
|
+
"""
|
40
|
+
|
41
|
+
private lazy val printImports: String =
|
42
|
+
"import org.scalatest.{FunSuite, Matchers}\n" +
|
43
|
+
(imports map (imp => s"import $imp\n") mkString)
|
44
|
+
|
45
|
+
private lazy val printTestCases: String = {
|
46
|
+
var pending = false
|
47
|
+
def printPending: String =
|
48
|
+
if (pending) s"pending\n " else { pending = true; "" }
|
49
|
+
|
50
|
+
def printTestCaseGroup(testCaseGroup: Seq[TestCaseGen],
|
51
|
+
groupDescription: Option[String]): String =
|
52
|
+
{
|
53
|
+
val description = groupDescription map (s => s"\n // $s") getOrElse ""
|
54
|
+
val testCases = testCaseGroup map printTestCase mkString
|
55
|
+
|
56
|
+
s"$description$testCases"
|
57
|
+
}
|
58
|
+
|
59
|
+
def printTestCase(tc: TestCaseGen): String =
|
60
|
+
s"""
|
61
|
+
test("${tc.description}") {
|
62
|
+
${printPending}${tc.result}
|
63
|
+
${tc.checkResult}
|
64
|
+
}
|
65
|
+
"""
|
66
|
+
|
67
|
+
testCases map (printTestCaseGroup _).tupled mkString
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
object TestBuilder {
|
72
|
+
def main(args: Array[String]): Unit = {
|
73
|
+
val testCases13 =
|
74
|
+
(1 to 3) map (i => TestCaseGen(s"test$i", s"identity($i)", s"$i"))
|
75
|
+
val testCases45 =
|
76
|
+
(4 to 5) map (i => TestCaseGen(s"test$i", s"identity($i)", s"$i"))
|
77
|
+
val tb = new TestBuilder("IdentityTest")
|
78
|
+
tb.addImport("scala.collection.mutable")
|
79
|
+
tb.addTestCases(testCases13, Some("identity tests 1-3"))
|
80
|
+
tb.addTestCases(testCases45)
|
81
|
+
println("-----")
|
82
|
+
println(tb.build)
|
83
|
+
println("-----")
|
84
|
+
tb.toFile
|
85
|
+
}
|
86
|
+
}
|
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.0.6.
|
4
|
+
version: 2.0.6.41
|
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-02-
|
11
|
+
date: 2017-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -341,7 +341,7 @@ files:
|
|
341
341
|
- common/exercises/roman-numerals/canonical-data.json
|
342
342
|
- common/exercises/roman-numerals/description.md
|
343
343
|
- common/exercises/roman-numerals/metadata.yml
|
344
|
-
- common/exercises/rotational-cipher/
|
344
|
+
- common/exercises/rotational-cipher/canonical-data.json
|
345
345
|
- common/exercises/rotational-cipher/description.md
|
346
346
|
- common/exercises/rotational-cipher/metadata.yml
|
347
347
|
- common/exercises/run-length-encoding/canonical-data.json
|
@@ -738,6 +738,14 @@ files:
|
|
738
738
|
- tracks/c/exercises/sum-of-multiples/test/vendor/unity.c
|
739
739
|
- tracks/c/exercises/sum-of-multiples/test/vendor/unity.h
|
740
740
|
- tracks/c/exercises/sum-of-multiples/test/vendor/unity_internals.h
|
741
|
+
- tracks/c/exercises/triangle/makefile
|
742
|
+
- tracks/c/exercises/triangle/src/example.c
|
743
|
+
- tracks/c/exercises/triangle/src/example.h
|
744
|
+
- tracks/c/exercises/triangle/src/triangle.h
|
745
|
+
- tracks/c/exercises/triangle/test/test_triangle.c
|
746
|
+
- tracks/c/exercises/triangle/test/vendor/unity.c
|
747
|
+
- tracks/c/exercises/triangle/test/vendor/unity.h
|
748
|
+
- tracks/c/exercises/triangle/test/vendor/unity_internals.h
|
741
749
|
- tracks/c/exercises/word-count/makefile
|
742
750
|
- tracks/c/exercises/word-count/src/example.c
|
743
751
|
- tracks/c/exercises/word-count/src/word_count.h
|
@@ -797,6 +805,8 @@ files:
|
|
797
805
|
- tracks/clojure/LICENSE
|
798
806
|
- tracks/clojure/README.org
|
799
807
|
- tracks/clojure/SETUP.org
|
808
|
+
- tracks/clojure/_src/clock_generator.clj
|
809
|
+
- tracks/clojure/_src/generator.clj
|
800
810
|
- tracks/clojure/_test/check_exercises.clj
|
801
811
|
- tracks/clojure/bin/fetch-configlet
|
802
812
|
- tracks/clojure/bin/restructure.clj
|
@@ -850,6 +860,10 @@ files:
|
|
850
860
|
- tracks/clojure/exercises/change/project.clj
|
851
861
|
- tracks/clojure/exercises/change/src/example.clj
|
852
862
|
- tracks/clojure/exercises/change/test/change_test.clj
|
863
|
+
- tracks/clojure/exercises/clock/clock.mustache
|
864
|
+
- tracks/clojure/exercises/clock/project.clj
|
865
|
+
- tracks/clojure/exercises/clock/src/example.clj
|
866
|
+
- tracks/clojure/exercises/clock/test/clock_test.clj
|
853
867
|
- tracks/clojure/exercises/crypto-square/project.clj
|
854
868
|
- tracks/clojure/exercises/crypto-square/src/example.clj
|
855
869
|
- tracks/clojure/exercises/crypto-square/test/crypto_square_test.clj
|
@@ -4313,6 +4327,9 @@ files:
|
|
4313
4327
|
- tracks/julia/exercises/nucleotide-count/example.jl
|
4314
4328
|
- tracks/julia/exercises/nucleotide-count/nucleotide-count.jl
|
4315
4329
|
- tracks/julia/exercises/nucleotide-count/runtests.jl
|
4330
|
+
- tracks/julia/exercises/pangram/example.jl
|
4331
|
+
- tracks/julia/exercises/pangram/pangram.jl
|
4332
|
+
- tracks/julia/exercises/pangram/runtests.jl
|
4316
4333
|
- tracks/julia/exercises/raindrops/example.jl
|
4317
4334
|
- tracks/julia/exercises/raindrops/raindrops.jl
|
4318
4335
|
- tracks/julia/exercises/raindrops/runtests.jl
|
@@ -6993,6 +7010,10 @@ files:
|
|
6993
7010
|
- tracks/scala/exercises/binary-search-tree/example.scala
|
6994
7011
|
- tracks/scala/exercises/binary-search-tree/src/main/scala/.keep
|
6995
7012
|
- tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala
|
7013
|
+
- tracks/scala/exercises/binary-search/build.sbt
|
7014
|
+
- tracks/scala/exercises/binary-search/example.scala
|
7015
|
+
- tracks/scala/exercises/binary-search/src/main/scala/BinarySearch.scala
|
7016
|
+
- tracks/scala/exercises/binary-search/src/test/scala/BinarySearchTest.scala
|
6996
7017
|
- tracks/scala/exercises/binary/build.sbt
|
6997
7018
|
- tracks/scala/exercises/binary/example.scala
|
6998
7019
|
- tracks/scala/exercises/binary/src/main/scala/.keep
|
@@ -7242,6 +7263,10 @@ files:
|
|
7242
7263
|
- tracks/scala/exercises/space-age/example.scala
|
7243
7264
|
- tracks/scala/exercises/space-age/src/main/scala/.keep
|
7244
7265
|
- tracks/scala/exercises/space-age/src/test/scala/SpaceAgeTest.scala
|
7266
|
+
- tracks/scala/exercises/strain/build.sbt
|
7267
|
+
- tracks/scala/exercises/strain/example.scala
|
7268
|
+
- tracks/scala/exercises/strain/src/main/scala/Strain.scala
|
7269
|
+
- tracks/scala/exercises/strain/src/test/scala/StrainTest.scala
|
7245
7270
|
- tracks/scala/exercises/sublist/build.sbt
|
7246
7271
|
- tracks/scala/exercises/sublist/example.scala
|
7247
7272
|
- tracks/scala/exercises/sublist/src/main/scala/.keep
|
@@ -7281,10 +7306,12 @@ files:
|
|
7281
7306
|
- tracks/scala/project/build.properties
|
7282
7307
|
- tracks/scala/testgen/build.sbt
|
7283
7308
|
- tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala
|
7309
|
+
- tracks/scala/testgen/src/main/scala/BinarySearchTestGenerator.scala
|
7284
7310
|
- tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala
|
7285
7311
|
- tracks/scala/testgen/src/main/scala/BracketPushTestGenerator.scala
|
7286
7312
|
- tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala
|
7287
7313
|
- tracks/scala/testgen/src/main/scala/PangramsTestGenerator.scala
|
7314
|
+
- tracks/scala/testgen/src/main/scala/TestBuilder.scala
|
7288
7315
|
- tracks/scheme/.git
|
7289
7316
|
- tracks/scheme/.gitignore
|
7290
7317
|
- tracks/scheme/.travis.yml
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/allergies/src/example/java/../../main/java/Allergen.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/meetup/src/example/java/../../main/java/MeetupSchedule.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/perfect-numbers/src/example/java/../../main/java/Classification.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/robot-simulator/src/example/java/../../main/java/GridPosition.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/robot-simulator/src/example/java/../../main/java/Orientation.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/secret-handshake/src/example/java/../../main/java/Signal.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/sublist/src/example/java/../../main/java/Relationship.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/triangle/src/example/java/../../main/java/TriangleException.java
|
@@ -1 +0,0 @@
|
|
1
|
-
tracks/java/exercises/triangle/src/example/java/../../main/java/TriangleKind.java
|