trackler 2.0.0.1 → 2.0.0.2

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.
Files changed (226) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bump-content +3 -1
  3. data/bin/verify-metadata +2 -2
  4. data/common/exercises/alphametics/canonical-data.json +19 -9
  5. data/common/exercises/food-chain/canonical-data.json +7 -1
  6. data/common/exercises/grains/canonical-data.json +66 -0
  7. data/common/exercises/raindrops/description.md +4 -5
  8. data/common/exercises/triangle/canonical-data.json +81 -54
  9. data/lib/trackler/version.rb +1 -1
  10. data/tracks/c/config.json +26 -19
  11. data/tracks/c/exercises/allergies/makefile +15 -0
  12. data/tracks/c/exercises/allergies/src/allergies.h +21 -0
  13. data/tracks/c/exercises/allergies/src/example.c +32 -0
  14. data/tracks/c/exercises/allergies/src/example.h +26 -0
  15. data/tracks/c/exercises/allergies/test/test_allergies.c +203 -0
  16. data/tracks/c/exercises/allergies/test/vendor/unity.c +1300 -0
  17. data/tracks/c/exercises/allergies/test/vendor/unity.h +274 -0
  18. data/tracks/c/exercises/allergies/test/vendor/unity_internals.h +701 -0
  19. data/tracks/c/exercises/atbash-cipher/makefile +16 -0
  20. data/tracks/c/exercises/atbash-cipher/src/example.c +71 -0
  21. data/tracks/c/exercises/atbash-cipher/src/example.h +7 -0
  22. data/tracks/c/exercises/atbash-cipher/test/test_atbash_cipher.c +113 -0
  23. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.c +1300 -0
  24. data/tracks/c/exercises/atbash-cipher/test/vendor/unity.h +274 -0
  25. data/tracks/c/exercises/atbash-cipher/test/vendor/unity_internals.h +701 -0
  26. data/tracks/c/exercises/phone-number/makefile +16 -0
  27. data/tracks/c/exercises/phone-number/src/example.c +66 -0
  28. data/tracks/c/exercises/phone-number/src/example.h +8 -0
  29. data/tracks/c/exercises/phone-number/test/test_phone_number.c +108 -0
  30. data/tracks/c/exercises/phone-number/test/vendor/unity.c +1300 -0
  31. data/tracks/c/exercises/phone-number/test/vendor/unity.h +274 -0
  32. data/tracks/c/exercises/phone-number/test/vendor/unity_internals.h +701 -0
  33. data/tracks/csharp/config.json +8 -0
  34. data/tracks/csharp/exercises/bowling/BowlingTest.cs +188 -33
  35. data/tracks/csharp/exercises/bowling/Example.cs +38 -9
  36. data/tracks/csharp/exercises/rectangles/Example.cs +91 -0
  37. data/tracks/csharp/exercises/rectangles/RectanglesTest.cs +133 -0
  38. data/tracks/elisp/docs/INSTALLATION.org +1 -1
  39. data/tracks/elixir/config.json +8 -66
  40. data/tracks/elixir/docs/LEARNING.md +1 -1
  41. data/tracks/elixir/exercises/diamond/diamond_test.exs +12 -12
  42. data/tracks/elixir/exercises/grep/example.exs +92 -0
  43. data/tracks/elixir/exercises/grep/grep.exs +6 -0
  44. data/tracks/elixir/exercises/grep/grep_test.exs +259 -0
  45. data/tracks/elixir/exercises/markdown/markdown.exs +59 -2
  46. data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +4 -4
  47. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +5 -0
  48. data/tracks/fsharp/exercises/bowling/BowlingTest.fs +158 -43
  49. data/tracks/fsharp/exercises/bowling/Example.fs +53 -24
  50. data/tracks/go/config.json +5 -0
  51. data/tracks/go/exercises/diamond/diamond_test.go +227 -0
  52. data/tracks/go/exercises/diamond/example.go +47 -0
  53. data/tracks/go/exercises/food-chain/example.go +1 -1
  54. data/tracks/go/exercises/food-chain/food_chain_test.go +30 -6
  55. data/tracks/go/exercises/nucleotide-count/example.go +21 -8
  56. data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +45 -37
  57. data/tracks/haskell/exercises/anagram/test/Tests.hs +1 -11
  58. data/tracks/java/bin/journey-test.sh +165 -128
  59. data/tracks/java/docs/ABOUT.md +5 -8
  60. data/tracks/java/exercises/hello-world/build.gradle +0 -6
  61. data/tracks/java/exercises/hello-world/src/test/java/HelloWorldTest.java +0 -1
  62. data/tracks/java/exercises/meetup/build.gradle +0 -1
  63. data/tracks/java/exercises/meetup/src/example/java/Meetup.java +9 -7
  64. data/tracks/java/exercises/meetup/src/test/java/MeetupTest.java +185 -188
  65. data/tracks/lua/config.json +0 -73
  66. data/tracks/lua/exercises/bowling/bowling_spec.lua +92 -48
  67. data/tracks/lua/exercises/bowling/example.lua +4 -1
  68. data/tracks/objective-c/config.json +9 -30
  69. data/tracks/objective-c/exercises/pangram/PangramExample.h +7 -0
  70. data/tracks/objective-c/exercises/pangram/PangramExample.m +21 -0
  71. data/tracks/objective-c/exercises/pangram/PangramTest.m +51 -0
  72. data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
  73. data/tracks/ocaml/README.md +46 -1
  74. data/tracks/ocaml/SETUP.md +21 -2
  75. data/tracks/ocaml/config.json +48 -78
  76. data/tracks/perl5/README.md +15 -8
  77. data/tracks/perl5/testall.pl +5 -5
  78. data/tracks/php/config.json +26 -34
  79. data/tracks/php/docs/ABOUT.md +15 -0
  80. data/tracks/php/exercises/allergies/allergies_test.php +121 -0
  81. data/tracks/php/exercises/allergies/example.php +64 -0
  82. data/tracks/php/exercises/etl/etl_test.php +52 -0
  83. data/tracks/php/exercises/etl/example.php +12 -0
  84. data/tracks/php/exercises/nucleotide-count/example.php +25 -0
  85. data/tracks/php/exercises/nucleotide-count/nucleotide-count_test.php +36 -0
  86. data/tracks/php/exercises/pig-latin/example.php +25 -29
  87. data/tracks/php/exercises/pig-latin/pig-latin_test.php +26 -19
  88. data/tracks/php/exercises/space-age/example.php +65 -0
  89. data/tracks/php/exercises/space-age/space-age_test.php +70 -0
  90. data/tracks/php/exercises/triangle/example.php +43 -0
  91. data/tracks/php/exercises/triangle/triangle_test.php +140 -0
  92. data/tracks/pony/exercises/anagram/example.pony +6 -6
  93. data/tracks/pony/exercises/anagram/test.pony +3 -4
  94. data/tracks/pony/exercises/bob/test.pony +23 -23
  95. data/tracks/pony/exercises/difference-of-squares/test.pony +11 -11
  96. data/tracks/pony/exercises/hamming/example.pony +3 -3
  97. data/tracks/pony/exercises/hamming/test.pony +16 -16
  98. data/tracks/pony/exercises/hello-world/test.pony +5 -4
  99. data/tracks/pony/exercises/leap/test.pony +8 -8
  100. data/tracks/python/config.json +18 -0
  101. data/tracks/python/exercises/diamond/diamond_test.py +33 -0
  102. data/tracks/python/exercises/diamond/example.py +15 -0
  103. data/tracks/python/exercises/linked-list/example.py +47 -0
  104. data/tracks/python/exercises/linked-list/linked_list.py +13 -0
  105. data/tracks/python/exercises/linked-list/linked_list_test.py +49 -0
  106. data/tracks/python/exercises/list-ops/example.py +55 -0
  107. data/tracks/python/exercises/list-ops/list_ops.py +38 -0
  108. data/tracks/python/exercises/list-ops/list_ops_test.py +136 -0
  109. data/tracks/ruby/bin/generate +22 -2
  110. data/tracks/ruby/config.json +12 -83
  111. data/tracks/ruby/exercises/allergies/allergies_test.rb +0 -1
  112. data/tracks/ruby/exercises/atbash-cipher/atbash_cipher_test.rb +0 -1
  113. data/tracks/ruby/exercises/beer-song/beer_song_test.rb +1 -2
  114. data/tracks/ruby/exercises/binary/example.rb +0 -1
  115. data/tracks/ruby/exercises/binary-search-tree/binary_search_tree_test.rb +1 -1
  116. data/tracks/ruby/exercises/bowling/.version +1 -0
  117. data/tracks/ruby/exercises/bowling/bowling_test.rb +109 -133
  118. data/tracks/ruby/exercises/bowling/example.rb +7 -7
  119. data/tracks/ruby/exercises/bowling/example.tt +27 -0
  120. data/tracks/ruby/exercises/circular-buffer/circular_buffer_test.rb +0 -2
  121. data/tracks/ruby/exercises/clock/example.rb +0 -2
  122. data/tracks/ruby/exercises/connect/connect_test.rb +0 -1
  123. data/tracks/ruby/exercises/custom-set/custom_set_test.rb +0 -1
  124. data/tracks/ruby/exercises/diamond/diamond_test.rb +0 -1
  125. data/tracks/ruby/exercises/etl/etl_test.rb +1 -1
  126. data/tracks/ruby/exercises/house/house_test.rb +0 -1
  127. data/tracks/ruby/exercises/isogram/isogram_test.rb +2 -2
  128. data/tracks/ruby/exercises/largest-series-product/example.tt +0 -3
  129. data/tracks/ruby/exercises/largest-series-product/largest_series_product_test.rb +0 -4
  130. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +1 -1
  131. data/tracks/ruby/exercises/meetup/meetup_test.rb +0 -1
  132. data/tracks/ruby/exercises/nth-prime/example.tt +0 -2
  133. data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +0 -2
  134. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +1 -2
  135. data/tracks/ruby/exercises/protein-translation/protein_translation_test.rb +0 -1
  136. data/tracks/ruby/exercises/proverb/proverb_test.rb +1 -3
  137. data/tracks/ruby/exercises/queen-attack/example.rb +3 -1
  138. data/tracks/ruby/exercises/queen-attack/queen_attack_test.rb +34 -8
  139. data/tracks/ruby/exercises/robot-simulator/robot_simulator_test.rb +1 -1
  140. data/tracks/ruby/exercises/strain/strain_test.rb +2 -2
  141. data/tracks/ruby/exercises/tournament/.version +1 -0
  142. data/tracks/ruby/exercises/tournament/example.rb +54 -0
  143. data/tracks/ruby/exercises/tournament/example.tt +23 -0
  144. data/tracks/ruby/exercises/tournament/tournament_test.rb +92 -0
  145. data/tracks/ruby/exercises/transpose/.version +1 -0
  146. data/tracks/ruby/exercises/transpose/example.rb +14 -0
  147. data/tracks/ruby/exercises/transpose/example.tt +22 -0
  148. data/tracks/ruby/exercises/transpose/transpose_test.rb +303 -0
  149. data/tracks/ruby/lib/bowling_cases.rb +46 -0
  150. data/tracks/ruby/lib/isogram_cases.rb +1 -1
  151. data/tracks/ruby/lib/tournament_cases.rb +45 -0
  152. data/tracks/ruby/lib/transpose_cases.rb +45 -0
  153. data/tracks/rust/config.json +2 -0
  154. data/tracks/rust/exercises/bowling/.gitignore +7 -0
  155. data/tracks/rust/exercises/bowling/Cargo.toml +3 -0
  156. data/tracks/rust/exercises/bowling/example.rs +134 -0
  157. data/tracks/rust/exercises/bowling/tests/bowling.rs +373 -0
  158. data/tracks/rust/exercises/grains/.gitignore +7 -0
  159. data/tracks/rust/exercises/grains/Cargo.toml +3 -0
  160. data/tracks/rust/exercises/grains/example.rs +11 -0
  161. data/tracks/rust/exercises/grains/src/lib.rs +7 -0
  162. data/tracks/rust/exercises/grains/tests/grains.rs +63 -0
  163. data/tracks/rust/problems.md +2 -0
  164. data/tracks/scala/README.md +38 -0
  165. data/tracks/scala/config.json +20 -74
  166. data/tracks/scala/exercises/accumulate/src/test/scala/accumulate_test.scala +4 -0
  167. data/tracks/scala/exercises/allergies/src/test/scala/allergies_test.scala +11 -0
  168. data/tracks/scala/exercises/alphametics/build.sbt +6 -0
  169. data/tracks/scala/exercises/alphametics/example.scala +125 -0
  170. data/tracks/scala/exercises/alphametics/src/main/scala/.keep +0 -0
  171. data/tracks/scala/exercises/alphametics/src/test/scala/AlphameticsTest.scala +62 -0
  172. data/tracks/scala/exercises/atbash-cipher/src/test/scala/atbash_test.scala +8 -0
  173. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +4 -0
  174. data/tracks/scala/exercises/binary/src/test/scala/binary_test.scala +13 -0
  175. data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +11 -0
  176. data/tracks/scala/exercises/bowling/Example.scala +116 -0
  177. data/tracks/scala/exercises/bowling/build.sbt +3 -0
  178. data/tracks/scala/exercises/bowling/src/main/scala/Bowling.scala +11 -0
  179. data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +237 -0
  180. data/tracks/scala/exercises/clock/src/test/scala/ClockTest.scala +50 -0
  181. data/tracks/scala/exercises/connect/README.md +17 -0
  182. data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +7 -0
  183. data/tracks/scala/exercises/crypto-square/src/test/scala/{CrytpoSquareTest.scala → CryptoSquareTest.scala} +9 -0
  184. data/tracks/scala/exercises/custom-set/src/test/scala/CustomSetTest.scala +36 -0
  185. data/tracks/scala/exercises/difference-of-squares/src/test/scala/squares_test.scala +8 -0
  186. data/tracks/scala/exercises/forth/src/test/scala/ForthTest.scala +22 -0
  187. data/tracks/scala/exercises/hexadecimal/src/test/scala/HexadecimalTest.scala +8 -0
  188. data/tracks/scala/exercises/kindergarten-garden/src/test/scala/GardenTest.scala +5 -0
  189. data/tracks/scala/exercises/largest-series-product/src/test/scala/SeriesTest.scala +2 -0
  190. data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +4 -0
  191. data/tracks/scala/exercises/luhn/src/test/scala/LuhnTest.scala +4 -0
  192. data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +2 -0
  193. data/tracks/scala/exercises/minesweeper/src/test/scala/MinesweeperTest.scala +6 -0
  194. data/tracks/scala/exercises/nth-prime/src/test/scala/PrimeTest.scala +5 -0
  195. data/tracks/scala/exercises/ocr-numbers/src/test/scala/OcrTest.scala +15 -0
  196. data/tracks/scala/exercises/octal/src/test/scala/OctalTest.scala +7 -0
  197. data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +8 -0
  198. data/tracks/scala/exercises/pascals-triangle/src/test/scala/PascalsTriangleTest.scala +5 -0
  199. data/tracks/scala/exercises/pig-latin/src/test/scala/PigLatinTest.scala +4 -0
  200. data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +3 -0
  201. data/tracks/scala/exercises/queen-attack/src/test/scala/QueensTest.scala +5 -0
  202. data/tracks/scala/exercises/robot-simulator/src/test/scala/RobotTest.scala +16 -8
  203. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +34 -17
  204. data/tracks/scala/exercises/scrabble-score/src/test/scala/scrabble_score_test.scala +6 -0
  205. data/tracks/scala/exercises/secret-handshake/src/test/scala/SecretHandshakeTest.scala +18 -9
  206. data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +4 -2
  207. data/tracks/scala/exercises/sieve/src/test/scala/SieveTest.scala +8 -4
  208. data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +17 -9
  209. data/tracks/scala/exercises/sublist/src/test/scala/sublist_test.scala +17 -0
  210. data/tracks/scala/exercises/trinary/src/test/scala/TrinaryTest.scala +14 -7
  211. data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +28 -14
  212. data/tracks/scala/project/Build.scala +3 -3
  213. data/tracks/scala/testgen/src/main/scala/BowlingTestGenerator.scala +57 -0
  214. data/tracks/sml/config.json +41 -6
  215. data/tracks/sml/exercises/flatten-array/example.sml +6 -0
  216. data/tracks/sml/exercises/flatten-array/test_flatten_array.sml +10 -0
  217. data/tracks/sml/exercises/nth-prime/example.sml +46 -0
  218. data/tracks/sml/exercises/nth-prime/test_nth_prime.sml +14 -0
  219. data/tracks/sml/exercises/raindrops/example.sml +9 -0
  220. data/tracks/sml/exercises/raindrops/raindrops.sml +2 -0
  221. data/tracks/sml/exercises/raindrops/test_raindrops.sml +95 -0
  222. data/tracks/swift/config.json +269 -328
  223. data/tracks/swift/exercises/pangram/PangramExample.swift +17 -0
  224. data/tracks/swift/exercises/pangram/PangramTest.swift +43 -0
  225. data/tracks/swift/xcodeProject/xSwift.xcodeproj/project.pbxproj +16 -0
  226. metadata +95 -3
@@ -1,36 +1,32 @@
1
1
  <?php
2
+ /**
3
+ * Translates a string into Pig Latin
4
+ *
5
+ * @param string $str
6
+ * @return string
7
+ */
8
+ function translate($str)
9
+ {
10
+ $words = explode(" ", $str);
11
+ $translatedWords = array_map('translateWord', $words);
12
+ return implode(' ', $translatedWords);
13
+ }
2
14
 
3
- class PigLatin
15
+ /**
16
+ * Translates a single word
17
+ *
18
+ * @param string $str
19
+ * @return string
20
+ */
21
+ function translateWord($str)
4
22
  {
5
- /**
6
- * Translates a string into Pig Latin
7
- *
8
- * @param string $str
9
- * @return string
10
- */
11
- public static function translate($str)
12
- {
13
- $words = explode(" ", $str);
14
- $translatedWords = array_map(["self", 'translateWord'], $words);
15
- return implode(' ', $translatedWords);
23
+ if (preg_match('/^s?qu|thr?|s?ch/', $str, $match)) {
24
+ return sprintf("%s%say", substr($str, strlen($match[0])), $match[0]);
16
25
  }
17
26
 
18
- /**
19
- * Translates a single word
20
- *
21
- * @param string $str
22
- * @return string
23
- */
24
- private static function translateWord($str)
25
- {
26
- if (preg_match('/^s?qu|thr?|s?ch/', $str, $match)) {
27
- return sprintf("%s%say", substr($str, strlen($match[0])), $match[0]);
28
- }
29
-
30
- if (preg_match('/^[aeiou]|yt|xr/', $str)) {
31
- return sprintf("%say", $str);
32
- }
33
-
34
- return sprintf("%s%say", substr($str, 1), $str[0]);
27
+ if (preg_match('/^[aeiou]|yt|xr/', $str)) {
28
+ return sprintf("%say", $str);
35
29
  }
30
+
31
+ return sprintf("%s%say", substr($str, 1), $str[0]);
36
32
  }
@@ -5,63 +5,70 @@ class PigLatinTest extends PHPUnit_Framework_TestCase
5
5
  {
6
6
  public function testWordBeginningWithP()
7
7
  {
8
- $this->assertEquals("igpay", PigLatin::translate("pig"));
8
+ $this->assertEquals("igpay", translate("pig"));
9
9
  }
10
10
 
11
11
  public function testWordBeginningWithK()
12
12
  {
13
13
  $this->markTestSkipped();
14
14
 
15
- $this->assertEquals("oalakay", PigLatin::translate("koala"));
15
+ $this->assertEquals("oalakay", translate("koala"));
16
16
  }
17
17
 
18
18
  public function testWordBeginningWithY()
19
19
  {
20
20
  $this->markTestSkipped();
21
21
 
22
- $this->assertEquals("ellowyay", PigLatin::translate("yellow"));
22
+ $this->assertEquals("ellowyay", translate("yellow"));
23
23
  }
24
24
 
25
25
  public function testWordBeginningWithX()
26
26
  {
27
27
  $this->markTestSkipped();
28
28
 
29
- $this->assertEquals("enonxay", PigLatin::translate("xenon"));
29
+ $this->assertEquals("enonxay", translate("xenon"));
30
30
  }
31
31
 
32
32
  public function testWordBeginningWithA()
33
33
  {
34
34
  $this->markTestSkipped();
35
35
 
36
- $this->assertEquals("appleay", PigLatin::translate("apple"));
36
+ $this->assertEquals("appleay", translate("apple"));
37
37
  }
38
38
 
39
39
  public function testWordBeginningWithE()
40
40
  {
41
41
  $this->markTestSkipped();
42
42
 
43
- $this->assertEquals("earay", PigLatin::translate("ear"));
43
+ $this->assertEquals("earay", translate("ear"));
44
44
  }
45
45
 
46
46
  public function testWordBeginningWithI()
47
47
  {
48
48
  $this->markTestSkipped();
49
49
 
50
- $this->assertEquals("iglooay", PigLatin::translate("igloo"));
50
+ $this->assertEquals("iglooay", translate("igloo"));
51
51
  }
52
52
 
53
53
  public function testWordBeginningWithO()
54
54
  {
55
55
  $this->markTestSkipped();
56
56
 
57
- $this->assertEquals("objectay", PigLatin::translate("object"));
57
+ $this->assertEquals("objectay", translate("object"));
58
58
  }
59
59
 
60
60
  public function testWordBeginningWithU()
61
61
  {
62
62
  $this->markTestSkipped();
63
63
 
64
- $this->assertEquals("underay", PigLatin::translate("under"));
64
+ $this->assertEquals("underay", translate("under"));
65
+ }
66
+
67
+ public function testWordBeginningVowelFollowedByQu()
68
+ {
69
+ $this->markTestSkipped();
70
+
71
+ $this->assertEquals("equalay", translate("equal"));
65
72
  }
66
73
 
67
74
 
@@ -69,7 +76,7 @@ class PigLatinTest extends PHPUnit_Framework_TestCase
69
76
  {
70
77
  $this->markTestSkipped();
71
78
 
72
- $this->assertEquals("atqay", PigLatin::translate("qat"));
79
+ $this->assertEquals("atqay", translate("qat"));
73
80
  }
74
81
 
75
82
 
@@ -77,62 +84,62 @@ class PigLatinTest extends PHPUnit_Framework_TestCase
77
84
  {
78
85
  $this->markTestSkipped();
79
86
 
80
- $this->assertEquals("airchay", PigLatin::translate("chair"));
87
+ $this->assertEquals("airchay", translate("chair"));
81
88
  }
82
89
 
83
90
  public function testWordBeginningWithQu()
84
91
  {
85
92
  $this->markTestSkipped();
86
93
 
87
- $this->assertEquals("eenquay", PigLatin::translate("queen"));
94
+ $this->assertEquals("eenquay", translate("queen"));
88
95
  }
89
96
 
90
97
  public function testWordBeginningWithQuAndAPrecedingConsonant()
91
98
  {
92
99
  $this->markTestSkipped();
93
100
 
94
- $this->assertEquals("aresquay", PigLatin::translate("square"));
101
+ $this->assertEquals("aresquay", translate("square"));
95
102
  }
96
103
 
97
104
  public function testWordBeginningWithTh()
98
105
  {
99
106
  $this->markTestSkipped();
100
107
 
101
- $this->assertEquals("erapythay", PigLatin::translate("therapy"));
108
+ $this->assertEquals("erapythay", translate("therapy"));
102
109
  }
103
110
 
104
111
  public function testWordBeginningWithThr()
105
112
  {
106
113
  $this->markTestSkipped();
107
114
 
108
- $this->assertEquals("ushthray", PigLatin::translate("thrush"));
115
+ $this->assertEquals("ushthray", translate("thrush"));
109
116
  }
110
117
 
111
118
  public function testWordBeginningWithSch()
112
119
  {
113
120
  $this->markTestSkipped();
114
121
 
115
- $this->assertEquals("oolschay", PigLatin::translate("school"));
122
+ $this->assertEquals("oolschay", translate("school"));
116
123
  }
117
124
 
118
125
  public function testWordBeginningWithYt()
119
126
  {
120
127
  $this->markTestSkipped();
121
128
 
122
- $this->assertEquals("yttriaay", PigLatin::translate("yttria"));
129
+ $this->assertEquals("yttriaay", translate("yttria"));
123
130
  }
124
131
 
125
132
  public function testWordBeginningWithXr()
126
133
  {
127
134
  $this->markTestSkipped();
128
135
 
129
- $this->assertEquals("xrayay", PigLatin::translate("xray"));
136
+ $this->assertEquals("xrayay", translate("xray"));
130
137
  }
131
138
 
132
139
  public function testAWholePhrase()
133
140
  {
134
141
  $this->markTestSkipped();
135
142
 
136
- $this->assertEquals("ickquay astfay unray", PigLatin::translate("quick fast run"));
143
+ $this->assertEquals("ickquay astfay unray", translate("quick fast run"));
137
144
  }
138
145
  }
@@ -0,0 +1,65 @@
1
+ <?php
2
+
3
+ class SpaceAge
4
+ {
5
+ public $seconds;
6
+
7
+ const EARTH_YEAR_IN_SECONDS = 31557600;
8
+ const MERCURY_YEAR_IN_EY = 0.2408467;
9
+ const VENUS_YEAR_IN_EY = 0.61519726;
10
+ const MARS_YEAR_IN_EY = 1.8808158;
11
+ const JUPITER_YEAR_IN_EY = 11.862615;
12
+ const SATURN_YEAR_IN_EY = 29.447498;
13
+ const URANUS_YEAR_IN_EY = 84.016846;
14
+ const NEPTUNE_YEAR_IN_EY = 164.79132;
15
+
16
+ public function __construct($seconds)
17
+ {
18
+ $this->seconds = $seconds;
19
+ }
20
+
21
+ public function seconds()
22
+ {
23
+ return $this->seconds;
24
+ }
25
+
26
+ public function earth()
27
+ {
28
+ return $this->seconds / self::EARTH_YEAR_IN_SECONDS;
29
+ }
30
+
31
+ public function mercury()
32
+ {
33
+ return $this->earth() / self::MERCURY_YEAR_IN_EY;
34
+ }
35
+
36
+ public function venus()
37
+ {
38
+ return $this->earth() / self::VENUS_YEAR_IN_EY;
39
+ }
40
+
41
+ public function mars()
42
+ {
43
+ return $this->earth() / self::MARS_YEAR_IN_EY;
44
+ }
45
+
46
+ public function jupiter()
47
+ {
48
+ return $this->earth() / self::JUPITER_YEAR_IN_EY;
49
+ }
50
+
51
+ public function saturn()
52
+ {
53
+ return $this->earth() / self::SATURN_YEAR_IN_EY;
54
+ }
55
+
56
+ public function uranus()
57
+ {
58
+ return $this->earth() / self::URANUS_YEAR_IN_EY;
59
+ }
60
+
61
+ public function neptune()
62
+ {
63
+ return $this->earth() / self::NEPTUNE_YEAR_IN_EY;
64
+ }
65
+ }
@@ -0,0 +1,70 @@
1
+ <?php
2
+
3
+ require "space-age.php";
4
+
5
+ class SpaceAgeTester extends PHPUnit_Framework_TestCase
6
+ {
7
+ const DELTA = 0.01;
8
+
9
+ public function testAgeInSeconds()
10
+ {
11
+ $age = new SpaceAge(1000000);
12
+ $this->assertEquals(1000000, $age->seconds());
13
+ }
14
+
15
+ public function testAgeOnEarth()
16
+ {
17
+ $this->markTestSkipped();
18
+ $age = new SpaceAge(1000000000);
19
+ $this->assertEquals(31.69, $age->earth(), '', self::DELTA);
20
+ }
21
+
22
+ public function testAgeOnMercury()
23
+ {
24
+ $this->markTestSkipped();
25
+ $age = new SpaceAge(2134835688);
26
+ $this->assertEquals(280.88, $age->mercury(), '', self::DELTA);
27
+ }
28
+
29
+ public function testAgeOnVenus()
30
+ {
31
+ $this->markTestSkipped();
32
+ $age = new SpaceAge(189839836);
33
+ $this->assertEquals(9.78, $age->venus(), '', self::DELTA);
34
+ }
35
+
36
+ public function testAgeOnMars()
37
+ {
38
+ $this->markTestSkipped();
39
+ $age = new SpaceAge(2329871239);
40
+ $this->assertEquals(39.25, $age->mars(), '', self::DELTA);
41
+ }
42
+
43
+ public function testAgeOnJupiter()
44
+ {
45
+ $this->markTestSkipped();
46
+ $age = new SpaceAge(901876382);
47
+ $this->assertEquals(2.41, $age->jupiter(), '', self::DELTA);
48
+ }
49
+
50
+ public function testAgeOnSaturn()
51
+ {
52
+ $this->markTestSkipped();
53
+ $age = new SpaceAge(3000000000);
54
+ $this->assertEquals(3.23, $age->saturn(), '', self::DELTA);
55
+ }
56
+
57
+ public function testAgeOnUranus()
58
+ {
59
+ $this->markTestSkipped();
60
+ $age = new SpaceAge(3210123456);
61
+ $this->assertEquals(1.21, $age->uranus(), '', self::DELTA);
62
+ }
63
+
64
+ public function testAgeOnNeptune()
65
+ {
66
+ $this->markTestSkipped();
67
+ $age = new SpaceAge(8210123456);
68
+ $this->assertEquals(1.58, $age->neptune(), '', self::DELTA);
69
+ }
70
+ }
@@ -0,0 +1,43 @@
1
+ <?php
2
+
3
+ class Triangle
4
+ {
5
+ protected $sideA;
6
+ protected $sideB;
7
+ protected $sideC;
8
+
9
+ public function __construct($sideA, $sideB, $sideC)
10
+ {
11
+ $this->sideA = $sideA;
12
+ $this->sideB = $sideB;
13
+ $this->sideC = $sideC;
14
+ }
15
+
16
+ public function kind()
17
+ {
18
+ if (0 == ($this->sideA + $this->sideB + $this->sideC)) {
19
+ throw new \Exception("These sides have no values.");
20
+ }
21
+
22
+ $sides = [$this->sideA, $this->sideB, $this->sideC];
23
+ sort($sides);
24
+ if ($sides[2] >= $sides[0] + $sides[1]) {
25
+ throw new \Exception("This violates the triangle inequality");
26
+ }
27
+
28
+ if ($this->sideA == $this->sideB &&
29
+ $this->sideA == $this->sideC
30
+ ) {
31
+ return 'equilateral';
32
+ }
33
+
34
+ if ($this->sideB == $this->sideC ||
35
+ $this->sideA == $this->sideC ||
36
+ $this->sideA == $this->sideB
37
+ ) {
38
+ return 'isosceles';
39
+ }
40
+
41
+ return 'scalene';
42
+ }
43
+ }
@@ -0,0 +1,140 @@
1
+ <?php
2
+
3
+ require "triangle.php";
4
+
5
+ class TriangleTest extends \PHPUnit_Framework_TestCase
6
+ {
7
+ public function testEquilateralTrianglesHaveEqualSides()
8
+ {
9
+ $this->assertEquals(
10
+ 'equilateral',
11
+ (new Triangle(2, 2, 2))->kind()
12
+ );
13
+ }
14
+
15
+ public function testLargerEquilateralTrianglesHaveEqualSides()
16
+ {
17
+ $this->markTestSkipped();
18
+ $this->assertEquals(
19
+ 'equilateral',
20
+ (new Triangle(10, 10, 10))->kind()
21
+ );
22
+ }
23
+
24
+ public function testIsoscelesTriangleWhenLastTwoSidesAreEqual()
25
+ {
26
+ $this->markTestSkipped();
27
+ $this->assertEquals(
28
+ 'isosceles',
29
+ (new Triangle(3, 4, 4))->kind()
30
+ );
31
+ }
32
+
33
+ public function testIsoscelesTriangleWhenFirstAndLastSidesAreEqual()
34
+ {
35
+ $this->markTestSkipped();
36
+ $this->assertEquals(
37
+ 'isosceles',
38
+ (new Triangle(4, 3, 4))->kind()
39
+ );
40
+ }
41
+
42
+ public function testIsoscelesTriangleWhenFirstTwoSidesAreEqual()
43
+ {
44
+ $this->markTestSkipped();
45
+ $this->assertEquals(
46
+ 'isosceles',
47
+ (new Triangle(4, 4, 3))->kind()
48
+ );
49
+ }
50
+
51
+ public function testIsoscelesTrianglesWithUnequalSideLargerThanEqualSides()
52
+ {
53
+ $this->markTestSkipped();
54
+ $this->assertEquals(
55
+ 'isosceles',
56
+ (new Triangle(4, 4, 7))->kind()
57
+ );
58
+ }
59
+
60
+ public function testScaleneTrianglesHaveNoEqualSides()
61
+ {
62
+ $this->markTestSkipped();
63
+ $this->assertEquals(
64
+ 'scalene',
65
+ (new Triangle(3, 4, 5))->kind()
66
+ );
67
+ }
68
+
69
+ public function test2aEqualsBPlusCLooksLikeEquilateralButIsNot()
70
+ {
71
+ $this->markTestSkipped();
72
+ $this->assertEquals(
73
+ 'scalene',
74
+ (new Triangle(5, 4, 6))->kind()
75
+ );
76
+ }
77
+
78
+ public function testScaleneTrianglesHaveNoEqualSidesAtLargerScale()
79
+ {
80
+ $this->markTestSkipped();
81
+ $this->assertEquals(
82
+ 'scalene',
83
+ (new Triangle(10, 11, 12))->kind()
84
+ );
85
+ }
86
+
87
+ public function testScaleneTrianglesHaveNoEqualSidesInDescendingOrder()
88
+ {
89
+ $this->markTestSkipped();
90
+ $this->assertEquals(
91
+ 'scalene',
92
+ (new Triangle(5, 4, 2))->kind()
93
+ );
94
+ }
95
+
96
+ public function testVerySmallTrianglesAreLegal()
97
+ {
98
+ $this->markTestSkipped();
99
+ $this->assertEquals(
100
+ 'scalene',
101
+ (new Triangle(0.4, 0.6, 0.3))->kind()
102
+ );
103
+ }
104
+
105
+ /**
106
+ * @expectedException \Exception
107
+ */
108
+ public function testTrianglesWithNoSizeAreIllegal()
109
+ {
110
+ $this->markTestSkipped();
111
+ (new Triangle(0, 0, 0))->kind();
112
+ }
113
+
114
+ /**
115
+ * @expectedException \Exception
116
+ */
117
+ public function testTrianglesViolatingTriangleInequalityAreIllegal()
118
+ {
119
+ $this->markTestSkipped();
120
+ (new Triangle(1, 1, 3))->kind();
121
+ }
122
+
123
+ /**
124
+ * @expectedException \Exception
125
+ */
126
+ public function testTrianglesViolatingTriangleInequalityAreIllegal2()
127
+ {
128
+ $this->markTestSkipped();
129
+ (new Triangle(7, 3, 2))->kind();
130
+ }
131
+
132
+ /**
133
+ * @expectedException \Exception
134
+ */
135
+ public function testTrianglesViolatingTriangleInequalityAreIllegal3()
136
+ {
137
+ $this->markTestSkipped();
138
+ (new Triangle(1, 3, 1))->kind();
139
+ }
140
+ }
@@ -1,4 +1,4 @@
1
- use "PonyTest"
1
+ use "ponytest"
2
2
 
3
3
  class Anagram
4
4
 
@@ -9,7 +9,7 @@ class Anagram
9
9
 
10
10
  for (index, value) in phrase.pairs() do
11
11
  let value_array: Array[U8] = _to_array_and_order(value.lower())
12
-
12
+
13
13
  if value.size() != word.size() then continue end
14
14
  if value.lower() == word.lower() then continue end
15
15
  if _check_array_eq(word_array, value_array) then
@@ -18,9 +18,9 @@ class Anagram
18
18
  end
19
19
 
20
20
  anagrams
21
-
21
+
22
22
  fun _to_array_and_order(word: String): Array[U8] ? =>
23
- // As of right now the String.split() function doesn't appear to work
23
+ // As of right now the String.split() function doesn't appear to work
24
24
  // on no delimiter, i.e. "abcd".split("") to ["a", "b", "c", "d"]
25
25
  // So I pull of the bytes
26
26
 
@@ -31,7 +31,7 @@ class Anagram
31
31
  word_array.push(value)
32
32
  end
33
33
 
34
-
34
+
35
35
  for (index, value) in word_array.pairs() do
36
36
  var inserted = false
37
37
  if (index == 0) then sorted_array.push(value) end
@@ -60,7 +60,7 @@ class Anagram
60
60
  if expect.size() != actual.size() then
61
61
  ok = false
62
62
  else
63
- var i: U64 = 0
63
+ var i: USize = 0
64
64
  while i < expect.size() do
65
65
  if expect(i) != actual(i) then
66
66
  ok = false
@@ -10,14 +10,14 @@ actor Main is TestList
10
10
  fun tag tests(test: PonyTest) =>
11
11
  test(_AnagramTest)
12
12
 
13
- class _AnagramTest iso is UnitTest
13
+ class iso _AnagramTest is UnitTest
14
14
  """
15
- Test Anagram package
15
+ Test Anagram package
16
16
  """
17
17
 
18
18
  fun name(): String => "anagram/Anagram"
19
19
 
20
- fun apply(h: TestHelper): TestResult ? =>
20
+ fun apply(h: TestHelper): None ? =>
21
21
  let anagrams = ["banana", "bob", "sent", "sale", "ales"]
22
22
  let emptyArray: Array[String] = Array[String]
23
23
 
@@ -33,4 +33,3 @@ class _AnagramTest iso is UnitTest
33
33
  h.assert_array_eq[String](["sent"],Anagram("nETs", anagrams))
34
34
  // Anagram should return multiple anagrams
35
35
  h.assert_array_eq[String](["sale", "ales"], Anagram("seal", anagrams))
36
- true
@@ -13,60 +13,60 @@ actor Main is TestList
13
13
  test(_BobSilentTest)
14
14
  test(_BobDefaultTest)
15
15
 
16
- class _BobShoutTest iso is UnitTest
16
+ class iso _BobShoutTest is UnitTest
17
17
  """
18
18
  Test matching when Bob is shouted at
19
19
  """
20
20
  fun name(): String => "bob/Bob"
21
21
 
22
- fun apply(h: TestHelper): TestResult ? =>
22
+ fun apply(h: TestHelper): None ? =>
23
23
  let shout_resp: String = "Whoa, chill out!"
24
24
 
25
- h.expect_eq[String](shout_resp, Bob("WATCH OUT!"))
26
- h.expect_eq[String](shout_resp, Bob("WHAT THE HELL WERE YOU THINKING?"))
27
- h.expect_eq[String](shout_resp, Bob("1, 2, 3 GO!"))
28
- h.expect_eq[String](shout_resp, Bob("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))
25
+ h.assert_eq[String](shout_resp, Bob("WATCH OUT!"))
26
+ h.assert_eq[String](shout_resp, Bob("WHAT THE HELL WERE YOU THINKING?"))
27
+ h.assert_eq[String](shout_resp, Bob("1, 2, 3 GO!"))
28
+ h.assert_eq[String](shout_resp, Bob("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))
29
29
 
30
- class _BobQuestionTest iso is UnitTest
30
+ class iso _BobQuestionTest is UnitTest
31
31
  """
32
32
  Test matching when Bob is questioned
33
33
  """
34
34
 
35
35
  fun name(): String => "bob/Bob"
36
36
 
37
- fun apply(h: TestHelper): TestResult ? =>
37
+ fun apply(h: TestHelper): None ? =>
38
38
  let ques_resp: String = "Sure."
39
39
 
40
- h.expect_eq[String](ques_resp, Bob("Does this cryogenic chamber make me look fat?"))
41
- h.expect_eq[String](ques_resp, Bob("You are, what, like 15?"))
42
- h.expect_eq[String](ques_resp, Bob("4?"))
43
- h.expect_eq[String](ques_resp, Bob("Wait! Hang on. Are you going to be OK?"))
40
+ h.assert_eq[String](ques_resp, Bob("Does this cryogenic chamber make me look fat?"))
41
+ h.assert_eq[String](ques_resp, Bob("You are, what, like 15?"))
42
+ h.assert_eq[String](ques_resp, Bob("4?"))
43
+ h.assert_eq[String](ques_resp, Bob("Wait! Hang on. Are you going to be OK?"))
44
44
 
45
- class _BobSilentTest iso is UnitTest
45
+ class iso _BobSilentTest is UnitTest
46
46
  """
47
47
  Test matching when Bob faces silence
48
48
  """
49
49
 
50
50
  fun name(): String => "bob/Bob"
51
51
 
52
- fun apply(h: TestHelper): TestResult ? =>
52
+ fun apply(h: TestHelper): None ? =>
53
53
  let silent_resp: String = "Fine. Be that way!"
54
54
 
55
- h.expect_eq[String](silent_resp, Bob(""))
56
- h.expect_eq[String](silent_resp, Bob(" "))
55
+ h.assert_eq[String](silent_resp, Bob(""))
56
+ h.assert_eq[String](silent_resp, Bob(" "))
57
57
 
58
- class _BobDefaultTest iso is UnitTest
58
+ class iso _BobDefaultTest is UnitTest
59
59
  """
60
60
  Test matching when Bob is defaulting
61
61
  """
62
62
 
63
63
  fun name(): String => "bob/Bob"
64
64
 
65
- fun apply(h: TestHelper): TestResult ? =>
65
+ fun apply(h: TestHelper): None ? =>
66
66
  let default_resp: String = "Whatever."
67
67
 
68
- h.expect_eq[String](default_resp, Bob("Tom-ay-to, tom-aaaah-to."))
69
- h.expect_eq[String](default_resp, Bob("Let's go make out behind the gym!"))
70
- h.expect_eq[String](default_resp, Bob("It's OK if you don't want to go to the DMV."))
71
- h.expect_eq[String](default_resp, Bob("1, 2, 3"))
72
- h.expect_eq[String](default_resp, Bob("Ending with ? means a question."))
68
+ h.assert_eq[String](default_resp, Bob("Tom-ay-to, tom-aaaah-to."))
69
+ h.assert_eq[String](default_resp, Bob("Let's go make out behind the gym!"))
70
+ h.assert_eq[String](default_resp, Bob("It's OK if you don't want to go to the DMV."))
71
+ h.assert_eq[String](default_resp, Bob("1, 2, 3"))
72
+ h.assert_eq[String](default_resp, Bob("Ending with ? means a question."))