trackler 2.0.1.1 → 2.0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/bin/update +4 -0
  3. data/common/exercises/minesweeper/canonical-data.json +3 -3
  4. data/fixtures/common/exercises/imbe/description.md +2 -0
  5. data/fixtures/common/exercises/imbe/metadata.yml +3 -0
  6. data/fixtures/common/exercises/no-metadata/description.md +1 -0
  7. data/fixtures/tracks/fruit/exercises/imbe/.meta/everything_in_meta_is_ignored.txt +0 -0
  8. data/fixtures/tracks/fruit/exercises/imbe/CaSe_iNSeNSiTiVe_eXaMPLe.TXT +0 -0
  9. data/fixtures/tracks/fruit/exercises/imbe/HINTS.md +1 -0
  10. data/fixtures/tracks/fruit/exercises/imbe/also_an_example.txt +1 -0
  11. data/fixtures/tracks/fruit/exercises/imbe/example.ext +1 -0
  12. data/fixtures/tracks/fruit/exercises/imbe/imbe.txt +1 -0
  13. data/lib/trackler/file_bundle.rb +27 -9
  14. data/lib/trackler/implementation.rb +7 -6
  15. data/lib/trackler/problem.rb +62 -37
  16. data/lib/trackler/version.rb +1 -1
  17. data/tracks/c/config.json +9 -0
  18. data/tracks/c/exercises/series/makefile +16 -0
  19. data/tracks/c/exercises/series/src/example.c +24 -0
  20. data/tracks/c/exercises/series/src/series.h +28 -0
  21. data/tracks/c/exercises/series/test/test_series.c +63 -0
  22. data/tracks/c/exercises/series/test/vendor/unity.c +1300 -0
  23. data/tracks/c/exercises/series/test/vendor/unity.h +274 -0
  24. data/tracks/c/exercises/series/test/vendor/unity_internals.h +701 -0
  25. data/tracks/crystal/src/generator/exercises/binary.cr +3 -3
  26. data/tracks/crystal/src/generator/exercises/forth.cr +3 -3
  27. data/tracks/crystal/src/generator/exercises/hello_world.cr +1 -1
  28. data/tracks/haskell/exercises/bob/test/Tests.hs +2 -10
  29. data/tracks/haskell/exercises/sublist/test/Tests.hs +6 -1
  30. data/tracks/java/config.json +13 -1
  31. data/tracks/java/exercises/bracket-push/build.gradle +17 -0
  32. data/tracks/java/exercises/bracket-push/src/example/java/BracketChecker.java +45 -0
  33. data/tracks/java/exercises/bracket-push/src/main/java/BracketChecker.java +5 -0
  34. data/tracks/java/exercises/bracket-push/src/test/java/BracketCheckerTest.java +102 -0
  35. data/tracks/java/exercises/robot-simulator/build.gradle +17 -0
  36. data/tracks/java/exercises/robot-simulator/src/example/java/GridPosition.java +1 -0
  37. data/tracks/java/exercises/robot-simulator/src/example/java/Orientation.java +1 -0
  38. data/tracks/java/exercises/robot-simulator/src/example/java/Robot.java +71 -0
  39. data/tracks/java/exercises/robot-simulator/src/main/java/GridPosition.java +29 -0
  40. data/tracks/java/exercises/robot-simulator/src/main/java/Orientation.java +5 -0
  41. data/tracks/java/exercises/robot-simulator/src/main/java/Robot.java +5 -0
  42. data/tracks/java/exercises/robot-simulator/src/test/java/RobotTest.java +244 -0
  43. data/tracks/java/exercises/settings.gradle +2 -0
  44. data/tracks/ocaml/exercises/say/test.ml +52 -56
  45. data/tracks/ocaml/tools/test-generator/src/codegen.ml +2 -1
  46. data/tracks/ocaml/tools/test-generator/src/special_cases.ml +10 -4
  47. data/tracks/ocaml/tools/test-generator/src/test_generator.ml +5 -0
  48. data/tracks/ocaml/tools/test-generator/templates/say/template.ml +21 -0
  49. data/tracks/ocaml/tools/test-generator/test/special_cases_test.ml +2 -2
  50. metadata +30 -1
@@ -16,16 +16,16 @@ end
16
16
  class BinaryTestCase < ExerciseTestCase
17
17
  private getter binary : JSON::Any
18
18
  private getter description : JSON::Any
19
- private getter expected : JSON::Any
19
+ private getter expected : JSON::Any?
20
20
 
21
21
  def initialize(test_case)
22
22
  @binary = test_case["binary"]
23
23
  @description = test_case["description"]
24
- @expected = test_case["expected"]
24
+ @expected = test_case["expected"]?
25
25
  end
26
26
 
27
27
  def workload
28
- if !(expected == nil)
28
+ if expected
29
29
  "Binary.to_decimal(\"#{binary}\").should eq(#{expected})"
30
30
  else
31
31
  <<-WL
@@ -22,16 +22,16 @@ end
22
22
  class ForthTestCase < ExerciseTestCase
23
23
  private getter input : JSON::Any | String
24
24
  private getter description : JSON::Any
25
- private getter expected : JSON::Any
25
+ private getter expected : JSON::Any?
26
26
 
27
27
  def initialize(test_case)
28
28
  @input = test_case["input"].as_a.join
29
29
  @description = test_case["description"]
30
- @expected = fix_empty_array(test_case["expected"])
30
+ @expected = fix_empty_array(test_case["expected"]?)
31
31
  end
32
32
 
33
33
  def workload
34
- if !(expected == nil)
34
+ if expected
35
35
  "Forth.evaluate(#{input.inspect}).should eq(#{expected})"
36
36
  else
37
37
  <<-WL
@@ -15,7 +15,7 @@ end
15
15
 
16
16
  class HelloWorldTestCase < ExerciseTestCase
17
17
  private getter description : JSON::Any
18
- private getter name : JSON::Any | Nil
18
+ private getter name : JSON::Any?
19
19
  private getter expected : JSON::Any
20
20
 
21
21
  def initialize(test_case)
@@ -15,7 +15,7 @@ specs = describe "bob" $
15
15
  where
16
16
  test Case{..} = it description $ responseFor input `shouldBe` expected
17
17
 
18
- -- Test cases adapted from `exercism/x-common/bob.json` on 2016-07-24.
18
+ -- Test cases adapted from `exercism/x-common/bob.json` on 2016-11-29.
19
19
 
20
20
  data Case = Case { description :: String
21
21
  , input :: String
@@ -75,14 +75,6 @@ cases = [ Case { description = "stating something"
75
75
  , input = "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"
76
76
  , expected = "Whoa, chill out!"
77
77
  }
78
- , Case { description = "shouting with umlauts"
79
- , input = "ÜMLÄÜTS!"
80
- , expected = "Whoa, chill out!"
81
- }
82
- , Case { description = "calmly speaking with umlauts"
83
- , input = "ÜMLäÜTS!"
84
- , expected = "Whatever."
85
- }
86
78
  , Case { description = "shouting with no exclamation mark"
87
79
  , input = "I HATE YOU"
88
80
  , expected = "Whoa, chill out!"
@@ -124,7 +116,7 @@ cases = [ Case { description = "stating something"
124
116
  , expected = "Sure."
125
117
  }
126
118
  , Case { description = "other whitespace"
127
- , input = "\n\r \t\x000b\x00a0\x2002"
119
+ , input = "\n\r \t"
128
120
  , expected = "Fine. Be that way!"
129
121
  }
130
122
  , Case { description = "non-question ending with whitespace"
@@ -42,7 +42,7 @@ specs = describe "sublist" $ do
42
42
  , "-"
43
43
  , description ]
44
44
 
45
- -- Test cases adapted from `exercism/x-common/sublist.json` on 2016-07-27.
45
+ -- Test cases adapted from `exercism/x-common/sublist.json` on 2016-11-29.
46
46
 
47
47
  data Case = Case { description :: String
48
48
  , listOne :: [Integer]
@@ -131,4 +131,9 @@ cases = [ Case { description = "empty lists"
131
131
  , listTwo = [3, 2, 1]
132
132
  , expectation = Unequal
133
133
  }
134
+ , Case { description = "same digits but different numbers"
135
+ , listOne = [1, 0, 1]
136
+ , listTwo = [10, 1]
137
+ , expectation = Unequal
138
+ }
134
139
  ]
@@ -48,7 +48,9 @@
48
48
  "largest-series-product",
49
49
  "queen-attack",
50
50
  "minesweeper",
51
- "series"
51
+ "series",
52
+ "robot-simulator",
53
+ "bracket-push"
52
54
  ],
53
55
  "exercises": [
54
56
  {
@@ -275,6 +277,16 @@
275
277
  "slug": "series",
276
278
  "difficulty": 1,
277
279
  "topics": []
280
+ },
281
+ {
282
+ "slug": "robot-simulator",
283
+ "difficulty": 1,
284
+ "topics": []
285
+ },
286
+ {
287
+ "slug": "bracket-push",
288
+ "difficulty": 1,
289
+ "topics": []
278
290
  }
279
291
  ],
280
292
  "deprecated": [
@@ -0,0 +1,17 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+ test {
13
+ testLogging {
14
+ exceptionFormat = 'full'
15
+ events = ["passed", "failed", "skipped"]
16
+ }
17
+ }
@@ -0,0 +1,45 @@
1
+ import java.util.*;
2
+
3
+ final class BracketChecker {
4
+
5
+ private static final Map<Character, Character> BRACKET_PAIR_MAP = new HashMap<Character, Character>() {{
6
+ put('[', ']');
7
+ put('{', '}');
8
+ put('(', ')');
9
+ }};
10
+
11
+ private static boolean isOpeningBracket(final char character) {
12
+ return BRACKET_PAIR_MAP.keySet().contains(character);
13
+ }
14
+
15
+ private static boolean isClosingBracket(final char character) {
16
+ return BRACKET_PAIR_MAP.values().contains(character);
17
+ }
18
+
19
+ private final String expression;
20
+
21
+ BracketChecker(final String expression) {
22
+ this.expression = expression;
23
+ }
24
+
25
+ boolean areBracketsMatchedAndNestedCorrectly() {
26
+ final Stack<Character> bracketsStack = new Stack<>();
27
+
28
+ for (final char character : expression.toCharArray()) {
29
+ if (isOpeningBracket(character)) {
30
+ bracketsStack.push(character);
31
+ } else if (isClosingBracket(character)) {
32
+ if (bracketsStack.isEmpty()) {
33
+ return false;
34
+ }
35
+
36
+ if (!BRACKET_PAIR_MAP.get(bracketsStack.pop()).equals(character)) {
37
+ return false;
38
+ }
39
+ }
40
+ }
41
+
42
+ return bracketsStack.isEmpty();
43
+ }
44
+
45
+ }
@@ -0,0 +1,5 @@
1
+ final class BracketChecker {
2
+
3
+
4
+
5
+ }
@@ -0,0 +1,102 @@
1
+ import org.junit.Ignore;
2
+ import org.junit.Test;
3
+
4
+ import static org.junit.Assert.assertEquals;
5
+ import static org.junit.Assert.assertFalse;
6
+ import static org.junit.Assert.assertTrue;
7
+
8
+ public final class BracketCheckerTest {
9
+
10
+ @Test
11
+ public void testPairedSquareBrackets() {
12
+ final BracketChecker bracketChecker = new BracketChecker("[]");
13
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
14
+ }
15
+
16
+ @Ignore
17
+ @Test
18
+ public void testEmptyString() {
19
+ final BracketChecker bracketChecker = new BracketChecker("");
20
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
21
+ }
22
+
23
+ @Ignore
24
+ @Test
25
+ public void testUnpairedBrackets() {
26
+ final BracketChecker bracketChecker = new BracketChecker("[[");
27
+ assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
28
+ }
29
+
30
+ @Ignore
31
+ @Test
32
+ public void testIncorrectlyOrderedBrackets() {
33
+ final BracketChecker bracketChecker = new BracketChecker("}{");
34
+ assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
35
+ }
36
+
37
+ @Ignore
38
+ @Test
39
+ public void testPairedBracketsWithWhitespace() {
40
+ final BracketChecker bracketChecker = new BracketChecker("{ }");
41
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
42
+ }
43
+
44
+ @Ignore
45
+ @Test
46
+ public void testSimpleNestedBrackets() {
47
+ final BracketChecker bracketChecker = new BracketChecker("{[]}");
48
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
49
+ }
50
+
51
+ @Ignore
52
+ @Test
53
+ public void testSeveralPairedBrackets() {
54
+ final BracketChecker bracketChecker = new BracketChecker("{}[]");
55
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
56
+ }
57
+
58
+ @Ignore
59
+ @Test
60
+ public void testPairedAndNestedBrackets() {
61
+ final BracketChecker bracketChecker = new BracketChecker("([{}({}[])])");
62
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
63
+ }
64
+
65
+ @Ignore
66
+ @Test
67
+ public void testUnopenedClosingBracket() {
68
+ final BracketChecker bracketChecker = new BracketChecker("{[)][]}");
69
+ assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
70
+ }
71
+
72
+ @Ignore
73
+ @Test
74
+ public void testUnpairedAndNestedBracket() {
75
+ final BracketChecker bracketChecker = new BracketChecker("([{])");
76
+ assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
77
+ }
78
+
79
+ @Ignore
80
+ @Test
81
+ public void testPairedAndIncorrectlyNestedBrackets() {
82
+ final BracketChecker bracketChecker = new BracketChecker("[({]})");
83
+ assertFalse(bracketChecker.areBracketsMatchedAndNestedCorrectly());
84
+ }
85
+
86
+ @Ignore
87
+ @Test
88
+ public void testValidMathExpression() {
89
+ final BracketChecker bracketChecker = new BracketChecker("(((185 + 223.85) * 15) - 543)/2");
90
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
91
+ }
92
+
93
+ @Ignore
94
+ @Test
95
+ public void testValidComplexLaTeXExpression() {
96
+ final BracketChecker bracketChecker = new BracketChecker(
97
+ "\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)");
98
+
99
+ assertTrue(bracketChecker.areBracketsMatchedAndNestedCorrectly());
100
+ }
101
+
102
+ }
@@ -0,0 +1,17 @@
1
+ apply plugin: "java"
2
+ apply plugin: "eclipse"
3
+ apply plugin: "idea"
4
+
5
+ repositories {
6
+ mavenCentral()
7
+ }
8
+
9
+ dependencies {
10
+ testCompile "junit:junit:4.12"
11
+ }
12
+ test {
13
+ testLogging {
14
+ exceptionFormat = 'full'
15
+ events = ["passed", "failed", "skipped"]
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ tracks/java/exercises/robot-simulator/src/example/java/../../main/java/GridPosition.java
@@ -0,0 +1 @@
1
+ tracks/java/exercises/robot-simulator/src/example/java/../../main/java/Orientation.java
@@ -0,0 +1,71 @@
1
+ final class Robot {
2
+
3
+ private GridPosition gridPosition;
4
+
5
+ private Orientation orientation;
6
+
7
+ Robot(final GridPosition initialGridPosition, final Orientation initialOrientation) {
8
+ this.gridPosition = initialGridPosition;
9
+ this.orientation = initialOrientation;
10
+ }
11
+
12
+ GridPosition getGridPosition() {
13
+ return gridPosition;
14
+ }
15
+
16
+ Orientation getOrientation() {
17
+ return orientation;
18
+ }
19
+
20
+ Robot advance() {
21
+ switch (orientation) {
22
+ case NORTH:
23
+ gridPosition = new GridPosition(gridPosition.x, gridPosition.y + 1);
24
+ break;
25
+ case EAST:
26
+ gridPosition = new GridPosition(gridPosition.x + 1, gridPosition.y);
27
+ break;
28
+ case SOUTH:
29
+ gridPosition = new GridPosition(gridPosition.x, gridPosition.y - 1);
30
+ break;
31
+ case WEST:
32
+ gridPosition = new GridPosition(gridPosition.x - 1, gridPosition.y);
33
+ break;
34
+ }
35
+
36
+ return this;
37
+ }
38
+
39
+ Robot simulate(final String instructions) {
40
+ for (final char instruction : instructions.toCharArray()) {
41
+ switch (instruction) {
42
+ case 'A':
43
+ advance();
44
+ break;
45
+ case 'R':
46
+ turnRight();
47
+ break;
48
+ case 'L':
49
+ turnLeft();
50
+ break;
51
+ default:
52
+ throw new IllegalArgumentException(String.format("Invalid instruction: '%s'", instruction));
53
+ }
54
+ }
55
+
56
+ return this;
57
+ }
58
+
59
+ Robot turnLeft() {
60
+ final int newOrientationOrdinal = Math.floorMod(orientation.ordinal() - 1, Orientation.values().length);
61
+ orientation = Orientation.values()[newOrientationOrdinal];
62
+ return this;
63
+ }
64
+
65
+ Robot turnRight() {
66
+ final int newOrientationOrdinal = Math.floorMod(orientation.ordinal() + 1, Orientation.values().length);
67
+ orientation = Orientation.values()[newOrientationOrdinal];
68
+ return this;
69
+ }
70
+
71
+ }
@@ -0,0 +1,29 @@
1
+ final class GridPosition {
2
+
3
+ final int x;
4
+
5
+ final int y;
6
+
7
+ GridPosition(final int x, final int y) {
8
+ this.x = x;
9
+ this.y = y;
10
+ }
11
+
12
+ /*
13
+ * This equals method is of deliberately narrow scope (only allows comparison with another GridPosition) to increase
14
+ * readability. In general, one should provide a full implementation of Object.equals(Object obj) and a
15
+ * corresponding implementation of Object.hashCode(). See
16
+ *
17
+ * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#equals(java.lang.Object)
18
+ *
19
+ * and
20
+ *
21
+ * https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#hashCode()
22
+ *
23
+ * for more information.
24
+ */
25
+ boolean equals(final GridPosition gridPosition) {
26
+ return this.x == gridPosition.x && this.y == gridPosition.y;
27
+ }
28
+
29
+ }
@@ -0,0 +1,5 @@
1
+ enum Orientation {
2
+
3
+ NORTH, EAST, SOUTH, WEST
4
+
5
+ }