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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/book-store/canonical-data.json +7 -1
  3. data/common/exercises/rotational-cipher/{cannonical-data.json → canonical-data.json} +0 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/c/config.json +9 -0
  6. data/tracks/c/exercises/triangle/makefile +16 -0
  7. data/tracks/c/exercises/triangle/src/example.c +33 -0
  8. data/tracks/c/exercises/triangle/src/example.h +15 -0
  9. data/tracks/c/exercises/triangle/src/triangle.h +10 -0
  10. data/tracks/c/exercises/triangle/test/test_triangle.c +121 -0
  11. data/tracks/c/exercises/triangle/test/vendor/unity.c +1300 -0
  12. data/tracks/c/exercises/triangle/test/vendor/unity.h +274 -0
  13. data/tracks/c/exercises/triangle/test/vendor/unity_internals.h +701 -0
  14. data/tracks/clojure/.gitignore +1 -0
  15. data/tracks/clojure/_src/clock_generator.clj +5 -0
  16. data/tracks/clojure/_src/generator.clj +72 -0
  17. data/tracks/clojure/config.json +6 -0
  18. data/tracks/clojure/exercises/clock/clock.mustache +34 -0
  19. data/tracks/clojure/exercises/clock/project.clj +4 -0
  20. data/tracks/clojure/exercises/clock/src/example.clj +19 -0
  21. data/tracks/clojure/exercises/clock/test/clock_test.clj +177 -0
  22. data/tracks/clojure/project.clj +4 -1
  23. data/tracks/csharp/exercises/poker/Example.cs +1 -1
  24. data/tracks/csharp/exercises/poker/PokerTest.cs +10 -0
  25. data/tracks/erlang/docs/INSTALLATION.md +14 -3
  26. data/tracks/erlang/docs/LEARNING.md +1 -0
  27. data/tracks/go/exercises/gigasecond/gigasecond_test.go +5 -2
  28. data/tracks/go/exercises/grade-school/example.go +2 -0
  29. data/tracks/go/exercises/grade-school/grade_school_test.go +8 -0
  30. data/tracks/go/exercises/hamming/hamming_test.go +1 -1
  31. data/tracks/go/exercises/hello-world/hello_test.go +6 -4
  32. data/tracks/haskell/exercises/accumulate/src/Accumulate.hs +1 -1
  33. data/tracks/haskell/exercises/anagram/src/Anagram.hs +1 -1
  34. data/tracks/java/bin/journey-test.sh +21 -4
  35. data/tracks/java/exercises/allergies/src/example/java/Allergen.java +20 -0
  36. data/tracks/java/exercises/hamming/src/test/java/HammingTest.java +10 -3
  37. data/tracks/java/exercises/luhn/src/example/java/LuhnValidator.java +19 -11
  38. data/tracks/java/exercises/luhn/src/test/java/LuhnValidatorTest.java +43 -1
  39. data/tracks/java/exercises/meetup/src/example/java/MeetupSchedule.java +8 -0
  40. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +91 -91
  41. data/tracks/java/exercises/perfect-numbers/src/example/java/Classification.java +5 -0
  42. data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +29 -0
  43. data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +5 -0
  44. data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +5 -0
  45. data/tracks/java/exercises/sublist/src/example/java/Relationship.java +5 -0
  46. data/tracks/java/exercises/triangle/src/example/java/TriangleException.java +5 -0
  47. data/tracks/java/exercises/triangle/src/example/java/TriangleKind.java +5 -0
  48. data/tracks/julia/config.json +10 -1
  49. data/tracks/julia/exercises/atbash-cipher/runtests.jl +36 -36
  50. data/tracks/julia/exercises/pangram/example.jl +2 -0
  51. data/tracks/julia/exercises/pangram/pangram.jl +4 -0
  52. data/tracks/julia/exercises/pangram/runtests.jl +40 -0
  53. data/tracks/perl5/exercises/bob/Example.pm +1 -1
  54. data/tracks/perl5/exercises/bob/bob.t +27 -31
  55. data/tracks/php/exercises/accumulate/accumulate_test.php +1 -1
  56. data/tracks/php/exercises/acronym/acronym_test.php +1 -1
  57. data/tracks/php/exercises/allergies/allergies_test.php +1 -1
  58. data/tracks/php/exercises/anagram/anagram_test.php +1 -1
  59. data/tracks/php/exercises/atbash-cipher/atbash-cipher_test.php +1 -1
  60. data/tracks/php/exercises/beer-song/beer-song_test.php +1 -1
  61. data/tracks/php/exercises/binary/binary_test.php +2 -2
  62. data/tracks/php/exercises/bob/bob_test.php +1 -1
  63. data/tracks/php/exercises/book-store/book-store_test.php +1 -1
  64. data/tracks/php/exercises/bowling/bowling_test.php +1 -1
  65. data/tracks/php/exercises/bracket-push/bracket-push_test.php +1 -1
  66. data/tracks/php/exercises/change/change_test.php +3 -3
  67. data/tracks/php/exercises/clock/clock_test.php +1 -1
  68. data/tracks/php/exercises/connect/connect_test.php +1 -1
  69. data/tracks/php/exercises/difference-of-squares/difference-of-squares_test.php +1 -1
  70. data/tracks/php/exercises/etl/etl_test.php +1 -1
  71. data/tracks/php/exercises/gigasecond/gigasecond_test.php +1 -1
  72. data/tracks/php/exercises/grains/grains_test.php +1 -1
  73. data/tracks/php/exercises/hamming/hamming_test.php +2 -2
  74. data/tracks/php/exercises/hello-world/hello-world_test.php +1 -1
  75. data/tracks/php/exercises/isogram/isogram_test.php +1 -1
  76. data/tracks/php/exercises/largest-series-product/largest-series-product_test.php +1 -1
  77. data/tracks/php/exercises/leap/leap_test.php +1 -1
  78. data/tracks/php/exercises/markdown/markdown_test.php +1 -1
  79. data/tracks/php/exercises/minesweeper/minesweeper_test.php +7 -7
  80. data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +1 -1
  81. data/tracks/php/exercises/ocr-numbers/ocr-numbers_test.php +1 -1
  82. data/tracks/php/exercises/pangram/pangram_test.php +1 -1
  83. data/tracks/php/exercises/phone-number/phone-number_test.php +1 -1
  84. data/tracks/php/exercises/pig-latin/pig-latin_test.php +1 -1
  85. data/tracks/php/exercises/raindrops/raindrops_test.php +1 -1
  86. data/tracks/php/exercises/rna-transcription/rna-transcription_test.php +1 -1
  87. data/tracks/php/exercises/robot-name/robot-name_test.php +1 -1
  88. data/tracks/php/exercises/robot-simulator/robot-simulator_test.php +1 -1
  89. data/tracks/php/exercises/roman-numerals/roman-numerals_test.php +1 -1
  90. data/tracks/php/exercises/sieve/sieve_test.php +1 -1
  91. data/tracks/php/exercises/space-age/space-age_test.php +1 -1
  92. data/tracks/php/exercises/triangle/triangle_test.php +1 -1
  93. data/tracks/php/exercises/trinary/trinary_test.php +1 -1
  94. data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +3 -3
  95. data/tracks/php/exercises/word-count/word-count_test.php +1 -1
  96. data/tracks/php/exercises/wordy/wordy_test.php +3 -3
  97. data/tracks/python/config.json +3 -13
  98. data/tracks/python/exercises/rectangles/rectangles_count_test.py +15 -22
  99. data/tracks/scala/config.json +684 -665
  100. data/tracks/scala/exercises/binary-search/build.sbt +3 -0
  101. data/tracks/scala/exercises/binary-search/example.scala +23 -0
  102. data/tracks/scala/exercises/binary-search/src/main/scala/BinarySearch.scala +0 -0
  103. data/tracks/scala/exercises/binary-search/src/test/scala/BinarySearchTest.scala +63 -0
  104. data/tracks/scala/exercises/strain/build.sbt +3 -0
  105. data/tracks/scala/exercises/strain/example.scala +22 -0
  106. data/tracks/scala/exercises/strain/src/main/scala/Strain.scala +0 -0
  107. data/tracks/scala/exercises/strain/src/test/scala/StrainTest.scala +78 -0
  108. data/tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala +13 -20
  109. data/tracks/scala/testgen/src/main/scala/BinarySearchTestGenerator.scala +48 -0
  110. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +24 -32
  111. data/tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala +148 -112
  112. data/tracks/scala/testgen/src/main/scala/TestBuilder.scala +86 -0
  113. metadata +30 -3
  114. data/tracks/java/exercises/allergies/src/example/java/Allergen.java +0 -1
  115. data/tracks/java/exercises/meetup/src/example/java/MeetupSchedule.java +0 -1
  116. data/tracks/java/exercises/perfect-numbers/src/example/java/Classification.java +0 -1
  117. data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +0 -1
  118. data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +0 -1
  119. data/tracks/java/exercises/secret-handshake/src/example/java/Signal.java +0 -1
  120. data/tracks/java/exercises/sublist/src/example/java/Relationship.java +0 -1
  121. data/tracks/java/exercises/triangle/src/example/java/TriangleException.java +0 -1
  122. 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 definitionfor the CustomSet exercise.
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
- print("import org.scalatest.{FunSuite, Matchers}" + System.lineSeparator())
23
- print(System.lineSeparator())
24
- print("class CustomSetTest extends FunSuite with Matchers {" + System.lineSeparator())
25
-
26
- writeEmptyTests()
27
- writeContainsTests()
28
- writeSubsetTests()
29
- writeDisjointTests()
30
- writeEqualTests()
31
- writeAddTests()
32
- writeIntersectionTests()
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 writeEmptyTests(): Unit = {
40
- println("// Empty test cases - " + (json \ "empty" \ "description").get.as[String])
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
- emptyTestCases.foreach(tc => {
45
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set = CustomSet.fromList(" + tc.set + ")")
48
- println("CustomSet.empty(set) should be (" + tc.expected + ")")
48
+ TestCaseGen(tc.description, callSUT, expected, result, checkResult)
49
+ }
49
50
 
50
- print("\t}" + System.lineSeparator())
51
- print(System.lineSeparator())
52
- })
51
+ testBuilder.addTestCases(emptyTestCases, Some(description))
53
52
  }
54
53
 
55
- private def writeContainsTests(): Unit = {
56
- println("// Contains test cases - " + (json \ "contains" \ "description").get.as[String])
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
- containsTestCases.foreach(tc => {
61
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set = CustomSet.fromList(" + tc.set + ")")
64
- println("CustomSet.member(set, " + tc.element + ") should be (" + tc.expected + ")")
67
+ TestCaseGen(tc.description, callSUT, expected, result, checkResult)
68
+ }
65
69
 
66
- print("\t}" + System.lineSeparator())
67
- print(System.lineSeparator())
68
- })
70
+ testBuilder.addTestCases(containsTestCases, Some(description))
69
71
  }
70
72
 
71
- private def writeSubsetTests(): Unit = {
72
- println("// Subset test cases - " + (json \ "subset" \ "description").get.as[String])
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
- subsetTestCases.foreach(tc => {
77
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
80
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
81
- println("CustomSet.isSubsetOf(set1, set2) should be (" + tc.expected + ")")
89
+ TestCaseGen(tc.description, callSUT, expected, result, checkResult)
90
+ }
82
91
 
83
- print("\t}" + System.lineSeparator())
84
- print(System.lineSeparator())
85
- })
92
+ testBuilder.addTestCases(subsetTestCases, Some(description))
86
93
  }
87
94
 
88
- private def writeDisjointTests(): Unit = {
89
- println("// Disjoint test cases - " + (json \ "disjoint" \ "description").get.as[String])
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
- disjointTestCases.foreach(tc => {
94
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
97
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
98
- println("CustomSet.isDisjointFrom(set1, set2) should be (" + tc.expected + ")")
111
+ TestCaseGen(tc.description, callSUT, expected, result, checkResult)
112
+ }
99
113
 
100
- print("\t}" + System.lineSeparator())
101
- print(System.lineSeparator())
102
- })
114
+ testBuilder.addTestCases(disjointTestCases, Some(description))
103
115
  }
104
116
 
105
- private def writeEqualTests(): Unit = {
106
- println("// Equal test cases - " + (json \ "equal" \ "description").get.as[String])
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
- equalTestCases.foreach(tc => {
111
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
114
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
115
- println("CustomSet.isEqual(set1, set2) should be (" + tc.expected + ")")
133
+ TestCaseGen(tc.description, callSUT, expected, result, checkResult)
134
+ }
116
135
 
117
- print("\t}" + System.lineSeparator())
118
- print(System.lineSeparator())
119
- })
136
+ testBuilder.addTestCases(equalTestCases, Some(description))
120
137
  }
121
138
 
122
- private def writeAddTests(): Unit = {
123
- println("// Add test cases - " + (json \ "add" \ "description").get.as[String])
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
- addTestCases.foreach(tc => {
128
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set = CustomSet.fromList(" + tc.set + ")")
131
- println("val expected = CustomSet.fromList(" + tc.expected + ")")
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
- print("\t}" + System.lineSeparator())
135
- print(System.lineSeparator())
136
- })
157
+ testBuilder.addTestCases(addTestCases, Some(description))
137
158
  }
138
159
 
139
- private def writeIntersectionTests(): Unit = {
140
- println("// Intersection test cases - " + (json \ "intersection" \ "description").get.as[String])
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
- intersectionTestCases.foreach(tc => {
145
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
146
-
147
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
148
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
149
- println("val expected = CustomSet.fromList(" + tc.expected + ")")
150
- println("CustomSet.isEqual(CustomSet.intersection(set1, set2), expected) should be (true)")
151
-
152
- print("\t}" + System.lineSeparator())
153
- print(System.lineSeparator())
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 writeDifferenceTests(): Unit = {
158
- println("// Difference test cases - " + (json \ "difference" \ "description").get.as[String])
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
- differenceTestCases.foreach(tc => {
163
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
164
-
165
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
166
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
167
- println("val expected = CustomSet.fromList(" + tc.expected + ")")
168
- println("CustomSet.isEqual(CustomSet.difference(set1, set2), expected) should be (true)")
169
-
170
- print("\t}" + System.lineSeparator())
171
- print(System.lineSeparator())
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 writeUnionTests(): Unit = {
176
- println("// Union test cases - " + (json \ "union" \ "description").get.as[String])
206
+ private def addUnionTests(testBuilder: TestBuilder): Unit = {
207
+ val description =
208
+ "Union test cases - " + (json \ "union" \ "description").get.as[String]
177
209
 
178
- val differenceTestCases = (json \ "union" \ "cases").get.as[List[UnionTestCase]]
210
+ val unionTestCases = (json \ "union" \ "cases").get.as[List[UnionTestCase]]
179
211
 
180
- differenceTestCases.foreach(tc => {
181
- print("\ttest(\"" + tc.description + "\") {" + System.lineSeparator())
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
- println("val set1 = CustomSet.fromList(" + tc.set1 + ")")
184
- println("val set2 = CustomSet.fromList(" + tc.set2 + ")")
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
- print("\t}" + System.lineSeparator())
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.40
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-13 00:00:00.000000000 Z
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/cannonical-data.json
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