trackler 2.0.6.41 → 2.0.6.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/common/CONTRIBUTING.md +15 -3
- data/common/README.md +7 -2
- data/common/exercises/binary/.deprecated +3 -0
- data/common/exercises/counter/.deprecated +2 -0
- data/common/exercises/hexadecimal/.deprecated +3 -0
- data/common/exercises/luhn/description.md +9 -31
- data/common/exercises/octal/.deprecated +3 -0
- data/common/exercises/point-mutations/.deprecated +2 -0
- data/common/exercises/trinary/.deprecated +3 -0
- data/lib/trackler/version.rb +1 -1
- data/tracks/c/exercises/rna-transcription/test/test_rna_transcription.c +2 -3
- data/tracks/ceylon/config.json +8 -0
- data/tracks/ceylon/docs/ABOUT.md +15 -0
- data/tracks/ceylon/docs/INSTALLATION.md +9 -0
- data/tracks/ceylon/docs/LEARNING.md +7 -0
- data/tracks/ceylon/docs/TESTS.md +11 -0
- data/tracks/ceylon/exercises/TRACK_HINTS.md +11 -0
- data/tracks/ceylon/exercises/hamming/example/Hamming.ceylon +8 -0
- data/tracks/ceylon/exercises/hamming/source/hamming/Hamming.ceylon +5 -0
- data/tracks/ceylon/exercises/hamming/source/hamming/HammingTest.ceylon +30 -0
- data/tracks/ceylon/exercises/hamming/source/hamming/module.ceylon +3 -0
- data/tracks/erlang/_test/check-exercises.escript +2 -2
- data/tracks/erlang/exercises/{circular-buffer/rebar.conf → accumulate/rebar.config} +1 -1
- data/tracks/erlang/exercises/allergies/{rebar.conf → rebar.config} +1 -1
- data/tracks/erlang/exercises/{accumulate/rebar.conf → anagram/rebar.config} +3 -1
- data/tracks/erlang/exercises/{bob/rebar.conf → atbash-cipher/rebar.config} +1 -1
- data/tracks/erlang/exercises/{binary/rebar.conf → bank-account/rebar.config} +1 -1
- data/tracks/erlang/exercises/beer-song/rebar.conf +1 -1
- data/tracks/erlang/exercises/binary/rebar.config +30 -0
- data/tracks/erlang/exercises/bob/rebar.config +30 -0
- data/tracks/erlang/exercises/circular-buffer/rebar.config +30 -0
- data/tracks/erlang/exercises/clock/rebar.config +30 -0
- data/tracks/erlang/exercises/difference-of-squares/rebar.config +30 -0
- data/tracks/erlang/exercises/etl/rebar.config +30 -0
- data/tracks/erlang/exercises/gigasecond/rebar.config +30 -0
- data/tracks/erlang/exercises/grade-school/rebar.config +30 -0
- data/tracks/erlang/exercises/grains/rebar.config +30 -0
- data/tracks/erlang/exercises/hamming/rebar.config +30 -0
- data/tracks/erlang/exercises/hello-world/rebar.config +30 -0
- data/tracks/erlang/exercises/largest-series-product/rebar.config +30 -0
- data/tracks/erlang/exercises/leap/rebar.config +30 -0
- data/tracks/erlang/exercises/luhn/rebar.config +30 -0
- data/tracks/erlang/exercises/meetup/rebar.config +30 -0
- data/tracks/erlang/exercises/nucleotide-count/rebar.config +30 -0
- data/tracks/erlang/exercises/parallel-letter-frequency/rebar.config +30 -0
- data/tracks/erlang/exercises/phone-number/rebar.config +30 -0
- data/tracks/erlang/exercises/rna-transcription/rebar.config +30 -0
- data/tracks/erlang/exercises/robot-simulator/HINTS.md +9 -0
- data/tracks/erlang/exercises/robot-simulator/rebar.config +30 -0
- data/tracks/erlang/exercises/roman-numerals/rebar.config +30 -0
- data/tracks/erlang/exercises/scrabble-score/rebar.config +30 -0
- data/tracks/erlang/exercises/series/rebar.config +30 -0
- data/tracks/erlang/exercises/space-age/rebar.config +30 -0
- data/tracks/erlang/exercises/strain/rebar.config +30 -0
- data/tracks/erlang/exercises/sum-of-multiples/rebar.config +30 -0
- data/tracks/erlang/exercises/triangle/rebar.config +30 -0
- data/tracks/erlang/exercises/trinary/rebar.config +30 -0
- data/tracks/erlang/exercises/word-count/rebar.config +30 -0
- data/tracks/erlang/exercises/zipper/rebar.config +30 -0
- data/tracks/go/README.md +2 -1
- data/tracks/go/exercises/diamond/diamond_test.go +8 -8
- data/tracks/go/exercises/difference-of-squares/difference_of_squares_test.go +8 -0
- data/tracks/go/exercises/difference-of-squares/example.go +2 -0
- data/tracks/go/exercises/diffie-hellman/diffie_hellman_test.go +8 -0
- data/tracks/go/exercises/diffie-hellman/example.go +2 -0
- data/tracks/go/exercises/error-handling/error_handling_test.go +8 -8
- data/tracks/go/exercises/etl/etl_test.go +8 -0
- data/tracks/go/exercises/etl/example.go +2 -0
- data/tracks/go/exercises/food-chain/food_chain_test.go +6 -6
- data/tracks/go/exercises/hello-world/hello_world.go +2 -2
- data/tracks/go/exercises/hexadecimal/hexadecimal_test.go +6 -6
- data/tracks/go/exercises/house/house_test.go +6 -6
- data/tracks/go/exercises/isogram/isogram_test.go +8 -8
- data/tracks/go/exercises/kindergarten-garden/kindergarten_garden_test.go +6 -6
- data/tracks/go/exercises/leap/leap_test.go +4 -1
- data/tracks/go/exercises/ledger/ledger_test.go +4 -1
- data/tracks/go/exercises/matrix/matrix_test.go +6 -6
- data/tracks/go/exercises/meetup/meetup_test.go +4 -1
- data/tracks/go/exercises/nth-prime/example.go +2 -0
- data/tracks/go/exercises/nth-prime/nth_prime_test.go +8 -0
- data/tracks/go/exercises/nucleotide-count/nucleotide_count_test.go +8 -8
- data/tracks/idris/.gitignore +2 -0
- data/tracks/idris/_src/Makefile.template +23 -0
- data/tracks/idris/config.json +9 -2
- data/tracks/idris/exercises/hello-world/HelloWorld.ipkg +5 -0
- data/tracks/idris/exercises/hello-world/Makefile +23 -0
- data/tracks/idris/exercises/hello-world/src/Test/HelloWorld.idr +25 -0
- data/tracks/idris/exercises/hello-world/src/example.idr +5 -0
- data/tracks/java/.travis.yml +5 -0
- data/tracks/java/bin/build-jq.sh +11 -0
- data/tracks/java/exercises/allergies/src/test/java/AllergiesTest.java +14 -13
- data/tracks/java/exercises/hamming/src/test/java/HammingTest.java +2 -2
- data/tracks/java/exercises/nth-prime/src/test/java/PrimeTest.java +8 -1
- data/tracks/java/exercises/nucleotide-count/src/test/java/NucleotideTest.java +12 -6
- data/tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java +8 -2
- data/tracks/java/exercises/series/src/test/java/SeriesTest.java +10 -4
- data/tracks/java/exercises/simple-linked-list/src/test/java/SimpleLinkedListTest.java +7 -2
- data/tracks/java/exercises/triangle/src/test/java/TriangleTest.java +29 -20
- data/tracks/kotlin/config.json +5 -0
- data/tracks/kotlin/exercises/build.gradle +17 -0
- data/tracks/kotlin/exercises/perfect-numbers/build.gradle +28 -0
- data/tracks/kotlin/exercises/perfect-numbers/src/example/kotlin/NaturalNumber.kt +17 -0
- data/tracks/kotlin/exercises/perfect-numbers/src/main/kotlin/NaturalNumber.kt +8 -0
- data/tracks/kotlin/exercises/perfect-numbers/src/test/kotlin/PerfectNumbersTest.kt +67 -0
- data/tracks/kotlin/exercises/settings.gradle +1 -0
- data/tracks/lua/exercises/hamming/example.lua +1 -0
- data/tracks/lua/exercises/hamming/hamming_spec.lua +19 -11
- data/tracks/ocaml/config.json +5 -0
- data/tracks/ocaml/exercises/beer-song/beer_song.mli +1 -1
- data/tracks/ocaml/exercises/beer-song/example.ml +3 -3
- data/tracks/ocaml/exercises/beer-song/test.ml +45 -22
- data/tracks/ocaml/exercises/run-length-encoding/.merlin +5 -0
- data/tracks/ocaml/exercises/run-length-encoding/Makefile +11 -0
- data/tracks/ocaml/exercises/run-length-encoding/example.ml +37 -0
- data/tracks/ocaml/exercises/run-length-encoding/run_length_encoding.mli +3 -0
- data/tracks/ocaml/exercises/run-length-encoding/test.ml +38 -0
- data/tracks/ocaml/tools/test-generator/src/template.ml +0 -2
- data/tracks/ocaml/tools/test-generator/templates/beer-song/template.ml +19 -0
- data/tracks/ocaml/tools/test-generator/templates/run-length-encoding/template.ml +19 -0
- data/tracks/php/config.json +17 -0
- data/tracks/php/exercises/queen-attack/example.php +86 -0
- data/tracks/php/exercises/queen-attack/queen-attack_test.php +125 -0
- data/tracks/php/exercises/scrabble-score/example.php +27 -0
- data/tracks/php/exercises/scrabble-score/scrabble-score_test.php +120 -0
- data/tracks/r/exercises/luhn/example.R +20 -32
- data/tracks/r/exercises/luhn/luhn.R +1 -22
- data/tracks/r/exercises/luhn/test_luhn.R +43 -55
- metadata +67 -37
- data/tracks/erlang/exercises/anagram/rebar.conf +0 -32
- data/tracks/erlang/exercises/atbash-cipher/rebar.conf +0 -30
- data/tracks/erlang/exercises/bank-account/rebar.conf +0 -30
- data/tracks/erlang/exercises/clock/rebar.conf +0 -30
- data/tracks/erlang/exercises/difference-of-squares/rebar.conf +0 -30
- data/tracks/erlang/exercises/etl/rebar.conf +0 -30
- data/tracks/erlang/exercises/gigasecond/rebar.conf +0 -30
- data/tracks/erlang/exercises/grade-school/rebar.conf +0 -30
- data/tracks/erlang/exercises/grains/rebar.conf +0 -30
- data/tracks/erlang/exercises/hamming/rebar.conf +0 -30
- data/tracks/erlang/exercises/hello-world/rebar.conf +0 -30
- data/tracks/erlang/exercises/largest-series-product/rebar.conf +0 -30
- data/tracks/erlang/exercises/leap/rebar.conf +0 -30
- data/tracks/erlang/exercises/luhn/rebar.conf +0 -30
- data/tracks/erlang/exercises/meetup/rebar.conf +0 -30
- data/tracks/erlang/exercises/nucleotide-count/rebar.conf +0 -30
- data/tracks/erlang/exercises/parallel-letter-frequency/rebar.conf +0 -30
- data/tracks/erlang/exercises/phone-number/rebar.conf +0 -30
- data/tracks/erlang/exercises/rna-transcription/rebar.conf +0 -30
- data/tracks/erlang/exercises/robot-simulator/rebar.conf +0 -30
- data/tracks/erlang/exercises/roman-numerals/rebar.conf +0 -30
- data/tracks/erlang/exercises/scrabble-score/rebar.conf +0 -30
- data/tracks/erlang/exercises/series/rebar.conf +0 -30
- data/tracks/erlang/exercises/space-age/rebar.conf +0 -30
- data/tracks/erlang/exercises/strain/rebar.conf +0 -30
- data/tracks/erlang/exercises/sum-of-multiples/rebar.conf +0 -30
- data/tracks/erlang/exercises/triangle/rebar.conf +0 -30
- data/tracks/erlang/exercises/trinary/rebar.conf +0 -30
- data/tracks/erlang/exercises/word-count/rebar.conf +0 -30
- data/tracks/erlang/exercises/zipper/rebar.conf +0 -30
@@ -3,6 +3,7 @@ import org.junit.Ignore;
|
|
3
3
|
|
4
4
|
import java.util.Arrays;
|
5
5
|
import java.util.List;
|
6
|
+
import java.util.Collections;
|
6
7
|
|
7
8
|
import static org.junit.Assert.assertEquals;
|
8
9
|
|
@@ -103,7 +104,7 @@ public class AllergiesTest {
|
|
103
104
|
@Test
|
104
105
|
public void isAllergicToJustEggs() {
|
105
106
|
Allergies allergies = new Allergies(1);
|
106
|
-
List<Allergen> expectedAllergens =
|
107
|
+
List<Allergen> expectedAllergens = Collections.singletonList(Allergen.EGGS);
|
107
108
|
|
108
109
|
assertEquals(expectedAllergens, allergies.getList());
|
109
110
|
}
|
@@ -112,7 +113,7 @@ public class AllergiesTest {
|
|
112
113
|
@Test
|
113
114
|
public void isAllergicToJustPeanuts() {
|
114
115
|
Allergies allergies = new Allergies(2);
|
115
|
-
List<Allergen> expectedAllergens =
|
116
|
+
List<Allergen> expectedAllergens = Collections.singletonList(Allergen.PEANUTS);
|
116
117
|
|
117
118
|
assertEquals(expectedAllergens, allergies.getList());
|
118
119
|
}
|
@@ -121,7 +122,7 @@ public class AllergiesTest {
|
|
121
122
|
@Test
|
122
123
|
public void isAllergicToJustStrawberries() {
|
123
124
|
Allergies allergies = new Allergies(8);
|
124
|
-
List<Allergen> expectedAllergens =
|
125
|
+
List<Allergen> expectedAllergens = Collections.singletonList(Allergen.STRAWBERRIES);
|
125
126
|
|
126
127
|
assertEquals(expectedAllergens, allergies.getList());
|
127
128
|
}
|
@@ -130,10 +131,10 @@ public class AllergiesTest {
|
|
130
131
|
@Test
|
131
132
|
public void isAllergicToEggsAndPeanuts() {
|
132
133
|
Allergies allergies = new Allergies(3);
|
133
|
-
List<Allergen> expectedAllergens = Arrays.asList(
|
134
|
+
List<Allergen> expectedAllergens = Arrays.asList(
|
134
135
|
Allergen.EGGS,
|
135
136
|
Allergen.PEANUTS
|
136
|
-
|
137
|
+
);
|
137
138
|
|
138
139
|
assertEquals(expectedAllergens, allergies.getList());
|
139
140
|
}
|
@@ -142,10 +143,10 @@ public class AllergiesTest {
|
|
142
143
|
@Test
|
143
144
|
public void isAllergicToEggsAndShellfish() {
|
144
145
|
Allergies allergies = new Allergies(5);
|
145
|
-
List<Allergen> expectedAllergens = Arrays.asList(
|
146
|
+
List<Allergen> expectedAllergens = Arrays.asList(
|
146
147
|
Allergen.EGGS,
|
147
148
|
Allergen.SHELLFISH
|
148
|
-
|
149
|
+
);
|
149
150
|
|
150
151
|
assertEquals(expectedAllergens, allergies.getList());
|
151
152
|
}
|
@@ -154,13 +155,13 @@ public class AllergiesTest {
|
|
154
155
|
@Test
|
155
156
|
public void isAllergicToLotsOfStuff() {
|
156
157
|
Allergies allergies = new Allergies(248);
|
157
|
-
List<Allergen> expectedAllergens = Arrays.asList(
|
158
|
+
List<Allergen> expectedAllergens = Arrays.asList(
|
158
159
|
Allergen.STRAWBERRIES,
|
159
160
|
Allergen.TOMATOES,
|
160
161
|
Allergen.CHOCOLATE,
|
161
162
|
Allergen.POLLEN,
|
162
163
|
Allergen.CATS
|
163
|
-
|
164
|
+
);
|
164
165
|
|
165
166
|
assertEquals(expectedAllergens, allergies.getList());
|
166
167
|
}
|
@@ -169,7 +170,7 @@ public class AllergiesTest {
|
|
169
170
|
@Test
|
170
171
|
public void isAllergicToEverything() {
|
171
172
|
Allergies allergies = new Allergies(255);
|
172
|
-
List<Allergen> expectedAllergens = Arrays.asList(
|
173
|
+
List<Allergen> expectedAllergens = Arrays.asList(
|
173
174
|
Allergen.EGGS,
|
174
175
|
Allergen.PEANUTS,
|
175
176
|
Allergen.SHELLFISH,
|
@@ -178,7 +179,7 @@ public class AllergiesTest {
|
|
178
179
|
Allergen.CHOCOLATE,
|
179
180
|
Allergen.POLLEN,
|
180
181
|
Allergen.CATS
|
181
|
-
|
182
|
+
);
|
182
183
|
|
183
184
|
assertEquals(expectedAllergens, allergies.getList());
|
184
185
|
}
|
@@ -187,7 +188,7 @@ public class AllergiesTest {
|
|
187
188
|
@Test
|
188
189
|
public void ignoreNonAllergenScoreParts() {
|
189
190
|
Allergies allergies = new Allergies(509);
|
190
|
-
List<Allergen> expectedAllergens = Arrays.asList(
|
191
|
+
List<Allergen> expectedAllergens = Arrays.asList(
|
191
192
|
Allergen.EGGS,
|
192
193
|
Allergen.SHELLFISH,
|
193
194
|
Allergen.STRAWBERRIES,
|
@@ -195,7 +196,7 @@ public class AllergiesTest {
|
|
195
196
|
Allergen.CHOCOLATE,
|
196
197
|
Allergen.POLLEN,
|
197
198
|
Allergen.CATS
|
198
|
-
|
199
|
+
);
|
199
200
|
|
200
201
|
assertEquals(expectedAllergens, allergies.getList());
|
201
202
|
}
|
@@ -19,13 +19,13 @@ public class HammingTest {
|
|
19
19
|
|
20
20
|
@Ignore
|
21
21
|
@Test
|
22
|
-
public void
|
22
|
+
public void testHammingDistanceForSingleNucleotideStrand() {
|
23
23
|
assertThat(Hamming.compute("A", "G"), is(1));
|
24
24
|
}
|
25
25
|
|
26
26
|
@Ignore
|
27
27
|
@Test
|
28
|
-
public void
|
28
|
+
public void testHammingDistanceForSmallStrand() {
|
29
29
|
assertThat(Hamming.compute("AG", "CT"), is(2));
|
30
30
|
}
|
31
31
|
|
@@ -1,11 +1,16 @@
|
|
1
1
|
import org.junit.Test;
|
2
2
|
import org.junit.Ignore;
|
3
|
+
import org.junit.Rule;
|
4
|
+
import org.junit.rules.ExpectedException;
|
3
5
|
|
4
6
|
import static org.hamcrest.CoreMatchers.*;
|
5
7
|
import static org.junit.Assert.*;
|
6
8
|
|
7
9
|
public class PrimeTest {
|
8
10
|
|
11
|
+
@Rule
|
12
|
+
public ExpectedException thrown = ExpectedException.none();
|
13
|
+
|
9
14
|
@Test
|
10
15
|
public void testFirstPrime() {
|
11
16
|
assertThat(Prime.nth(1), is(2));
|
@@ -30,8 +35,10 @@ public class PrimeTest {
|
|
30
35
|
}
|
31
36
|
|
32
37
|
@Ignore
|
33
|
-
@Test
|
38
|
+
@Test
|
34
39
|
public void testUndefinedPrime() {
|
40
|
+
thrown.expect(IllegalArgumentException.class);
|
35
41
|
Prime.nth(0);
|
36
42
|
}
|
43
|
+
|
37
44
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import org.junit.Ignore;
|
2
2
|
import org.junit.Test;
|
3
|
+
import org.junit.Rule;
|
4
|
+
import org.junit.rules.ExpectedException;
|
3
5
|
|
4
6
|
import java.util.Map;
|
5
7
|
|
@@ -8,8 +10,11 @@ import static org.junit.Assert.*;
|
|
8
10
|
|
9
11
|
public class NucleotideTest {
|
10
12
|
|
13
|
+
@Rule
|
14
|
+
public ExpectedException thrown = ExpectedException.none();
|
15
|
+
|
11
16
|
@Test
|
12
|
-
public void
|
17
|
+
public void testEmptyDnaStringHasNoAdenine() {
|
13
18
|
DNA dna = new DNA("");
|
14
19
|
assertThat(dna.count('A'), is(0));
|
15
20
|
}
|
@@ -30,14 +35,14 @@ public class NucleotideTest {
|
|
30
35
|
|
31
36
|
@Ignore
|
32
37
|
@Test
|
33
|
-
public void
|
38
|
+
public void testRepetitiveCytosineGetsCounted() {
|
34
39
|
DNA dna = new DNA("CCCCC");
|
35
40
|
assertThat(dna.count('C'), is(5));
|
36
41
|
}
|
37
42
|
|
38
43
|
@Ignore
|
39
44
|
@Test
|
40
|
-
public void
|
45
|
+
public void testRepetitiveSequenceWithOnlyGuanine() {
|
41
46
|
DNA dna = new DNA("GGGGGGGG");
|
42
47
|
Map<Character, Integer> counts = dna.nucleotideCounts();
|
43
48
|
assertThat(counts.size(), is(4));
|
@@ -51,7 +56,7 @@ public class NucleotideTest {
|
|
51
56
|
|
52
57
|
@Ignore
|
53
58
|
@Test
|
54
|
-
public void
|
59
|
+
public void testCountsOnlyThymine() {
|
55
60
|
DNA dna = new DNA("GGGGGTAACCCGG");
|
56
61
|
assertThat(dna.count('T'), is(1));
|
57
62
|
}
|
@@ -66,7 +71,7 @@ public class NucleotideTest {
|
|
66
71
|
|
67
72
|
@Ignore
|
68
73
|
@Test
|
69
|
-
public void
|
74
|
+
public void testDnaCountsDoNotChangeAfterCountingAdenine() {
|
70
75
|
DNA dna = new DNA("GATTACA");
|
71
76
|
dna.count('A');
|
72
77
|
Map<Character, Integer> counts = dna.nucleotideCounts();
|
@@ -80,8 +85,9 @@ public class NucleotideTest {
|
|
80
85
|
}
|
81
86
|
|
82
87
|
@Ignore
|
83
|
-
@Test
|
88
|
+
@Test
|
84
89
|
public void testValidatesNucleotides() {
|
90
|
+
thrown.expect(IllegalArgumentException.class);
|
85
91
|
DNA dna = new DNA("GACT");
|
86
92
|
dna.count('X');
|
87
93
|
}
|
@@ -1,12 +1,17 @@
|
|
1
1
|
import org.junit.Test;
|
2
2
|
import org.junit.Ignore;
|
3
|
+
import org.junit.Rule;
|
4
|
+
import org.junit.rules.ExpectedException;
|
5
|
+
|
3
6
|
|
4
7
|
import static org.junit.Assert.assertArrayEquals;
|
5
8
|
import static org.junit.Assert.assertEquals;
|
6
9
|
|
7
10
|
public class PascalsTriangleTest {
|
8
11
|
|
9
|
-
|
12
|
+
@Rule
|
13
|
+
public ExpectedException thrown = ExpectedException.none();
|
14
|
+
|
10
15
|
@Test
|
11
16
|
public void testTriangleWithFourRows() {
|
12
17
|
int[][] expectedOutput = new int[][]{
|
@@ -72,8 +77,9 @@ public class PascalsTriangleTest {
|
|
72
77
|
}
|
73
78
|
|
74
79
|
@Ignore
|
75
|
-
@Test
|
80
|
+
@Test
|
76
81
|
public void testValidatesNotNegativeRows() {
|
82
|
+
thrown.expect(IllegalArgumentException.class);
|
77
83
|
PascalsTriangle.computeTriangle(-1);
|
78
84
|
}
|
79
85
|
}
|
@@ -1,15 +1,20 @@
|
|
1
|
-
|
2
1
|
import java.util.Arrays;
|
3
2
|
import java.util.List;
|
3
|
+
|
4
4
|
import org.junit.Test;
|
5
|
+
import org.junit.Ignore;
|
6
|
+
import org.junit.Rule;
|
7
|
+
import org.junit.rules.ExpectedException;
|
5
8
|
|
6
9
|
import static org.junit.Assert.assertEquals;
|
7
10
|
import static org.junit.Assert.assertFalse;
|
8
11
|
import static org.junit.Assert.assertNotNull;
|
9
|
-
import org.junit.Ignore;
|
10
12
|
|
11
13
|
public class SeriesTest {
|
12
|
-
|
14
|
+
|
15
|
+
@Rule
|
16
|
+
public ExpectedException thrown = ExpectedException.none();
|
17
|
+
|
13
18
|
@Test
|
14
19
|
public void hasDigitsShort() {
|
15
20
|
Series sut = new Series("01234");
|
@@ -146,9 +151,10 @@ public class SeriesTest {
|
|
146
151
|
assertEquals(expected, actual);
|
147
152
|
}
|
148
153
|
|
149
|
-
@Test
|
154
|
+
@Test
|
150
155
|
@Ignore
|
151
156
|
public void throwsAnErrorIfNotEnoughDigitsToSlice() {
|
157
|
+
thrown.expect(IllegalArgumentException.class);
|
152
158
|
new Series("01032987583").slices(12);
|
153
159
|
}
|
154
160
|
}
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import org.junit.Ignore;
|
2
2
|
import org.junit.Test;
|
3
|
+
import org.junit.Rule;
|
4
|
+
import org.junit.rules.ExpectedException;
|
3
5
|
|
4
6
|
import java.util.NoSuchElementException;
|
5
7
|
|
@@ -8,7 +10,9 @@ import static org.junit.Assert.*;
|
|
8
10
|
|
9
11
|
public class SimpleLinkedListTest {
|
10
12
|
|
11
|
-
|
13
|
+
@Rule
|
14
|
+
public ExpectedException thrown = ExpectedException.none();
|
15
|
+
|
12
16
|
@Test
|
13
17
|
public void aNewListIsEmpty() {
|
14
18
|
SimpleLinkedList list = new SimpleLinkedList();
|
@@ -24,8 +28,9 @@ public class SimpleLinkedListTest {
|
|
24
28
|
}
|
25
29
|
|
26
30
|
@Ignore
|
27
|
-
@Test
|
31
|
+
@Test
|
28
32
|
public void popOnEmptyListWillThrow() {
|
33
|
+
thrown.expect(NoSuchElementException.class);
|
29
34
|
SimpleLinkedList list = new SimpleLinkedList();
|
30
35
|
list.pop();
|
31
36
|
}
|
@@ -1,13 +1,17 @@
|
|
1
1
|
import org.junit.Test;
|
2
2
|
import org.junit.Ignore;
|
3
|
+
import org.junit.Rule;
|
4
|
+
import org.junit.rules.ExpectedException;
|
3
5
|
|
4
6
|
import static org.junit.Assert.assertEquals;
|
5
7
|
|
6
8
|
public class TriangleTest {
|
7
9
|
|
10
|
+
@Rule
|
11
|
+
public final ExpectedException thrown = ExpectedException.none();
|
8
12
|
|
9
13
|
@Test
|
10
|
-
public void equilateralTriangleHaveEqualSides() throws
|
14
|
+
public void equilateralTriangleHaveEqualSides() throws TriangleException {
|
11
15
|
Triangle triangle = new Triangle(2, 2, 2);
|
12
16
|
|
13
17
|
assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
|
@@ -15,7 +19,7 @@ public class TriangleTest {
|
|
15
19
|
|
16
20
|
@Ignore
|
17
21
|
@Test
|
18
|
-
public void largerEquilateralTrianglesAlsoHaveEqualSides() throws
|
22
|
+
public void largerEquilateralTrianglesAlsoHaveEqualSides() throws TriangleException {
|
19
23
|
Triangle triangle = new Triangle(10, 10, 10);
|
20
24
|
|
21
25
|
assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
|
@@ -23,7 +27,7 @@ public class TriangleTest {
|
|
23
27
|
|
24
28
|
@Ignore
|
25
29
|
@Test
|
26
|
-
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws
|
30
|
+
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException {
|
27
31
|
Triangle triangle = new Triangle(3, 4, 4);
|
28
32
|
|
29
33
|
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
|
@@ -31,7 +35,7 @@ public class TriangleTest {
|
|
31
35
|
|
32
36
|
@Ignore
|
33
37
|
@Test
|
34
|
-
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws
|
38
|
+
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleException {
|
35
39
|
Triangle triangle = new Triangle(4, 3, 4);
|
36
40
|
|
37
41
|
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
|
@@ -39,7 +43,7 @@ public class TriangleTest {
|
|
39
43
|
|
40
44
|
@Ignore
|
41
45
|
@Test
|
42
|
-
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws
|
46
|
+
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException {
|
43
47
|
Triangle triangle = new Triangle(4, 4, 3);
|
44
48
|
|
45
49
|
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
|
@@ -47,7 +51,7 @@ public class TriangleTest {
|
|
47
51
|
|
48
52
|
@Ignore
|
49
53
|
@Test
|
50
|
-
public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws
|
54
|
+
public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws TriangleException {
|
51
55
|
Triangle triangle = new Triangle(10, 10, 2);
|
52
56
|
|
53
57
|
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
|
@@ -55,7 +59,7 @@ public class TriangleTest {
|
|
55
59
|
|
56
60
|
@Ignore
|
57
61
|
@Test
|
58
|
-
public void scaleneTrianglesHaveNoEqualSides() throws
|
62
|
+
public void scaleneTrianglesHaveNoEqualSides() throws TriangleException {
|
59
63
|
Triangle triangle = new Triangle(3, 4, 5);
|
60
64
|
|
61
65
|
assertEquals(TriangleKind.SCALENE, triangle.getKind());
|
@@ -63,7 +67,7 @@ public class TriangleTest {
|
|
63
67
|
|
64
68
|
@Ignore
|
65
69
|
@Test
|
66
|
-
public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws
|
70
|
+
public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws TriangleException {
|
67
71
|
Triangle triangle = new Triangle(10, 11, 12);
|
68
72
|
|
69
73
|
assertEquals(TriangleKind.SCALENE, triangle.getKind());
|
@@ -71,7 +75,7 @@ public class TriangleTest {
|
|
71
75
|
|
72
76
|
@Ignore
|
73
77
|
@Test
|
74
|
-
public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws
|
78
|
+
public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws TriangleException {
|
75
79
|
Triangle triangle = new Triangle(5, 4, 2);
|
76
80
|
|
77
81
|
assertEquals(TriangleKind.SCALENE, triangle.getKind());
|
@@ -79,39 +83,44 @@ public class TriangleTest {
|
|
79
83
|
|
80
84
|
@Ignore
|
81
85
|
@Test
|
82
|
-
public void verySmallTrianglesAreLegal() throws
|
86
|
+
public void verySmallTrianglesAreLegal() throws TriangleException {
|
83
87
|
Triangle triangle = new Triangle(0.4, 0.6, 0.3);
|
84
88
|
|
85
89
|
assertEquals(TriangleKind.SCALENE, triangle.getKind());
|
86
90
|
}
|
87
91
|
|
88
92
|
@Ignore
|
89
|
-
@Test
|
90
|
-
public void trianglesWithNoSizeAreIllegal() throws
|
93
|
+
@Test
|
94
|
+
public void trianglesWithNoSizeAreIllegal() throws TriangleException {
|
95
|
+
thrown.expect(TriangleException.class);
|
91
96
|
new Triangle(0, 0, 0);
|
92
97
|
}
|
93
98
|
|
94
99
|
@Ignore
|
95
|
-
@Test
|
96
|
-
public void trianglesWithNegativeSidesAreIllegal() throws
|
100
|
+
@Test
|
101
|
+
public void trianglesWithNegativeSidesAreIllegal() throws TriangleException {
|
102
|
+
thrown.expect(TriangleException.class);
|
97
103
|
new Triangle(3, 4, -5);
|
98
104
|
}
|
99
105
|
|
100
106
|
@Ignore
|
101
|
-
@Test
|
102
|
-
public void trianglesViolatingTriangleInequalityAreIllegal() throws
|
107
|
+
@Test
|
108
|
+
public void trianglesViolatingTriangleInequalityAreIllegal() throws TriangleException {
|
109
|
+
thrown.expect(TriangleException.class);
|
103
110
|
new Triangle(1, 1, 3);
|
104
111
|
}
|
105
112
|
|
106
113
|
@Ignore
|
107
|
-
@Test
|
108
|
-
public void trianglesViolatingTriangleInequalityAreIllegal2() throws
|
114
|
+
@Test
|
115
|
+
public void trianglesViolatingTriangleInequalityAreIllegal2() throws TriangleException {
|
116
|
+
thrown.expect(TriangleException.class);
|
109
117
|
new Triangle(2, 4, 2);
|
110
118
|
}
|
111
119
|
|
112
120
|
@Ignore
|
113
|
-
@Test
|
114
|
-
public void trianglesViolatingTriangleInequalityAreIllegal3() throws
|
121
|
+
@Test
|
122
|
+
public void trianglesViolatingTriangleInequalityAreIllegal3() throws TriangleException {
|
123
|
+
thrown.expect(TriangleException.class);
|
115
124
|
new Triangle(7, 3, 2);
|
116
125
|
}
|
117
126
|
}
|
data/tracks/kotlin/config.json
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
subprojects {
|
2
2
|
afterEvaluate { Project project ->
|
3
|
+
|
4
|
+
configurations {
|
5
|
+
starterSourceCompile.extendsFrom compile
|
6
|
+
starterSourceRuntime.extendsFrom runtime
|
7
|
+
|
8
|
+
exerciseTestsCompile.extendsFrom testCompile
|
9
|
+
exerciseTestsRuntime.extendsFrom testRuntime
|
10
|
+
}
|
11
|
+
|
3
12
|
sourceSets {
|
4
13
|
// Verify that the tests are working by running them against the example code.
|
5
14
|
// By replacing the "main" sourceSet with the example code we avoid any collisions
|
@@ -18,6 +27,14 @@ subprojects {
|
|
18
27
|
println " (source = " + compileTask.source.asPath + ")"
|
19
28
|
}
|
20
29
|
|
30
|
+
exerciseTests {
|
31
|
+
kotlin {
|
32
|
+
srcDirs = ["src/test/kotlin"]
|
33
|
+
compileClasspath += main.output
|
34
|
+
runtimeClasspath += main.output
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
21
38
|
// In lieu of being able to disable @Ignore in JUnit tests, we filter
|
22
39
|
// those annotations, placing the edited tests in the path named here.
|
23
40
|
test {
|
@@ -0,0 +1,28 @@
|
|
1
|
+
buildscript {
|
2
|
+
ext.kotlin_version = '1.0.6'
|
3
|
+
repositories {
|
4
|
+
mavenCentral()
|
5
|
+
}
|
6
|
+
dependencies {
|
7
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
apply plugin: 'kotlin'
|
12
|
+
|
13
|
+
repositories {
|
14
|
+
mavenCentral()
|
15
|
+
}
|
16
|
+
|
17
|
+
dependencies {
|
18
|
+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
19
|
+
|
20
|
+
testCompile 'junit:junit:4.12'
|
21
|
+
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
|
22
|
+
}
|
23
|
+
test {
|
24
|
+
testLogging {
|
25
|
+
exceptionFormat = 'full'
|
26
|
+
events = ["passed", "failed", "skipped"]
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
enum class Classification {
|
3
|
+
DEFICIENT, PERFECT, ABUNDANT
|
4
|
+
}
|
5
|
+
|
6
|
+
fun classify(naturalNumber: Int): Classification {
|
7
|
+
require(naturalNumber >= 0, { "$naturalNumber is not a natural number" })
|
8
|
+
|
9
|
+
val aliquotSum = naturalNumber.aliquotSum()
|
10
|
+
return when {
|
11
|
+
aliquotSum == naturalNumber -> Classification.PERFECT
|
12
|
+
aliquotSum > naturalNumber -> Classification.ABUNDANT
|
13
|
+
else -> Classification.DEFICIENT
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
fun Int.aliquotSum(): Int = (1 until this).filter { this % it == 0 }.sum()
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import org.junit.Ignore
|
2
|
+
import org.junit.Test
|
3
|
+
|
4
|
+
import org.junit.Assert.assertEquals
|
5
|
+
|
6
|
+
class NaturalNumberTest {
|
7
|
+
|
8
|
+
@Test
|
9
|
+
fun smallPerfectNumberIsClassifiedCorrectly() {
|
10
|
+
assertEquals(Classification.PERFECT, classify(6))
|
11
|
+
}
|
12
|
+
|
13
|
+
@Ignore
|
14
|
+
@Test
|
15
|
+
fun mediumPerfectNumberIsClassifiedCorrectly() {
|
16
|
+
assertEquals(Classification.PERFECT, classify(28))
|
17
|
+
}
|
18
|
+
|
19
|
+
@Ignore
|
20
|
+
@Test
|
21
|
+
fun largePerfectNumberIsClassifiedCorrectly() {
|
22
|
+
assertEquals(Classification.PERFECT, classify(33550336))
|
23
|
+
}
|
24
|
+
|
25
|
+
@Ignore
|
26
|
+
@Test
|
27
|
+
fun smallAbundantNumberIsClassifiedCorrectly() {
|
28
|
+
assertEquals(Classification.ABUNDANT, classify(12))
|
29
|
+
}
|
30
|
+
|
31
|
+
@Ignore
|
32
|
+
@Test
|
33
|
+
fun mediumAbundantNumberIsClassifiedCorrectly() {
|
34
|
+
assertEquals(Classification.ABUNDANT, classify(24))
|
35
|
+
}
|
36
|
+
|
37
|
+
@Ignore
|
38
|
+
@Test
|
39
|
+
fun largeAbundantNumberIsClassifiedCorrectly() {
|
40
|
+
assertEquals(Classification.ABUNDANT, classify(33550335))
|
41
|
+
}
|
42
|
+
|
43
|
+
@Ignore
|
44
|
+
@Test
|
45
|
+
fun smallDeficientNumberIsClassifiedCorrectly() {
|
46
|
+
assertEquals(Classification.DEFICIENT, classify(8))
|
47
|
+
}
|
48
|
+
|
49
|
+
@Ignore
|
50
|
+
@Test
|
51
|
+
fun mediumNumberIsClassifiedCorrectly() {
|
52
|
+
assertEquals(Classification.DEFICIENT, classify(31))
|
53
|
+
}
|
54
|
+
|
55
|
+
@Ignore
|
56
|
+
@Test
|
57
|
+
fun largeDeficientNumberIsClassifiedCorrectly() {
|
58
|
+
assertEquals(Classification.DEFICIENT, classify(33550337))
|
59
|
+
}
|
60
|
+
|
61
|
+
@Ignore
|
62
|
+
@Test(expected = RuntimeException::class)
|
63
|
+
fun mustProvideNaturalNumber() {
|
64
|
+
assertEquals(Classification.DEFICIENT, classify(-1))
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|