trackler 2.2.1.30 → 2.2.1.31

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/word-search/canonical-data.json +278 -4
  4. data/tracks/c/exercises/raindrops/test/test_raindrops.c +0 -16
  5. data/tracks/ceylon/README.md +1 -1
  6. data/tracks/ceylon/config.json +12 -0
  7. data/tracks/ceylon/docs/RESOURCES.md +1 -1
  8. data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +1 -1
  9. data/tracks/ceylon/exercises/anagram/source/anagram/module.ceylon +1 -1
  10. data/tracks/ceylon/exercises/bracket-push/example/module.ceylon +2 -2
  11. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +1 -1
  12. data/tracks/ceylon/exercises/bracket-push/source/bracketpush/module.ceylon +1 -1
  13. data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +1 -1
  14. data/tracks/ceylon/exercises/hamming/source/hamming/module.ceylon +1 -1
  15. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +1 -1
  16. data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/module.ceylon +1 -1
  17. data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +1 -1
  18. data/tracks/ceylon/exercises/leap/source/leap/module.ceylon +1 -1
  19. data/tracks/ceylon/exercises/react/example/module.ceylon +2 -2
  20. data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +1 -1
  21. data/tracks/ceylon/exercises/react/source/react/module.ceylon +1 -1
  22. data/tracks/ceylon/exercises/rna-transcription/README.md +41 -0
  23. data/tracks/ceylon/exercises/rna-transcription/example/RNA.ceylon +13 -0
  24. data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNA.ceylon +5 -0
  25. data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNAtest.ceylon +33 -0
  26. data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/module.ceylon +3 -0
  27. data/tracks/ceylon/exercises/sieve/example/module.ceylon +2 -2
  28. data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +1 -1
  29. data/tracks/ceylon/exercises/sieve/source/sieve/module.ceylon +1 -1
  30. data/tracks/clojure/.travis.yml +1 -1
  31. data/tracks/clojure/_src/generator.clj +1 -1
  32. data/tracks/clojure/exercises/clock/{clock.mustache → .meta/clock.mustache} +0 -0
  33. data/tracks/clojure/exercises/luhn/{luhn.mustache → .meta/luhn.mustache} +0 -0
  34. data/tracks/clojure/exercises/sublist/{sublist.mustache → .meta/sublist.mustache} +0 -0
  35. data/tracks/go/exercises/robot-name/.meta/hints.md +13 -0
  36. data/tracks/go/exercises/robot-name/bonus_example.go +2 -0
  37. data/tracks/java/gradle/wrapper/gradle-wrapper.jar +0 -0
  38. data/tracks/java/gradle/wrapper/gradle-wrapper.properties +2 -2
  39. data/tracks/java/gradlew +3 -3
  40. data/tracks/java/gradlew.bat +0 -0
  41. data/tracks/php/config.json +8 -0
  42. data/tracks/php/exercises/flatten-array/example.php +10 -0
  43. data/tracks/php/exercises/flatten-array/flatten-array_test.php +51 -0
  44. data/tracks/ruby/exercises/hello-world/GETTING_STARTED.md +2 -2
  45. data/tracks/scala/exercises/accumulate/src/test/scala/AccumulateTest.scala +1 -0
  46. data/tracks/scala/exercises/allergies/example.scala +3 -3
  47. data/tracks/scala/exercises/allergies/src/test/scala/AllergiesTest.scala +68 -33
  48. data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +1 -0
  49. data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +1 -0
  50. data/tracks/scala/exercises/connect/example.scala +1 -1
  51. data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +72 -56
  52. data/tracks/scala/exercises/dominoes/src/main/scala/.keep +0 -0
  53. data/tracks/scala/exercises/dominoes/src/test/scala/DominoesTest.scala +32 -31
  54. data/tracks/scala/exercises/grade-school/src/test/scala/GradeSchoolTest.scala +1 -0
  55. data/tracks/scala/exercises/lens-person/src/test/scala/LensPersonTest.scala +1 -0
  56. data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +1 -0
  57. data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +1 -0
  58. data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +1 -0
  59. data/tracks/scala/exercises/protein-translation/src/test/scala/ProteinTranslationTest.scala +2 -1
  60. data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +1 -0
  61. data/tracks/scala/exercises/robot-name/src/test/scala/RobotNameTest.scala +1 -0
  62. data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +1 -0
  63. data/tracks/scala/exercises/sgf-parsing/src/test/scala/SgfTest.scala +1 -0
  64. data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +1 -0
  65. data/tracks/scala/exercises/simple-linked-list/src/test/scala/SimpleLinkedListTest.scala +1 -1
  66. data/tracks/scala/exercises/strain/src/test/scala/StrainTest.scala +2 -1
  67. data/tracks/scala/exercises/wordy/example.scala +3 -3
  68. data/tracks/scala/exercises/wordy/src/test/scala/WordyTest.scala +84 -0
  69. data/tracks/scala/exercises/zebra-puzzle/src/test/scala/ZebraPuzzleTest.scala +1 -0
  70. data/tracks/scala/exercises/zipper/src/test/scala/ZipperTest.scala +1 -0
  71. data/tracks/scala/testgen/src/main/scala/AllergiesTestGenerator.scala +60 -0
  72. data/tracks/scala/testgen/src/main/scala/ConnectTestGenerator.scala +52 -0
  73. data/tracks/scala/testgen/src/main/scala/DominoesTestGenerator.scala +71 -0
  74. data/tracks/scala/testgen/src/main/scala/WordyTestGenerator.scala +35 -0
  75. data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +20 -0
  76. data/tracks/scala/testgen/src/main/twirl/funSuiteTemplateIgnoreExpected.scala.txt +16 -0
  77. metadata +20 -8
  78. data/tracks/scala/exercises/allergies/src/main/scala/Allergies.scala +0 -11
  79. data/tracks/scala/exercises/dominoes/src/main/scala/Dominoes.scala +0 -4
  80. data/tracks/scala/exercises/wordy/src/test/scala/WordProblemTest.scala +0 -81
@@ -0,0 +1,13 @@
1
+ ### Bonus exercise
2
+
3
+ Once you get `go test` passing, try `go test -tags bonus`. This uses a *build
4
+ tag* to enable a test that wasn't previously enabled. Build tags control which
5
+ files should be included in the package. You can read more about those at [the
6
+ Go documentation](https://golang.org/pkg/go/build/#hdr-Build_Constraints).
7
+
8
+ For this exercise it limits `go test` to only build the tests in the
9
+ `robot_name_test.go` file. We can then include the bonus test in the
10
+ `bonus_test.go` file with the tags flag as described above.
11
+
12
+ To get the bonus test to pass you'll have to ensure a robot's name has not been
13
+ used before.
@@ -7,6 +7,8 @@ import (
7
7
  "math/rand"
8
8
  )
9
9
 
10
+ const testVersion = 1
11
+
10
12
  type Robot struct {
11
13
  name string
12
14
  }
@@ -1,6 +1,6 @@
1
- #Sat Sep 09 18:32:27 EDT 2017
1
+ #Fri Jul 07 18:07:45 EDT 2017
2
2
  distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-bin.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-bin.zip
data/tracks/java/gradlew CHANGED
@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
33
33
  # Use the maximum available, or set MAX_FD != -1 to use that value.
34
34
  MAX_FD="maximum"
35
35
 
36
- warn () {
36
+ warn ( ) {
37
37
  echo "$*"
38
38
  }
39
39
 
40
- die () {
40
+ die ( ) {
41
41
  echo
42
42
  echo "$*"
43
43
  echo
@@ -155,7 +155,7 @@ if $cygwin ; then
155
155
  fi
156
156
 
157
157
  # Escape application args
158
- save () {
158
+ save ( ) {
159
159
  for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
160
  echo " "
161
161
  }
File without changes
@@ -566,6 +566,14 @@
566
566
  "topics": [
567
567
 
568
568
  ]
569
+ },
570
+ {
571
+ "uuid": "9dede68f-6b48-4142-88fd-0cf2c9de7207",
572
+ "slug": "flatten-array",
573
+ "difficulty": 2,
574
+ "topics": [
575
+ "Arrays"
576
+ ]
569
577
  }
570
578
  ]
571
579
  }
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ function flatten($array = [])
4
+ {
5
+ $return = array();
6
+ array_walk_recursive($array, function ($x) use (&$return) {
7
+ return !is_null($x) ? $return[] = $x : [];
8
+ });
9
+ return $return;
10
+ }
@@ -0,0 +1,51 @@
1
+ <?php
2
+
3
+ require 'flatten-array.php';
4
+
5
+ class FlattenArrayTest extends PHPUnit\Framework\TestCase
6
+ {
7
+ public function testWithOutNesting()
8
+ {
9
+ $input = [0, 1, 2];
10
+ $expected = [0, 1, 2];
11
+ $this->assertEquals($expected, flatten($input));
12
+ }
13
+ public function testArrayWithJustIntegersPresent()
14
+ {
15
+ $this->markTestSkipped();
16
+ $input = [1, [2, 3, 4, 5, 6, 7], 8];
17
+ $expected = [1, 2, 3, 4, 5, 6, 7, 8];
18
+ $this->assertEquals($expected, flatten($input));
19
+ }
20
+
21
+ public function testFiveLevelNesting()
22
+ {
23
+ $this->markTestSkipped();
24
+ $input = [0, 2, [[2, 3], 8, 100, 4, [[[50]]]], -2];
25
+ $expected = [0, 2, 2, 3, 8, 100, 4, 50, -2];
26
+ $this->assertEquals($expected, flatten($input));
27
+ }
28
+
29
+ public function testSixLevelNesting()
30
+ {
31
+ $this->markTestSkipped();
32
+ $input = [1, [2, [[3]], [4, [[5]]], 6, 7], 8];
33
+ $expected = [1, 2, 3, 4, 5, 6, 7, 8];
34
+ $this->assertEquals($expected, flatten($input));
35
+ }
36
+ public function testSixLevelNestListWithNullValues()
37
+ {
38
+ $this->markTestSkipped();
39
+ $input = [0, 2, [[2, 3], 8, [[100]], null, [[null]]], -2];
40
+ $expected = [0, 2, 2, 3, 8, 100, -2];
41
+ $this->assertEquals($expected, flatten($input));
42
+ }
43
+
44
+ public function testAllValuesInNestedListAreNull()
45
+ {
46
+ $this->markTestSkipped();
47
+ $input = [null, [[[null]]], null, null, [[null, null], null], null];
48
+ $expected = [];
49
+ $this->assertEquals($expected, flatten($input));
50
+ }
51
+ }
@@ -95,8 +95,8 @@ Run the test again.
95
95
 
96
96
  1) Failure:
97
97
  HelloWorldTest#test_no_name [hello_world_test.rb:11]:
98
- When given no name, we should greet the world!.
99
- Expected: "Hello, world!"
98
+ When given no name, we should greet the world.
99
+ Expected: "Hello, World!"
100
100
  Actual: nil
101
101
 
102
102
  Up until now we've been getting errors, this time we get a failure.
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{Matchers, FlatSpec}
2
2
 
3
+ /** @version created manually **/
3
4
  class AccumulateTest extends FlatSpec with Matchers {
4
5
 
5
6
  it should "allow empty accumulation" in {
@@ -3,11 +3,11 @@ import Allergen.Allergen
3
3
  object Allergies {
4
4
  private lazy val allergenList = Allergen.values
5
5
 
6
- def isAllergicTo(allergen: Allergen, score: Int): Boolean =
6
+ def allergicTo(allergen: Allergen, score: Int): Boolean =
7
7
  (allergen.id & score) != 0
8
8
 
9
- def allergies(score: Int): List[Allergen] =
10
- allergenList.filter(a => isAllergicTo(a, score)).toList
9
+ def list(score: Int): List[Allergen] =
10
+ allergenList.filter(a => allergicTo(a, score)).toList
11
11
  }
12
12
 
13
13
  object Allergen extends Enumeration {
@@ -1,69 +1,104 @@
1
- import org.scalatest.{Matchers, FlatSpec}
1
+ import org.scalatest.{Matchers, FunSuite}
2
2
 
3
- class AllergiesTest extends FlatSpec with Matchers {
4
- it should "handle no allergies means not allergic" in {
5
- Allergies.isAllergicTo(Allergen.Peanuts, 0) should equal (false)
6
- Allergies.isAllergicTo(Allergen.Cats, 0) should equal (false)
7
- Allergies.isAllergicTo(Allergen.Strawberries, 0) should equal (false)
3
+ /** @version 1.0.0 */
4
+ class AllergiesTest extends FunSuite with Matchers {
5
+
6
+ test("Allergen.Peanuts - no allergies means not allergic") {
7
+ Allergies.allergicTo(Allergen.Peanuts, 0) should be(false)
8
+ }
9
+
10
+ test("Allergen.Cats - no allergies means not allergic") {
11
+ pending
12
+ Allergies.allergicTo(Allergen.Cats, 0) should be(false)
13
+ }
14
+
15
+ test("Allergen.Strawberries - no allergies means not allergic") {
16
+ pending
17
+ Allergies.allergicTo(Allergen.Strawberries, 0) should be(false)
18
+ }
19
+
20
+ test("Allergen.Eggs - is allergic to eggs") {
21
+ pending
22
+ Allergies.allergicTo(Allergen.Eggs, 1) should be(true)
23
+ }
24
+
25
+ test("Allergen.Eggs - allergic to eggs in addition to other stuff") {
26
+ pending
27
+ Allergies.allergicTo(Allergen.Eggs, 5) should be(true)
8
28
  }
9
29
 
10
- it should "handle is allergic to eggs" in {
30
+ test("Allergen.Shellfish - allergic to eggs in addition to other stuff") {
11
31
  pending
12
- Allergies.isAllergicTo(Allergen.Eggs, 1) should equal (true)
32
+ Allergies.allergicTo(Allergen.Shellfish, 5) should be(true)
13
33
  }
14
34
 
15
- it should "handle is allergic to eggs in addition to other stuff" in {
35
+ test("Allergen.Strawberries - allergic to eggs in addition to other stuff") {
16
36
  pending
17
- Allergies.isAllergicTo(Allergen.Eggs, 5) should equal (true)
37
+ Allergies.allergicTo(Allergen.Strawberries, 5) should be(false)
18
38
  }
19
39
 
20
- it should "handle no allergies" in {
40
+ test("no allergies at all") {
21
41
  pending
22
- Allergies.allergies(0) should equal (List())
42
+ Allergies.list(0) should be(List())
23
43
  }
24
44
 
25
- it should "handle allergic to just eggs" in {
45
+ test("allergic to just eggs") {
26
46
  pending
27
- Allergies.allergies(1) should equal (List(Allergen.Eggs))
47
+ Allergies.list(1) should be(List(Allergen.Eggs))
28
48
  }
29
49
 
30
- it should "handle allergic to just peanuts" in {
50
+ test("allergic to just peanuts") {
31
51
  pending
32
- Allergies.allergies(2) should equal (List(Allergen.Peanuts))
52
+ Allergies.list(2) should be(List(Allergen.Peanuts))
33
53
  }
34
54
 
35
- it should "handle allergic to just strawberries" in {
55
+ test("allergic to just strawberries") {
36
56
  pending
37
- Allergies.allergies(8) should equal (List(Allergen.Strawberries))
57
+ Allergies.list(8) should be(List(Allergen.Strawberries))
38
58
  }
39
59
 
40
- it should "handle allergic to eggs and peanuts" in {
60
+ test("allergic to eggs and peanuts") {
41
61
  pending
42
- Allergies.allergies(3) should equal (List(Allergen.Eggs, Allergen.Peanuts))
62
+ Allergies.list(3) should be(List(Allergen.Eggs, Allergen.Peanuts))
43
63
  }
44
64
 
45
- it should "handle allergic to more than eggs but not peanuts" in {
65
+ test("allergic to more than eggs but not peanuts") {
46
66
  pending
47
- Allergies.allergies(5) should equal (List(Allergen.Eggs, Allergen.Shellfish))
67
+ Allergies.list(5) should be(List(Allergen.Eggs, Allergen.Shellfish))
48
68
  }
49
69
 
50
- it should "handle allergic to lots of stuff" in {
70
+ test("allergic to lots of stuff") {
51
71
  pending
52
- Allergies.allergies(248) should equal (List(Allergen.Strawberries, Allergen.Tomatoes,
53
- Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
72
+ Allergies.list(248) should be(
73
+ List(Allergen.Strawberries,
74
+ Allergen.Tomatoes,
75
+ Allergen.Chocolate,
76
+ Allergen.Pollen,
77
+ Allergen.Cats))
54
78
  }
55
79
 
56
- it should "handle allergic to everything" in {
80
+ test("allergic to everything") {
57
81
  pending
58
- Allergies.allergies(255) should equal (List(Allergen.Eggs, Allergen.Peanuts,
59
- Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes,
60
- Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
82
+ Allergies.list(255) should be(
83
+ List(Allergen.Eggs,
84
+ Allergen.Peanuts,
85
+ Allergen.Shellfish,
86
+ Allergen.Strawberries,
87
+ Allergen.Tomatoes,
88
+ Allergen.Chocolate,
89
+ Allergen.Pollen,
90
+ Allergen.Cats))
61
91
  }
62
92
 
63
- it should "ignore non allergen score parts" in {
93
+ test("ignore non allergen score parts") {
64
94
  pending
65
- Allergies.allergies(509) should equal (List(Allergen.Eggs,
66
- Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes,
67
- Allergen.Chocolate, Allergen.Pollen, Allergen.Cats))
95
+ Allergies.list(509) should be(
96
+ List(Allergen.Eggs,
97
+ Allergen.Shellfish,
98
+ Allergen.Strawberries,
99
+ Allergen.Tomatoes,
100
+ Allergen.Chocolate,
101
+ Allergen.Pollen,
102
+ Allergen.Cats))
68
103
  }
69
104
  }
@@ -1,6 +1,7 @@
1
1
  import org.scalatest.concurrent.{IntegrationPatience, Conductors}
2
2
  import org.scalatest.{Matchers, FunSuite}
3
3
 
4
+ /** @version created manually **/
4
5
  class BankAccountTest extends FunSuite with Matchers with Conductors with IntegrationPatience {
5
6
  test("open account") {
6
7
  Bank.openAccount().getBalance should be (Some(0))
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{Matchers, FlatSpec}
2
2
 
3
+ /** @version created manually **/
3
4
  class BstTest extends FlatSpec with Matchers {
4
5
  val bst4 = Bst(4)
5
6
 
@@ -55,7 +55,7 @@ case class Connect(lines: List[String]) {
55
55
  }
56
56
  }
57
57
 
58
- def result: Option[Color] = {
58
+ def winner: Option[Color] = {
59
59
  if (blackStartCoords.exists(tryConnect(Color.Black, seenCoords, _))) Some(Color.Black)
60
60
  else if (whiteStartCoords.exists(tryConnect(Color.White, seenCoords, _))) Some(Color.White)
61
61
  else None
@@ -1,86 +1,102 @@
1
1
  import org.scalatest.{Matchers, FunSuite}
2
2
 
3
+ /** @version 1.0.0 */
3
4
  class ConnectTest extends FunSuite with Matchers {
5
+
4
6
  // Filter readable board into valid input
5
7
  private def mkBoard(lines: List[String]): List[String] =
6
8
  lines.map(l => l.filter(!_.isSpaceChar))
7
9
 
8
- test("empty board") {
9
- val lines = List(". . . . ."
10
- ," . . . . ."
11
- ," . . . . ."
12
- ," . . . . ."
13
- ," . . . . .")
14
- Connect(mkBoard(lines)).result should be (None)
10
+ test("an empty board has no winner") {
11
+ Connect(
12
+ mkBoard(
13
+ List(". . . . .",
14
+ " . . . . .",
15
+ " . . . . .",
16
+ " . . . . .",
17
+ " . . . . ."))).winner should be(None)
18
+ }
19
+
20
+ test("X can win on a 1x1 board") {
21
+ pending
22
+ Connect(mkBoard(List("X"))).winner should be(Some(Color.Black))
23
+ }
24
+
25
+ test("O can win on a 1x1 board") {
26
+ pending
27
+ Connect(mkBoard(List("O"))).winner should be(Some(Color.White))
15
28
  }
16
29
 
17
- test("black single item board") {
30
+ test("only edges does not make a winner") {
18
31
  pending
19
- val lines = List("X")
20
- Connect(mkBoard(lines)).result should be (Some(Color.Black))
32
+ Connect(mkBoard(List("O O O X", " X . . X", " X . . X", " X O O O"))).winner should be(
33
+ None)
21
34
  }
22
35
 
23
- test("white single item board") {
36
+ test("illegal diagonal does not make a winner") {
24
37
  pending
25
- val lines = List("O")
26
- Connect(mkBoard(lines)).result should be (Some(Color.White))
38
+ Connect(
39
+ mkBoard(List("X O . .",
40
+ " O X X X",
41
+ " O X O .",
42
+ " . O X .",
43
+ " X X O O"))).winner should be(None)
27
44
  }
28
45
 
29
- test("convoluted path") {
46
+ test("nobody wins crossing adjacent angles") {
30
47
  pending
31
- val lines = List(". X X . ."
32
- ," X . X . X"
33
- ," . X . X ."
34
- ," . X X . ."
35
- ," O O O O O")
36
- Connect(mkBoard(lines)).result should be (Some(Color.Black))
48
+ Connect(
49
+ mkBoard(List("X . . .",
50
+ " . X O .",
51
+ " O . X O",
52
+ " . O . X",
53
+ " . . O ."))).winner should be(None)
37
54
  }
38
55
 
39
- test("rectangle - black wins") {
56
+ test("X wins crossing from left to right") {
40
57
  pending
41
- val lines = List(". O . ."
42
- ," O X X X"
43
- ," O X O ."
44
- ," X X O X"
45
- ," . O X .")
46
- Connect(mkBoard(lines)).result should be (Some(Color.Black))
58
+ Connect(
59
+ mkBoard(List(". O . .",
60
+ " O X X X",
61
+ " O X O .",
62
+ " X X O X",
63
+ " . O X ."))).winner should be(Some(Color.Black))
47
64
  }
48
65
 
49
- test("rectangle - white wins") {
66
+ test("O wins crossing from top to bottom") {
50
67
  pending
51
- val lines = List(". O . ."
52
- ," O X X X"
53
- ," O O O ."
54
- ," X X O X"
55
- ," . O X .")
56
- Connect(mkBoard(lines)).result should be (Some(Color.White))
68
+ Connect(
69
+ mkBoard(List(". O . .",
70
+ " O X X X",
71
+ " O O O .",
72
+ " X X O X",
73
+ " . O X ."))).winner should be(Some(Color.White))
57
74
  }
58
75
 
59
- test("spiral - black wins") {
76
+ test("X wins using a convoluted path") {
60
77
  pending
61
- val lines = List("OXXXXXXXX"
62
- ,"OXOOOOOOO"
63
- ,"OXOXXXXXO"
64
- ,"OXOXOOOXO"
65
- ,"OXOXXXOXO"
66
- ,"OXOOOXOXO"
67
- ,"OXXXXXOXO"
68
- ,"OOOOOOOXO"
69
- ,"XXXXXXXXO")
70
- Connect(mkBoard(lines)).result should be (Some(Color.Black))
78
+ Connect(
79
+ mkBoard(
80
+ List(". X X . .",
81
+ " X . X . X",
82
+ " . X . X .",
83
+ " . X X . .",
84
+ " O O O O O"))).winner should be(Some(Color.Black))
71
85
  }
72
86
 
73
- test("spiral - none") {
87
+ test("X wins using a spiral path") {
74
88
  pending
75
- val lines = List("OXXXXXXXX"
76
- ,"OXOOOOOOO"
77
- ,"OXOXXXXXO"
78
- ,"OXOXOOOXO"
79
- ,"OXOX.XOXO"
80
- ,"OXOOOXOXO"
81
- ,"OXXXXXOXO"
82
- ,"OOOOOOOXO"
83
- ,"XXXXXXXXO")
84
- Connect(mkBoard(lines)).result should be (None)
89
+ Connect(
90
+ mkBoard(List(
91
+ "O X X X X X X X X",
92
+ " O X O O O O O O O",
93
+ " O X O X X X X X O",
94
+ " O X O X O O O X O",
95
+ " O X O X X X O X O",
96
+ " O X O O O X O X O",
97
+ " O X X X X X O X O",
98
+ " O O O O O O O X O",
99
+ " X X X X X X X X O"
100
+ ))).winner should be(Some(Color.Black))
85
101
  }
86
102
  }
@@ -1,7 +1,36 @@
1
- import org.scalatest.{FunSuite, Matchers}
1
+ import org.scalatest.{Matchers, FunSuite}
2
2
 
3
+ /** @version 2.0.0 */
3
4
  class DominoesTest extends FunSuite with Matchers {
4
5
 
6
+ private def check(input: List[(Int, Int)], hasResult: Boolean): Unit = {
7
+ val result = Dominoes.chain(input)
8
+ if (hasResult) {
9
+ checkChain(result getOrElse fail("should have had a chain, but didn't"), input)
10
+ }
11
+ else assert(result == None)
12
+ }
13
+
14
+ private def checkChain(result: List[(Int, Int)], input: List[(Int, Int)]): Unit = {
15
+ def sortDomino(ab: (Int, Int)): (Int, Int) =
16
+ if (ab._1 > ab._2) ab.swap else ab
17
+ def consecutivesShouldMatch(dominoes: List[((Int, Int), Int)]): Unit =
18
+ dominoes.tails foreach {
19
+ case (a@(_,x), i1)::(b@(y,_), i2)::_ =>
20
+ assert(x == y, s"dominoes $i1 and $i2 don't match: $a $b")
21
+ case _ =>
22
+ }
23
+ def endsShouldMatch: Unit =
24
+ if (!result.isEmpty)
25
+ consecutivesShouldMatch(List((result.last, result.length - 1),
26
+ (result.head, 0)))
27
+
28
+ assert(result.map(sortDomino).sorted == input.map(sortDomino).sorted,
29
+ "doesn't consist of input dominoes")
30
+ consecutivesShouldMatch(result.zipWithIndex)
31
+ endsShouldMatch
32
+ }
33
+
5
34
  test("empty input = empty output") {
6
35
  check(List(), true)
7
36
  }
@@ -56,36 +85,8 @@ class DominoesTest extends FunSuite with Matchers {
56
85
  check(List((1, 2), (2, 3), (3, 1), (1, 1), (2, 2), (3, 3)), true)
57
86
  }
58
87
 
59
- test("ten elements") {
88
+ test("nine elements") {
60
89
  pending
61
90
  check(List((1, 2), (5, 3), (3, 1), (1, 2), (2, 4), (1, 6), (2, 3), (3, 4), (5, 6)), true)
62
91
  }
63
-
64
- private def check(input: List[(Int, Int)], hasResult: Boolean): Unit = {
65
- val result = Dominoes.chain(input)
66
- if (hasResult) {
67
- checkChain(result getOrElse fail("should have had a chain, but didn't"), input)
68
- }
69
- else assert(result == None)
70
- }
71
-
72
- private def checkChain(result: List[(Int, Int)], input: List[(Int, Int)]): Unit = {
73
- def sortDomino(ab: (Int, Int)): (Int, Int) =
74
- if (ab._1 > ab._2) ab.swap else ab
75
- def consecutivesShouldMatch(dominoes: List[((Int, Int), Int)]): Unit =
76
- dominoes.tails foreach {
77
- case (a@(_,x), i1)::(b@(y,_), i2)::_ =>
78
- assert(x == y, s"dominoes $i1 and $i2 don't match: $a $b")
79
- case _ =>
80
- }
81
- def endsShouldMatch: Unit =
82
- if (!result.isEmpty)
83
- consecutivesShouldMatch(List((result.last, result.length - 1),
84
- (result.head, 0)))
85
-
86
- assert(result.map(sortDomino).sorted == input.map(sortDomino).sorted,
87
- "doesn't consist of input dominoes")
88
- consecutivesShouldMatch(result.zipWithIndex)
89
- endsShouldMatch
90
- }
91
- }
92
+ }
@@ -1,5 +1,6 @@
1
1
  import org.scalatest._
2
2
 
3
+ /** @version created manually **/
3
4
  class GradeSchoolTest extends FunSuite with Matchers with OneInstancePerTest {
4
5
  val school = new School
5
6
 
@@ -2,6 +2,7 @@ import org.scalatest.{FunSuite, Matchers}
2
2
  import java.time.LocalDate
3
3
  import LensPerson._
4
4
 
5
+ /** @version created manually **/
5
6
  class LensPersonTest extends FunSuite with Matchers {
6
7
  val testPerson =
7
8
  Person(
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{Matchers, FlatSpec}
2
2
 
3
+ /** @version created manually **/
3
4
  class DequeTest extends FlatSpec with Matchers {
4
5
 
5
6
  it should "handle push then pop" in {
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{Matchers, FlatSpec}
2
2
 
3
+ /** @version created manually **/
3
4
  class MatrixTest extends FlatSpec with Matchers {
4
5
  it should "extract a row" in {
5
6
  Matrix("1 2\n10 20").rows(0) should be (Vector(1, 2))
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{Matchers, FunSuite}
2
2
 
3
+ /** @version created manually **/
3
4
  class FrequencyTest extends FunSuite with Matchers {
4
5
 
5
6
  // Poem by Friedrich Schiller. The corresponding music is the European
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{FunSuite, Matchers}
2
2
 
3
+ /** @version created manually **/
3
4
  class ProteinTranslationTest extends FunSuite with Matchers {
4
5
  test("Identifies methionine codon") {
5
6
  ProteinTranslation.translate("AUG") should be(Seq("Methionine"))
@@ -56,4 +57,4 @@ class ProteinTranslationTest extends FunSuite with Matchers {
56
57
  pending
57
58
  ProteinTranslation.translate("UGGUGUUAUUAAUGGUUU") should be(Seq("Tryptophan", "Cysteine", "Tyrosine"))
58
59
  }
59
- }
60
+ }
@@ -1,5 +1,6 @@
1
1
  import org.scalatest.{FunSuite, Matchers}
2
2
 
3
+ /** @version created manually **/
3
4
  class PythagoreanTripletTest extends FunSuite with Matchers {
4
5
  test("isPythagorean") {
5
6
  PythagoreanTriplet.isPythagorean((3, 4, 5)) should be (true)
@@ -2,6 +2,7 @@ import org.scalatest._
2
2
 
3
3
  import collection.mutable
4
4
 
5
+ /** @version created manually **/
5
6
  class RobotNameSpecs extends FunSpec with Matchers {
6
7
  val nameRegex = """[A-Z]{2}\d{3}"""
7
8