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.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/word-search/canonical-data.json +278 -4
- data/tracks/c/exercises/raindrops/test/test_raindrops.c +0 -16
- data/tracks/ceylon/README.md +1 -1
- data/tracks/ceylon/config.json +12 -0
- data/tracks/ceylon/docs/RESOURCES.md +1 -1
- data/tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon +1 -1
- data/tracks/ceylon/exercises/anagram/source/anagram/module.ceylon +1 -1
- data/tracks/ceylon/exercises/bracket-push/example/module.ceylon +2 -2
- data/tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon +1 -1
- data/tracks/ceylon/exercises/bracket-push/source/bracketpush/module.ceylon +1 -1
- data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +1 -1
- data/tracks/ceylon/exercises/hamming/source/hamming/module.ceylon +1 -1
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/SeriesTest.ceylon +1 -1
- data/tracks/ceylon/exercises/largest-series-product/source/largestseriesproduct/module.ceylon +1 -1
- data/tracks/ceylon/exercises/leap/source/leap/LeapTest.ceylon +1 -1
- data/tracks/ceylon/exercises/leap/source/leap/module.ceylon +1 -1
- data/tracks/ceylon/exercises/react/example/module.ceylon +2 -2
- data/tracks/ceylon/exercises/react/source/react/ReactorTest.ceylon +1 -1
- data/tracks/ceylon/exercises/react/source/react/module.ceylon +1 -1
- data/tracks/ceylon/exercises/rna-transcription/README.md +41 -0
- data/tracks/ceylon/exercises/rna-transcription/example/RNA.ceylon +13 -0
- data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNA.ceylon +5 -0
- data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/RNAtest.ceylon +33 -0
- data/tracks/ceylon/exercises/rna-transcription/source/rnatranscription/module.ceylon +3 -0
- data/tracks/ceylon/exercises/sieve/example/module.ceylon +2 -2
- data/tracks/ceylon/exercises/sieve/source/sieve/SieveTest.ceylon +1 -1
- data/tracks/ceylon/exercises/sieve/source/sieve/module.ceylon +1 -1
- data/tracks/clojure/.travis.yml +1 -1
- data/tracks/clojure/_src/generator.clj +1 -1
- data/tracks/clojure/exercises/clock/{clock.mustache → .meta/clock.mustache} +0 -0
- data/tracks/clojure/exercises/luhn/{luhn.mustache → .meta/luhn.mustache} +0 -0
- data/tracks/clojure/exercises/sublist/{sublist.mustache → .meta/sublist.mustache} +0 -0
- data/tracks/go/exercises/robot-name/.meta/hints.md +13 -0
- data/tracks/go/exercises/robot-name/bonus_example.go +2 -0
- data/tracks/java/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/tracks/java/gradle/wrapper/gradle-wrapper.properties +2 -2
- data/tracks/java/gradlew +3 -3
- data/tracks/java/gradlew.bat +0 -0
- data/tracks/php/config.json +8 -0
- data/tracks/php/exercises/flatten-array/example.php +10 -0
- data/tracks/php/exercises/flatten-array/flatten-array_test.php +51 -0
- data/tracks/ruby/exercises/hello-world/GETTING_STARTED.md +2 -2
- data/tracks/scala/exercises/accumulate/src/test/scala/AccumulateTest.scala +1 -0
- data/tracks/scala/exercises/allergies/example.scala +3 -3
- data/tracks/scala/exercises/allergies/src/test/scala/AllergiesTest.scala +68 -33
- data/tracks/scala/exercises/bank-account/src/test/scala/BankAccountTest.scala +1 -0
- data/tracks/scala/exercises/binary-search-tree/src/test/scala/BstTest.scala +1 -0
- data/tracks/scala/exercises/connect/example.scala +1 -1
- data/tracks/scala/exercises/connect/src/test/scala/ConnectTest.scala +72 -56
- data/tracks/scala/exercises/dominoes/src/main/scala/.keep +0 -0
- data/tracks/scala/exercises/dominoes/src/test/scala/DominoesTest.scala +32 -31
- data/tracks/scala/exercises/grade-school/src/test/scala/GradeSchoolTest.scala +1 -0
- data/tracks/scala/exercises/lens-person/src/test/scala/LensPersonTest.scala +1 -0
- data/tracks/scala/exercises/linked-list/src/test/scala/DequeTest.scala +1 -0
- data/tracks/scala/exercises/matrix/src/test/scala/MatrixTest.scala +1 -0
- data/tracks/scala/exercises/parallel-letter-frequency/src/test/scala/FrequencyTest.scala +1 -0
- data/tracks/scala/exercises/protein-translation/src/test/scala/ProteinTranslationTest.scala +2 -1
- data/tracks/scala/exercises/pythagorean-triplet/src/test/scala/PythagoreanTripletTest.scala +1 -0
- data/tracks/scala/exercises/robot-name/src/test/scala/RobotNameTest.scala +1 -0
- data/tracks/scala/exercises/series/src/test/scala/SeriesTest.scala +1 -0
- data/tracks/scala/exercises/sgf-parsing/src/test/scala/SgfTest.scala +1 -0
- data/tracks/scala/exercises/simple-cipher/src/test/scala/CipherTest.scala +1 -0
- data/tracks/scala/exercises/simple-linked-list/src/test/scala/SimpleLinkedListTest.scala +1 -1
- data/tracks/scala/exercises/strain/src/test/scala/StrainTest.scala +2 -1
- data/tracks/scala/exercises/wordy/example.scala +3 -3
- data/tracks/scala/exercises/wordy/src/test/scala/WordyTest.scala +84 -0
- data/tracks/scala/exercises/zebra-puzzle/src/test/scala/ZebraPuzzleTest.scala +1 -0
- data/tracks/scala/exercises/zipper/src/test/scala/ZipperTest.scala +1 -0
- data/tracks/scala/testgen/src/main/scala/AllergiesTestGenerator.scala +60 -0
- data/tracks/scala/testgen/src/main/scala/ConnectTestGenerator.scala +52 -0
- data/tracks/scala/testgen/src/main/scala/DominoesTestGenerator.scala +71 -0
- data/tracks/scala/testgen/src/main/scala/WordyTestGenerator.scala +35 -0
- data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +20 -0
- data/tracks/scala/testgen/src/main/twirl/funSuiteTemplateIgnoreExpected.scala.txt +16 -0
- metadata +20 -8
- data/tracks/scala/exercises/allergies/src/main/scala/Allergies.scala +0 -11
- data/tracks/scala/exercises/dominoes/src/main/scala/Dominoes.scala +0 -4
- 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.
|
Binary file
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
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
|
}
|
data/tracks/java/gradlew.bat
CHANGED
File without changes
|
data/tracks/php/config.json
CHANGED
@@ -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,
|
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.
|
@@ -3,11 +3,11 @@ import Allergen.Allergen
|
|
3
3
|
object Allergies {
|
4
4
|
private lazy val allergenList = Allergen.values
|
5
5
|
|
6
|
-
def
|
6
|
+
def allergicTo(allergen: Allergen, score: Int): Boolean =
|
7
7
|
(allergen.id & score) != 0
|
8
8
|
|
9
|
-
def
|
10
|
-
allergenList.filter(a =>
|
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,
|
1
|
+
import org.scalatest.{Matchers, FunSuite}
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Allergies.
|
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
|
-
|
30
|
+
test("Allergen.Shellfish - allergic to eggs in addition to other stuff") {
|
11
31
|
pending
|
12
|
-
Allergies.
|
32
|
+
Allergies.allergicTo(Allergen.Shellfish, 5) should be(true)
|
13
33
|
}
|
14
34
|
|
15
|
-
|
35
|
+
test("Allergen.Strawberries - allergic to eggs in addition to other stuff") {
|
16
36
|
pending
|
17
|
-
Allergies.
|
37
|
+
Allergies.allergicTo(Allergen.Strawberries, 5) should be(false)
|
18
38
|
}
|
19
39
|
|
20
|
-
|
40
|
+
test("no allergies at all") {
|
21
41
|
pending
|
22
|
-
Allergies.
|
42
|
+
Allergies.list(0) should be(List())
|
23
43
|
}
|
24
44
|
|
25
|
-
|
45
|
+
test("allergic to just eggs") {
|
26
46
|
pending
|
27
|
-
Allergies.
|
47
|
+
Allergies.list(1) should be(List(Allergen.Eggs))
|
28
48
|
}
|
29
49
|
|
30
|
-
|
50
|
+
test("allergic to just peanuts") {
|
31
51
|
pending
|
32
|
-
Allergies.
|
52
|
+
Allergies.list(2) should be(List(Allergen.Peanuts))
|
33
53
|
}
|
34
54
|
|
35
|
-
|
55
|
+
test("allergic to just strawberries") {
|
36
56
|
pending
|
37
|
-
Allergies.
|
57
|
+
Allergies.list(8) should be(List(Allergen.Strawberries))
|
38
58
|
}
|
39
59
|
|
40
|
-
|
60
|
+
test("allergic to eggs and peanuts") {
|
41
61
|
pending
|
42
|
-
Allergies.
|
62
|
+
Allergies.list(3) should be(List(Allergen.Eggs, Allergen.Peanuts))
|
43
63
|
}
|
44
64
|
|
45
|
-
|
65
|
+
test("allergic to more than eggs but not peanuts") {
|
46
66
|
pending
|
47
|
-
Allergies.
|
67
|
+
Allergies.list(5) should be(List(Allergen.Eggs, Allergen.Shellfish))
|
48
68
|
}
|
49
69
|
|
50
|
-
|
70
|
+
test("allergic to lots of stuff") {
|
51
71
|
pending
|
52
|
-
Allergies.
|
53
|
-
Allergen.
|
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
|
-
|
80
|
+
test("allergic to everything") {
|
57
81
|
pending
|
58
|
-
Allergies.
|
59
|
-
Allergen.
|
60
|
-
|
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
|
-
|
93
|
+
test("ignore non allergen score parts") {
|
64
94
|
pending
|
65
|
-
Allergies.
|
66
|
-
Allergen.
|
67
|
-
|
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))
|
@@ -55,7 +55,7 @@ case class Connect(lines: List[String]) {
|
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
|
-
def
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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("
|
30
|
+
test("only edges does not make a winner") {
|
18
31
|
pending
|
19
|
-
|
20
|
-
|
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("
|
36
|
+
test("illegal diagonal does not make a winner") {
|
24
37
|
pending
|
25
|
-
|
26
|
-
|
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("
|
46
|
+
test("nobody wins crossing adjacent angles") {
|
30
47
|
pending
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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("
|
56
|
+
test("X wins crossing from left to right") {
|
40
57
|
pending
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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("
|
66
|
+
test("O wins crossing from top to bottom") {
|
50
67
|
pending
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
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("
|
76
|
+
test("X wins using a convoluted path") {
|
60
77
|
pending
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
87
|
+
test("X wins using a spiral path") {
|
74
88
|
pending
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
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
|
}
|
File without changes
|
@@ -1,7 +1,36 @@
|
|
1
|
-
import org.scalatest.{
|
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("
|
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.{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
|
+
}
|