trackler 2.0.8.36 → 2.0.8.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/lib/trackler/version.rb +1 -1
  4. data/tracks/c/config.json +7 -0
  5. data/tracks/c/exercises/perfect-numbers/makefile +16 -0
  6. data/tracks/c/exercises/perfect-numbers/src/example.c +28 -0
  7. data/tracks/c/exercises/perfect-numbers/src/example.h +13 -0
  8. data/tracks/c/exercises/perfect-numbers/src/perfect_numbers.h +11 -0
  9. data/tracks/c/exercises/perfect-numbers/test/test_perfect_numbers.c +87 -0
  10. data/tracks/c/exercises/perfect-numbers/test/vendor/unity.c +1300 -0
  11. data/tracks/c/exercises/perfect-numbers/test/vendor/unity.h +274 -0
  12. data/tracks/c/exercises/perfect-numbers/test/vendor/unity_internals.h +701 -0
  13. data/tracks/ceylon/README.md +1 -1
  14. data/tracks/ceylon/docs/RESOURCES.md +5 -0
  15. data/tracks/ceylon/exercises/anagram/source/anagram/module.ceylon +1 -1
  16. data/tracks/ceylon/exercises/bracket-push/example/module.ceylon +2 -2
  17. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/module.ceylon +1 -1
  18. data/tracks/ceylon/exercises/hamming/source/hamming/module.ceylon +1 -1
  19. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/module.ceylon +1 -1
  20. data/tracks/ceylon/exercises/leap/source/leap/module.ceylon +1 -1
  21. data/tracks/ceylon/exercises/react/example/module.ceylon +2 -2
  22. data/tracks/ceylon/exercises/react/source/react/module.ceylon +1 -1
  23. data/tracks/ceylon/exercises/sieve/example/module.ceylon +2 -2
  24. data/tracks/ceylon/exercises/sieve/source/sieve/module.ceylon +1 -1
  25. data/tracks/clojurescript/.github/ISSUE_TEMPLATE.md +9 -0
  26. data/tracks/clojurescript/.gitignore +4 -0
  27. data/tracks/clojurescript/.travis.yml +5 -0
  28. data/tracks/clojurescript/LICENSE +21 -0
  29. data/tracks/clojurescript/README.md +72 -0
  30. data/tracks/clojurescript/bin/fetch-configlet +32 -0
  31. data/tracks/clojurescript/config.json +21 -0
  32. data/tracks/clojurescript/docs/ABOUT.md +0 -0
  33. data/tracks/clojurescript/docs/INSTALLATION.md +0 -0
  34. data/tracks/clojurescript/docs/LEARNING.md +0 -0
  35. data/tracks/clojurescript/docs/RESOURCES.md +0 -0
  36. data/tracks/clojurescript/docs/TESTS.md +0 -0
  37. data/tracks/clojurescript/exercises/TRACK_HINTS.md +0 -0
  38. data/tracks/clojurescript/img/.keep +0 -0
  39. data/tracks/csharp/exercises/grade-school/Example.cs +13 -1
  40. data/tracks/csharp/exercises/grade-school/GradeSchool.cs +1 -1
  41. data/tracks/csharp/exercises/grade-school/GradeSchoolTest.cs +42 -18
  42. data/tracks/go/README.md +8 -0
  43. data/tracks/go/exercises/twelve-days/HINTS.md +2 -0
  44. data/tracks/haskell/config.json +0 -1
  45. data/tracks/objective-c/config.json +9 -0
  46. data/tracks/objective-c/exercises/crypto-square/CryptoSquareExample.h +14 -0
  47. data/tracks/objective-c/exercises/crypto-square/CryptoSquareExample.m +96 -0
  48. data/tracks/objective-c/exercises/crypto-square/CryptoSquareTest.m +94 -0
  49. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  50. data/tracks/purescript/.gitignore +2 -2
  51. data/tracks/purescript/bin/test-one.sh +58 -0
  52. data/tracks/purescript/bin/test.sh +13 -44
  53. data/tracks/purescript/config.json +7 -0
  54. data/tracks/purescript/exercises/bracket-push/bower.json +17 -0
  55. data/tracks/purescript/exercises/bracket-push/examples/src/BracketPush.purs +43 -0
  56. data/tracks/purescript/exercises/bracket-push/src/BracketPush.purs +3 -0
  57. data/tracks/purescript/exercises/bracket-push/test/Main.purs +64 -0
  58. data/tracks/scala/exercises/hello-world/HINTS.md +0 -4
  59. data/tracks/scala/exercises/hello-world/example.scala +1 -2
  60. data/tracks/scala/exercises/hello-world/src/test/scala/HelloWorldTest.scala +4 -11
  61. data/tracks/scala/testgen/build.sbt +9 -0
  62. data/tracks/scala/testgen/project/build.properties +2 -0
  63. data/tracks/scala/testgen/project/plugins.sbt +2 -0
  64. data/tracks/scala/testgen/src/main/scala/BeerSongTestGenerator.scala +15 -0
  65. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +23 -44
  66. data/tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala +31 -0
  67. data/tracks/scala/testgen/src/main/scala/HelloWorldTestGenerator.scala +14 -0
  68. data/tracks/scala/testgen/src/main/scala/NucleotideCountTestGenerator.scala +15 -0
  69. data/tracks/scala/testgen/src/main/scala/PangramsTestGenerator.scala +20 -38
  70. data/tracks/scala/testgen/src/main/scala/SumOfMultiplesTestGenerator.scala +14 -0
  71. data/tracks/scala/testgen/src/main/scala/testgen/CanonicalDataParser.scala +105 -0
  72. data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +111 -0
  73. data/tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt +12 -0
  74. metadata +44 -4
  75. data/tracks/haskell/common/stack.yaml +0 -1
  76. data/tracks/haskell/exercises/pov/.dummylink +0 -1
@@ -0,0 +1,111 @@
1
+ package testgen
2
+
3
+ import java.io.FileWriter
4
+ import java.io.File
5
+ import play.twirl.api.Txt
6
+ import play.twirl.api.Template1
7
+ import TestSuiteBuilder._
8
+
9
+ object TestSuiteBuilder {
10
+
11
+ type TestSuiteTemplate = Template1[TestSuiteData, Txt]
12
+ type ToTestCaseData = String => LabeledTestItem => TestCaseData
13
+
14
+ private val DefaultTemplate: TestSuiteTemplate =
15
+ txt.funSuiteTemplate.asInstanceOf[Template1[TestSuiteData, Txt]]
16
+
17
+ def build(file: File, toTestCaseData: ToTestCaseData, imports: Seq[String] = Seq())(
18
+ implicit template: TestSuiteTemplate = DefaultTemplate): String =
19
+ {
20
+ val exercise @ Exercise(name, version, cases, comments) =
21
+ CanonicalDataParser.parse(file)
22
+ val tsName = testSuiteName(name)
23
+ val testCasesAllPending = cases map toTestCaseData(sutName(name))
24
+ val testCases =
25
+ testCasesAllPending updated(0, testCasesAllPending.head.copy(pending = false))
26
+ val testSuiteData =
27
+ TestSuiteData(tsName, version, imports, testCases)
28
+
29
+ template.render(testSuiteData).toString
30
+ }
31
+
32
+ def withLabeledTest(f: String => LabeledTest => TestCaseData): ToTestCaseData =
33
+ sut => item => f(sut)(item.asInstanceOf[LabeledTest])
34
+
35
+ def fromLabeledTest(argNames: String*): ToTestCaseData =
36
+ withLabeledTest { sut => labeledTest =>
37
+ val sutFunction = labeledTest.property
38
+ val args = sutArgs(labeledTest.result, argNames: _*)
39
+ val sutCall = s"$sut.$sutFunction(${args})"
40
+ val expected = toString(labeledTest.expected)
41
+
42
+ TestCaseData(labeledTest.description, sutCall, expected)
43
+ }
44
+
45
+ def fromLabeledTestAlt(propArgs: (String, Seq[String])*): ToTestCaseData =
46
+ withLabeledTest { sut => labeledTest =>
47
+ val sutFunction = labeledTest.property
48
+ val args = sutArgsAlt(labeledTest.result, propArgs:_*)
49
+ val sutCall = s"$sut.$sutFunction(${args})"
50
+ val expected = toString(labeledTest.expected)
51
+
52
+ TestCaseData(labeledTest.description, sutCall, expected)
53
+ }
54
+
55
+ def main(args: Array[String]): Unit = {
56
+ val path = "src/main/resources"
57
+ val input: Map[String, ToTestCaseData] =
58
+ Map("hello-world" -> fromLabeledTest(),
59
+ "sum-of-multiples" -> fromLabeledTest("factors", "limit"),
60
+ "bowling" -> fromLabeledTest("previous_rolls"))
61
+
62
+ input foreach { case ((name, toTestCaseData)) =>
63
+ val file = new File(s"$path/$name.json")
64
+
65
+ val code = build(file, toTestCaseData)
66
+ println(s"------ $name -------")
67
+ println(code)
68
+ println(s"------ \\$name -------")
69
+ }
70
+ }
71
+
72
+ def sutName(exerciseName: String) =
73
+ (exerciseName split ("-") map (_.capitalize) mkString)
74
+ def testSuiteName(exerciseName: String): String =
75
+ sutName(exerciseName) + "Test"
76
+
77
+ def sutArgs(parseResult: CanonicalDataParser.ParseResult, argNames: String*): String =
78
+ argNames map (name => toString(parseResult(name))) mkString(", ")
79
+
80
+ def sutArgsAlt(parseResult: CanonicalDataParser.ParseResult, propArgs: (String, Seq[String])*): String =
81
+ propArgs collect {
82
+ case ((property, argNames)) if parseResult("property") == property =>
83
+ sutArgs(parseResult, argNames:_*)
84
+ } head
85
+
86
+ private def toString(expected: CanonicalDataParser.Expected): String =
87
+ expected.fold(error => s"Left(${toString(error)})", toString)
88
+
89
+ private def toString(any: Any): String = {
90
+ def quote(str: String): String =
91
+ if ("\"\n" exists (str.contains(_:Char))) "\"\"\"" else "\""
92
+
93
+ any match {
94
+ case str: String =>
95
+ val quot = quote(str)
96
+ s"$quot$str$quot"
97
+ case _ => any.toString
98
+ }
99
+ }
100
+
101
+ def toFile(text: String, dest: File): Unit = {
102
+ val fileWriter = new FileWriter(dest)
103
+ try { fileWriter.write(text) } finally fileWriter.close
104
+ }
105
+ }
106
+
107
+ case class TestCaseData(description: String, sutCall: String, expected: String,
108
+ pending: Boolean = true)
109
+
110
+ case class TestSuiteData(name: String, version: String, imports: Seq[String],
111
+ testCases: Seq[TestCaseData])
@@ -0,0 +1,12 @@
1
+ @(data: testgen.TestSuiteData)@for(imp <- data.imports) {import @imp}
2
+ import org.scalatest.{Matchers, FunSuite}
3
+ @import testgen.TestSuiteBuilder._
4
+
5
+ /** @@version @data.version */
6
+ class @data.name extends FunSuite with Matchers {
7
+ @for(testCase <- data.testCases) {
8
+ test("@testCase.description") { @if(testCase.pending) {
9
+ pending}
10
+ @testCase.sutCall should be (@testCase.expected)
11
+ }
12
+ }}
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.8.36
4
+ version: 2.0.8.37
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-03-30 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -712,6 +712,14 @@ files:
712
712
  - tracks/c/exercises/pascals-triangle/test/vendor/unity.c
713
713
  - tracks/c/exercises/pascals-triangle/test/vendor/unity.h
714
714
  - tracks/c/exercises/pascals-triangle/test/vendor/unity_internals.h
715
+ - tracks/c/exercises/perfect-numbers/makefile
716
+ - tracks/c/exercises/perfect-numbers/src/example.c
717
+ - tracks/c/exercises/perfect-numbers/src/example.h
718
+ - tracks/c/exercises/perfect-numbers/src/perfect_numbers.h
719
+ - tracks/c/exercises/perfect-numbers/test/test_perfect_numbers.c
720
+ - tracks/c/exercises/perfect-numbers/test/vendor/unity.c
721
+ - tracks/c/exercises/perfect-numbers/test/vendor/unity.h
722
+ - tracks/c/exercises/perfect-numbers/test/vendor/unity_internals.h
715
723
  - tracks/c/exercises/phone-number/makefile
716
724
  - tracks/c/exercises/phone-number/src/example.c
717
725
  - tracks/c/exercises/phone-number/src/example.h
@@ -1046,6 +1054,21 @@ files:
1046
1054
  - tracks/clojure/exercises/wordy/test/wordy_test.clj
1047
1055
  - tracks/clojure/img/icon.png
1048
1056
  - tracks/clojure/project.clj
1057
+ - tracks/clojurescript/.git
1058
+ - tracks/clojurescript/.github/ISSUE_TEMPLATE.md
1059
+ - tracks/clojurescript/.gitignore
1060
+ - tracks/clojurescript/.travis.yml
1061
+ - tracks/clojurescript/LICENSE
1062
+ - tracks/clojurescript/README.md
1063
+ - tracks/clojurescript/bin/fetch-configlet
1064
+ - tracks/clojurescript/config.json
1065
+ - tracks/clojurescript/docs/ABOUT.md
1066
+ - tracks/clojurescript/docs/INSTALLATION.md
1067
+ - tracks/clojurescript/docs/LEARNING.md
1068
+ - tracks/clojurescript/docs/RESOURCES.md
1069
+ - tracks/clojurescript/docs/TESTS.md
1070
+ - tracks/clojurescript/exercises/TRACK_HINTS.md
1071
+ - tracks/clojurescript/img/.keep
1049
1072
  - tracks/coffeescript/.git
1050
1073
  - tracks/coffeescript/.gitignore
1051
1074
  - tracks/coffeescript/.travis.yml
@@ -3544,6 +3567,7 @@ files:
3544
3567
  - tracks/go/exercises/triangle/triangle_test.go
3545
3568
  - tracks/go/exercises/trinary/example.go
3546
3569
  - tracks/go/exercises/trinary/trinary_test.go
3570
+ - tracks/go/exercises/twelve-days/HINTS.md
3547
3571
  - tracks/go/exercises/twelve-days/example.go
3548
3572
  - tracks/go/exercises/twelve-days/twelve_days_test.go
3549
3573
  - tracks/go/exercises/variable-length-quantity/example.go
@@ -3612,7 +3636,6 @@ files:
3612
3636
  - tracks/haskell/bin/test-all-examples
3613
3637
  - tracks/haskell/bin/test-example
3614
3638
  - tracks/haskell/bin/test-stub
3615
- - tracks/haskell/common/stack.yaml
3616
3639
  - tracks/haskell/config.json
3617
3640
  - tracks/haskell/docs/ABOUT.md
3618
3641
  - tracks/haskell/docs/INSTALLATION.md
@@ -3943,7 +3966,6 @@ files:
3943
3966
  - tracks/haskell/exercises/pig-latin/src/PigLatin.hs
3944
3967
  - tracks/haskell/exercises/pig-latin/stack.yaml
3945
3968
  - tracks/haskell/exercises/pig-latin/test/Tests.hs
3946
- - tracks/haskell/exercises/pov/.dummylink
3947
3969
  - tracks/haskell/exercises/pov/examples/success-standard/package.yaml
3948
3970
  - tracks/haskell/exercises/pov/examples/success-standard/src/POV.hs
3949
3971
  - tracks/haskell/exercises/pov/package.yaml
@@ -5640,6 +5662,9 @@ files:
5640
5662
  - tracks/objective-c/exercises/clock/ClockExample.h
5641
5663
  - tracks/objective-c/exercises/clock/ClockExample.m
5642
5664
  - tracks/objective-c/exercises/clock/ClockTest.m
5665
+ - tracks/objective-c/exercises/crypto-square/CryptoSquareExample.h
5666
+ - tracks/objective-c/exercises/crypto-square/CryptoSquareExample.m
5667
+ - tracks/objective-c/exercises/crypto-square/CryptoSquareTest.m
5643
5668
  - tracks/objective-c/exercises/difference-of-squares/DifferenceOfSquaresExample.h
5644
5669
  - tracks/objective-c/exercises/difference-of-squares/DifferenceOfSquaresExample.m
5645
5670
  - tracks/objective-c/exercises/difference-of-squares/DifferenceOfSquaresTest.m
@@ -6491,6 +6516,7 @@ files:
6491
6516
  - tracks/purescript/README.md
6492
6517
  - tracks/purescript/SETUP.md
6493
6518
  - tracks/purescript/bin/fetch-configlet
6519
+ - tracks/purescript/bin/test-one.sh
6494
6520
  - tracks/purescript/bin/test.sh
6495
6521
  - tracks/purescript/config.json
6496
6522
  - tracks/purescript/docs/ABOUT.md
@@ -6514,6 +6540,10 @@ files:
6514
6540
  - tracks/purescript/exercises/bob/examples/src/Bob.purs
6515
6541
  - tracks/purescript/exercises/bob/src/Bob.purs
6516
6542
  - tracks/purescript/exercises/bob/test/Main.purs
6543
+ - tracks/purescript/exercises/bracket-push/bower.json
6544
+ - tracks/purescript/exercises/bracket-push/examples/src/BracketPush.purs
6545
+ - tracks/purescript/exercises/bracket-push/src/BracketPush.purs
6546
+ - tracks/purescript/exercises/bracket-push/test/Main.purs
6517
6547
  - tracks/purescript/exercises/hello-world/bower.json
6518
6548
  - tracks/purescript/exercises/hello-world/examples/src/HelloWorld.purs
6519
6549
  - tracks/purescript/exercises/hello-world/src/HelloWorld.purs
@@ -7949,16 +7979,26 @@ files:
7949
7979
  - tracks/scala/project/Build.scala
7950
7980
  - tracks/scala/project/build.properties
7951
7981
  - tracks/scala/testgen/build.sbt
7982
+ - tracks/scala/testgen/project/build.properties
7983
+ - tracks/scala/testgen/project/plugins.sbt
7952
7984
  - tracks/scala/testgen/src/main/scala/AllYourBaseTestGenerator.scala
7985
+ - tracks/scala/testgen/src/main/scala/BeerSongTestGenerator.scala
7953
7986
  - tracks/scala/testgen/src/main/scala/BinarySearchTestGenerator.scala
7954
7987
  - tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala
7955
7988
  - tracks/scala/testgen/src/main/scala/BracketPushTestGenerator.scala
7956
7989
  - tracks/scala/testgen/src/main/scala/CustomSetTestGenerator.scala
7990
+ - tracks/scala/testgen/src/main/scala/FoodChainTestGenerator.scala
7991
+ - tracks/scala/testgen/src/main/scala/HelloWorldTestGenerator.scala
7957
7992
  - tracks/scala/testgen/src/main/scala/IsogramTestGenerator.scala
7993
+ - tracks/scala/testgen/src/main/scala/NucleotideCountTestGenerator.scala
7958
7994
  - tracks/scala/testgen/src/main/scala/PangramsTestGenerator.scala
7959
7995
  - tracks/scala/testgen/src/main/scala/RailFenceCipherTestGenerator.scala
7996
+ - tracks/scala/testgen/src/main/scala/SumOfMultiplesTestGenerator.scala
7960
7997
  - tracks/scala/testgen/src/main/scala/TestBuilder.scala
7961
7998
  - tracks/scala/testgen/src/main/scala/VariableLengthQuantityTestGenerator.scala
7999
+ - tracks/scala/testgen/src/main/scala/testgen/CanonicalDataParser.scala
8000
+ - tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala
8001
+ - tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt
7962
8002
  - tracks/scheme/.git
7963
8003
  - tracks/scheme/.gitignore
7964
8004
  - tracks/scheme/.travis.yml
@@ -1 +0,0 @@
1
- resolver: lts-8.2
@@ -1 +0,0 @@
1
- resolver: lts-8.2