trackler 2.2.1.95 → 2.2.1.96

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/two-bucket/canonical-data.json +31 -31
  4. data/tracks/csharp/docs/ABOUT.md +21 -3
  5. data/tracks/dart/.travis.yml +1 -2
  6. data/tracks/dart/README.md +2 -2
  7. data/tracks/dart/{tool/create-exercise → bin/create_exercise.dart} +14 -10
  8. data/tracks/dart/test/create_exercise_test.dart +132 -0
  9. data/tracks/dart/test/exercises_test.dart +1 -1
  10. data/tracks/fsharp/exercises/list-ops/Example.fs +5 -5
  11. data/tracks/fsharp/exercises/list-ops/ListOps.fs +1 -1
  12. data/tracks/fsharp/exercises/list-ops/ListOpsTest.fs +41 -62
  13. data/tracks/fsharp/generators/Common.fs +3 -0
  14. data/tracks/fsharp/generators/Formatting.fs +3 -1
  15. data/tracks/fsharp/generators/Generators.fs +21 -0
  16. data/tracks/go/config.json +14 -0
  17. data/tracks/go/exercises/grep/.meta/gen.go +76 -0
  18. data/tracks/go/exercises/grep/.meta/hints.md +13 -0
  19. data/tracks/go/exercises/grep/README.md +104 -0
  20. data/tracks/go/exercises/grep/cases_test.go +202 -0
  21. data/tracks/go/exercises/grep/example.go +102 -0
  22. data/tracks/go/exercises/grep/grep_test.go +84 -0
  23. data/tracks/java/exercises/anagram/.meta/version +1 -1
  24. data/tracks/java/exercises/anagram/src/test/java/AnagramTest.java +0 -32
  25. data/tracks/java/exercises/space-age/.meta/src/reference/java/SpaceAge.java +0 -4
  26. data/tracks/java/exercises/space-age/.meta/version +1 -0
  27. data/tracks/java/exercises/space-age/src/test/java/SpaceAgeTest.java +0 -16
  28. data/tracks/julia/.gitignore +1 -0
  29. data/tracks/julia/exercises/complex-numbers/{HINTS.md → .meta/hints.md} +0 -0
  30. data/tracks/julia/exercises/custom-set/{HINTS.md → .meta/hints.md} +0 -0
  31. data/tracks/julia/exercises/robot-name/{HINTS.md → .meta/hints.md} +0 -0
  32. data/tracks/julia/exercises/rotational-cipher/{HINTS.md → .meta/hints.md} +0 -0
  33. data/tracks/julia/runtests.jl +24 -25
  34. data/tracks/perl6/.travis.yml +7 -3
  35. data/tracks/perl6/Dockerfile +4 -0
  36. data/tracks/perl6/exercises/accumulate/Accumulate.pm6 +1 -1
  37. data/tracks/perl6/exercises/accumulate/Example.pm6 +1 -1
  38. data/tracks/perl6/exercises/accumulate/accumulate.t +6 -15
  39. data/tracks/perl6/exercises/accumulate/example.yaml +2 -3
  40. data/tracks/perl6/exercises/acronym/Acronym.pm6 +1 -1
  41. data/tracks/perl6/exercises/acronym/Example.pm6 +1 -1
  42. data/tracks/perl6/exercises/acronym/acronym.t +7 -29
  43. data/tracks/perl6/exercises/acronym/example.yaml +2 -3
  44. data/tracks/perl6/exercises/all-your-base/AllYourBase.pm6 +1 -1
  45. data/tracks/perl6/exercises/all-your-base/Example.pm6 +1 -1
  46. data/tracks/perl6/exercises/all-your-base/all-your-base.t +7 -29
  47. data/tracks/perl6/exercises/all-your-base/example.yaml +2 -3
  48. data/tracks/perl6/exercises/allergies/Allergies.pm6 +1 -1
  49. data/tracks/perl6/exercises/allergies/Example.pm6 +1 -1
  50. data/tracks/perl6/exercises/allergies/allergies.t +7 -29
  51. data/tracks/perl6/exercises/allergies/example.yaml +2 -3
  52. data/tracks/perl6/exercises/anagram/Anagram.pm6 +1 -1
  53. data/tracks/perl6/exercises/anagram/Example.pm6 +1 -1
  54. data/tracks/perl6/exercises/anagram/anagram.t +7 -29
  55. data/tracks/perl6/exercises/anagram/example.yaml +2 -3
  56. data/tracks/perl6/exercises/atbash-cipher/AtbashCipher.pm6 +1 -1
  57. data/tracks/perl6/exercises/atbash-cipher/Example.pm6 +1 -1
  58. data/tracks/perl6/exercises/atbash-cipher/atbash-cipher.t +7 -29
  59. data/tracks/perl6/exercises/atbash-cipher/example.yaml +2 -3
  60. data/tracks/{julia/exercises/.keep → perl6/exercises/binary/Binary.pm6} +0 -0
  61. data/tracks/perl6/exercises/binary/binary.t +3 -5
  62. data/tracks/perl6/exercises/bob/Bob.pm6 +1 -1
  63. data/tracks/perl6/exercises/bob/Example.pm6 +1 -1
  64. data/tracks/perl6/exercises/bob/bob.t +9 -32
  65. data/tracks/perl6/exercises/bob/example.yaml +3 -7
  66. data/tracks/perl6/exercises/clock/Clock.pm6 +1 -1
  67. data/tracks/perl6/exercises/clock/Example.pm6 +1 -1
  68. data/tracks/perl6/exercises/clock/clock.t +12 -32
  69. data/tracks/perl6/exercises/clock/example.yaml +6 -6
  70. data/tracks/perl6/exercises/etl/ETL.pm6 +1 -1
  71. data/tracks/perl6/exercises/etl/Example.pm6 +1 -1
  72. data/tracks/perl6/exercises/etl/etl.t +7 -29
  73. data/tracks/perl6/exercises/etl/example.yaml +2 -3
  74. data/tracks/perl6/exercises/flatten-array/Example.pm6 +1 -1
  75. data/tracks/perl6/exercises/flatten-array/FlattenArray.pm6 +1 -1
  76. data/tracks/perl6/exercises/flatten-array/example.yaml +2 -3
  77. data/tracks/perl6/exercises/flatten-array/flatten-array.t +7 -29
  78. data/tracks/perl6/exercises/grade-school/Example.pm6 +1 -1
  79. data/tracks/perl6/exercises/grade-school/GradeSchool.pm6 +1 -1
  80. data/tracks/perl6/exercises/grade-school/example.yaml +2 -3
  81. data/tracks/perl6/exercises/grade-school/grade-school.t +6 -15
  82. data/tracks/perl6/exercises/grains/Example.pm6 +1 -1
  83. data/tracks/perl6/exercises/grains/Grains.pm6 +1 -1
  84. data/tracks/perl6/exercises/grains/example.yaml +2 -3
  85. data/tracks/perl6/exercises/grains/grains.t +7 -29
  86. data/tracks/perl6/exercises/hamming/Example.pm6 +1 -1
  87. data/tracks/perl6/exercises/hamming/Hamming.pm6 +1 -1
  88. data/tracks/perl6/exercises/hamming/example.yaml +2 -3
  89. data/tracks/perl6/exercises/hamming/hamming.t +7 -29
  90. data/tracks/perl6/exercises/hello-world/Example.pm6 +1 -1
  91. data/tracks/perl6/exercises/hello-world/HelloWorld.pm6 +1 -1
  92. data/tracks/perl6/exercises/hello-world/example.yaml +2 -8
  93. data/tracks/perl6/exercises/hello-world/hello-world.t +7 -33
  94. data/tracks/perl6/exercises/leap/Example.pm6 +1 -1
  95. data/tracks/perl6/exercises/leap/Leap.pm6 +1 -1
  96. data/tracks/perl6/exercises/leap/example.yaml +2 -3
  97. data/tracks/perl6/exercises/leap/leap.t +7 -29
  98. data/tracks/perl6/exercises/linked-list/Example.pm6 +1 -1
  99. data/tracks/perl6/exercises/linked-list/LinkedList.pm6 +1 -1
  100. data/tracks/perl6/exercises/linked-list/example.yaml +3 -3
  101. data/tracks/perl6/exercises/linked-list/linked-list.t +9 -16
  102. data/tracks/perl6/exercises/luhn/Example.pm6 +1 -1
  103. data/tracks/perl6/exercises/luhn/Luhn.pm6 +1 -1
  104. data/tracks/perl6/exercises/luhn/example.yaml +2 -3
  105. data/tracks/perl6/exercises/luhn/luhn.t +7 -29
  106. data/tracks/perl6/exercises/meetup/Example.pm6 +1 -1
  107. data/tracks/perl6/exercises/meetup/Meetup.pm6 +1 -1
  108. data/tracks/perl6/exercises/meetup/example.yaml +2 -3
  109. data/tracks/perl6/exercises/meetup/meetup.t +7 -29
  110. data/tracks/perl6/exercises/nucleotide-count/Example.pm6 +1 -1
  111. data/tracks/perl6/exercises/nucleotide-count/NucleotideCount.pm6 +1 -1
  112. data/tracks/perl6/exercises/nucleotide-count/example.yaml +2 -3
  113. data/tracks/perl6/exercises/nucleotide-count/nucleotide-count.t +7 -29
  114. data/tracks/perl6/exercises/pangram/Example.pm6 +1 -1
  115. data/tracks/perl6/exercises/pangram/Pangram.pm6 +1 -1
  116. data/tracks/perl6/exercises/pangram/example.yaml +2 -3
  117. data/tracks/perl6/exercises/pangram/pangram.t +7 -29
  118. data/tracks/perl6/exercises/phone-number/Example.pm6 +1 -1
  119. data/tracks/perl6/exercises/phone-number/Phone.pm6 +1 -1
  120. data/tracks/perl6/exercises/phone-number/example.yaml +2 -3
  121. data/tracks/perl6/exercises/phone-number/phone-number.t +7 -29
  122. data/tracks/perl6/exercises/raindrops/Example.pm6 +1 -1
  123. data/tracks/perl6/exercises/raindrops/Raindrops.pm6 +1 -1
  124. data/tracks/perl6/exercises/raindrops/example.yaml +2 -3
  125. data/tracks/perl6/exercises/raindrops/raindrops.t +7 -29
  126. data/tracks/perl6/exercises/rna-transcription/Example.pm6 +1 -1
  127. data/tracks/perl6/exercises/rna-transcription/RNA.pm6 +1 -1
  128. data/tracks/perl6/exercises/rna-transcription/example.yaml +2 -3
  129. data/tracks/perl6/exercises/rna-transcription/rna-transcription.t +7 -29
  130. data/tracks/perl6/exercises/robot-name/Example.pm6 +1 -1
  131. data/tracks/perl6/exercises/robot-name/Robot.pm6 +1 -1
  132. data/tracks/perl6/exercises/robot-name/example.yaml +5 -5
  133. data/tracks/perl6/exercises/robot-name/robot-name.t +10 -17
  134. data/tracks/perl6/exercises/roman-numerals/Example.pm6 +1 -1
  135. data/tracks/perl6/exercises/roman-numerals/RomanNumerals.pm6 +1 -1
  136. data/tracks/perl6/exercises/roman-numerals/example.yaml +2 -3
  137. data/tracks/perl6/exercises/roman-numerals/roman-numerals.t +7 -29
  138. data/tracks/perl6/exercises/scrabble-score/Example.pm6 +1 -1
  139. data/tracks/perl6/exercises/scrabble-score/Scrabble.pm6 +1 -1
  140. data/tracks/perl6/exercises/scrabble-score/example.yaml +2 -3
  141. data/tracks/perl6/exercises/scrabble-score/scrabble-score.t +7 -29
  142. data/tracks/perl6/exercises/space-age/Example.pm6 +1 -1
  143. data/tracks/perl6/exercises/space-age/SpaceAge.pm6 +1 -1
  144. data/tracks/perl6/exercises/space-age/example.yaml +2 -3
  145. data/tracks/perl6/exercises/space-age/space-age.t +7 -29
  146. data/tracks/perl6/exercises/trinary/Trinary.pm6 +0 -0
  147. data/tracks/perl6/exercises/trinary/trinary.t +2 -5
  148. data/tracks/perl6/exercises/two-fer/Example.pm6 +1 -1
  149. data/tracks/perl6/exercises/two-fer/TwoFer.pm6 +1 -1
  150. data/tracks/perl6/exercises/two-fer/example.yaml +2 -8
  151. data/tracks/perl6/exercises/two-fer/two-fer.t +7 -33
  152. data/tracks/perl6/exercises/word-count/Example.pm6 +1 -1
  153. data/tracks/perl6/exercises/word-count/WordCount.pm6 +1 -1
  154. data/tracks/perl6/exercises/word-count/example.yaml +2 -3
  155. data/tracks/perl6/exercises/word-count/word-count.t +7 -29
  156. data/tracks/perl6/exercises/wordy/Example.pm6 +1 -1
  157. data/tracks/perl6/exercises/wordy/Wordy.pm6 +1 -1
  158. data/tracks/perl6/exercises/wordy/example.yaml +2 -3
  159. data/tracks/perl6/exercises/wordy/wordy.t +7 -29
  160. data/tracks/perl6/templates/test.mustache +10 -39
  161. data/tracks/python/config.json +10 -0
  162. data/tracks/python/exercises/all-your-base/all_your_base_test.py +2 -2
  163. data/tracks/python/exercises/binary-search/binary_search_test.py +2 -2
  164. data/tracks/python/exercises/binary/binary_test.py +2 -2
  165. data/tracks/python/exercises/bob/bob_test.py +4 -2
  166. data/tracks/python/exercises/bob/example.py +5 -2
  167. data/tracks/python/exercises/circular-buffer/circular_buffer_test.py +2 -2
  168. data/tracks/python/exercises/custom-set/README.md +20 -0
  169. data/tracks/python/exercises/custom-set/custom_set.py +30 -0
  170. data/tracks/python/exercises/custom-set/custom_set_test.py +212 -0
  171. data/tracks/python/exercises/custom-set/example.py +45 -0
  172. data/tracks/python/exercises/dot-dsl/dot_dsl_test.py +20 -10
  173. data/tracks/python/exercises/error-handling/error_handling_test.py +2 -2
  174. data/tracks/python/exercises/forth/forth_test.py +18 -18
  175. data/tracks/python/exercises/grains/grains_test.py +2 -2
  176. data/tracks/python/exercises/hamming/hamming_test.py +2 -2
  177. data/tracks/python/exercises/hexadecimal/hexadecimal_test.py +2 -2
  178. data/tracks/python/exercises/largest-series-product/largest_series_product_test.py +2 -2
  179. data/tracks/python/exercises/meetup/meetup_test.py +2 -2
  180. data/tracks/python/exercises/minesweeper/minesweeper_test.py +2 -2
  181. data/tracks/python/exercises/nth-prime/nth_prime_test.py +2 -2
  182. data/tracks/python/exercises/nucleotide-count/nucleotide_count_test.py +2 -2
  183. data/tracks/python/exercises/ocr-numbers/ocr_numbers_test.py +2 -2
  184. data/tracks/python/exercises/octal/octal_test.py +2 -2
  185. data/tracks/python/exercises/perfect-numbers/perfect_numbers_test.py +2 -2
  186. data/tracks/python/exercises/phone-number/phone_number_test.py +2 -2
  187. data/tracks/python/exercises/pov/pov_test.py +2 -2
  188. data/tracks/python/exercises/protein-translation/protein_translation_test.py +2 -2
  189. data/tracks/python/exercises/pythagorean-triplet/pythagorean_triplet_test.py +2 -2
  190. data/tracks/python/exercises/queen-attack/queen_attack_test.py +2 -2
  191. data/tracks/python/exercises/rna-transcription/rna_transcription_test.py +2 -2
  192. data/tracks/python/exercises/saddle-points/saddle_points_test.py +2 -2
  193. data/tracks/python/exercises/say/say_test.py +2 -2
  194. data/tracks/python/exercises/scale-generator/scale_generator_test.py +2 -2
  195. data/tracks/python/exercises/series/series_test.py +2 -2
  196. data/tracks/python/exercises/simple-cipher/simple_cipher_test.py +2 -2
  197. data/tracks/python/exercises/simple-linked-list/simple_linked_list_test.py +2 -2
  198. data/tracks/python/exercises/tree-building/tree_building_test.py +2 -2
  199. data/tracks/python/exercises/triangle/example.py +14 -24
  200. data/tracks/python/exercises/triangle/triangle.py +6 -6
  201. data/tracks/python/exercises/triangle/triangle_test.py +42 -44
  202. data/tracks/python/exercises/variable-length-quantity/variable_length_quantity_test.py +2 -2
  203. data/tracks/python/exercises/wordy/wordy_test.py +2 -2
  204. data/tracks/python/test/check-exercises.py +2 -1
  205. metadata +22 -8
@@ -0,0 +1,102 @@
1
+ package grep
2
+
3
+ import (
4
+ "bufio"
5
+ "os"
6
+ "strconv"
7
+ "strings"
8
+ )
9
+
10
+ type options struct {
11
+ printLineNumbers bool
12
+ printFilenamesOnly bool
13
+ caseInsensitiveMatch bool
14
+ invertPatternMatch bool
15
+ matchEntireLine bool
16
+ prefixFilenames bool
17
+ }
18
+
19
+ // Search looks for pattern in the files given, using optional flags.
20
+ func Search(pattern string, flags, files []string) []string {
21
+ output := []string{}
22
+ options := getOptions(flags, len(files))
23
+ for _, file := range files {
24
+ output = append(output, searchFile(pattern, file, options)...)
25
+ }
26
+ return output
27
+ }
28
+
29
+ // searchFile performs a search for pattern in the given file
30
+ // and returns the output according to the options.
31
+ func searchFile(pattern string, file string, options *options) (output []string) {
32
+ f, err := os.Open(file)
33
+ if err != nil {
34
+ return nil
35
+ }
36
+ defer f.Close()
37
+ var filePrefix string
38
+ if options.prefixFilenames {
39
+ filePrefix = file + ":"
40
+ }
41
+ scanner := bufio.NewScanner(f)
42
+ for lineNum := 1; scanner.Scan(); lineNum++ {
43
+ var match bool
44
+ line := scanner.Text()
45
+ if options.matchEntireLine {
46
+ if options.caseInsensitiveMatch {
47
+ match = strings.EqualFold(line, pattern)
48
+ } else {
49
+ match = line == pattern
50
+ }
51
+ } else {
52
+ if options.caseInsensitiveMatch {
53
+ match = strings.Contains(strings.ToLower(line), strings.ToLower(pattern))
54
+ } else {
55
+ match = strings.Contains(line, pattern)
56
+ }
57
+ }
58
+ if match && !options.invertPatternMatch {
59
+ if options.printFilenamesOnly {
60
+ output = append(output, file)
61
+ break
62
+ } else if options.printLineNumbers {
63
+ output = append(output, filePrefix+strconv.Itoa(lineNum)+":"+line)
64
+ } else {
65
+ output = append(output, filePrefix+line)
66
+ }
67
+ } else if !match && options.invertPatternMatch {
68
+ if options.printFilenamesOnly {
69
+ output = append(output, file)
70
+ break
71
+ } else if options.printLineNumbers {
72
+ output = append(output, filePrefix+strconv.Itoa(lineNum)+":"+line)
73
+ } else {
74
+ output = append(output, filePrefix+line)
75
+ }
76
+ }
77
+ }
78
+ return output
79
+ }
80
+
81
+ // getOptions examines flags and nfiles, outputing options.
82
+ func getOptions(flags []string, nfiles int) (opt *options) {
83
+ opt = &options{}
84
+ for _, option := range flags {
85
+ switch option {
86
+ case "-n":
87
+ opt.printLineNumbers = true
88
+ case "-l":
89
+ opt.printFilenamesOnly = true
90
+ case "-i":
91
+ opt.caseInsensitiveMatch = true
92
+ case "-v":
93
+ opt.invertPatternMatch = true
94
+ case "-x":
95
+ opt.matchEntireLine = true
96
+ }
97
+ }
98
+ if nfiles > 1 {
99
+ opt.prefixFilenames = true
100
+ }
101
+ return opt
102
+ }
@@ -0,0 +1,84 @@
1
+ package grep
2
+
3
+ import (
4
+ "os"
5
+ "reflect"
6
+ "strings"
7
+ "testing"
8
+ )
9
+
10
+ func createFiles(content []string) (filenames []string) {
11
+ // Parse fileContentData, making the list of filenames
12
+ // with their content.
13
+ var filename string
14
+ var f *os.File
15
+ for _, d := range content {
16
+ t := strings.TrimSpace(d)
17
+ if len(t) == 0 {
18
+ if len(filename) == 0 {
19
+ continue
20
+ }
21
+ // Close file
22
+ f.Close()
23
+ filenames = append(filenames, filename)
24
+ filename = ""
25
+ f = nil
26
+ continue
27
+ }
28
+ if strings.Contains(t, ".txt") {
29
+ filename = t
30
+ // Open file
31
+ var err error
32
+ f, err = os.Create(filename)
33
+ if err != nil {
34
+ panic(err)
35
+ }
36
+ continue
37
+ }
38
+ fields := strings.Split(t, "|")
39
+ if len(fields) == 3 {
40
+ // Write string into file with newline.
41
+ _, err := f.WriteString(strings.TrimRight(fields[1], " ") + "\n")
42
+ if err != nil {
43
+ panic(err)
44
+ }
45
+ }
46
+ }
47
+ if f != nil {
48
+ f.Close()
49
+ filenames = append(filenames, filename)
50
+ }
51
+ return
52
+ }
53
+
54
+ func deleteFiles(filenames []string) {
55
+ for _, file := range filenames {
56
+ os.Remove(file)
57
+ }
58
+ }
59
+
60
+ func TestSearch(t *testing.T) {
61
+ files := createFiles(fileContentData)
62
+ defer deleteFiles(files)
63
+
64
+ for _, tc := range testCases {
65
+ actual := Search(tc.pattern, tc.flags, tc.files)
66
+ if !reflect.DeepEqual(actual, tc.expected) {
67
+ t.Fatalf("FAIL: %s\nSearch for pattern %q\nexpected %v\nactual %v.",
68
+ tc.description, tc.pattern, tc.expected, actual)
69
+ }
70
+ t.Logf("PASS: %s", tc.description)
71
+ }
72
+ }
73
+
74
+ func BenchmarkSearch(b *testing.B) {
75
+ files := createFiles(fileContentData)
76
+ defer deleteFiles(files)
77
+
78
+ b.ResetTimer()
79
+ for i := 0; i < b.N; i++ {
80
+ for _, tc := range testCases {
81
+ Search(tc.pattern, tc.flags, tc.files)
82
+ }
83
+ }
84
+ }
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -17,22 +17,6 @@ public class AnagramTest {
17
17
  assertTrue(detector.match(Arrays.asList("hello", "world", "zombies", "pants")).isEmpty());
18
18
  }
19
19
 
20
- @Ignore("Remove to run test")
21
- @Test
22
- public void testDetectSimpleAnagram() {
23
- Anagram detector = new Anagram("ant");
24
- List<String> anagram = detector.match(Arrays.asList("tan", "stand", "at"));
25
- assertThat(anagram, hasItem("tan"));
26
- assertThat(anagram.size(), is(1));
27
- }
28
-
29
- @Ignore("Remove to run test")
30
- @Test
31
- public void testDoesNotConfuseDifferentDuplicates() {
32
- Anagram detector = new Anagram("galea");
33
- assertTrue(detector.match(Collections.singletonList("eagle")).isEmpty());
34
- }
35
-
36
20
  @Ignore("Remove to run test")
37
21
  @Test
38
22
  public void testDetectMultipleAnagrams() {
@@ -64,15 +48,6 @@ public class AnagramTest {
64
48
  assertThat(anagrams, allOf(hasItem("gallery"), hasItem("regally"), hasItem("largely")));
65
49
  }
66
50
 
67
- @Ignore("Remove to run test")
68
- @Test
69
- public void testIdenticalWordIsNotAnagram() {
70
- Anagram detector = new Anagram("corn");
71
- List<String> anagrams = detector.match(Arrays.asList("corn", "dark", "Corn", "rank", "CORN", "cron", "park"));
72
- assertThat(anagrams, hasItem("cron"));
73
- assertThat(anagrams.size(), is(1));
74
- }
75
-
76
51
  @Ignore("Remove to run test")
77
52
  @Test
78
53
  public void testEliminateAnagramsWithSameChecksum() {
@@ -104,13 +79,6 @@ public class AnagramTest {
104
79
  assertThat(anagrams, hasItem("Carthorse"));
105
80
  }
106
81
 
107
- @Ignore("Remove to run test")
108
- @Test
109
- public void testWordIsNotItsOwnAnagram() {
110
- Anagram detector = new Anagram("banana");
111
- assertTrue(detector.match(Collections.singletonList("Banana")).isEmpty());
112
- }
113
-
114
82
  @Ignore("Remove to run test")
115
83
  @Test
116
84
  public void testIdenticalWordRepeatedIsNotAnagram() {
@@ -32,10 +32,6 @@ class SpaceAge {
32
32
  this.seconds = seconds;
33
33
  }
34
34
 
35
- double getSeconds() {
36
- return seconds;
37
- }
38
-
39
35
  double onEarth() {
40
36
  return calculateAge(Planet.EARTH);
41
37
  }
@@ -7,15 +7,6 @@ public class SpaceAgeTest {
7
7
 
8
8
  private static final double MAXIMUM_DELTA = 1E-02;
9
9
 
10
-
11
- @Test
12
- public void ageInSeconds() {
13
- SpaceAge age = new SpaceAge(1000000);
14
-
15
- assertEquals(1000000, age.getSeconds(), MAXIMUM_DELTA);
16
- }
17
-
18
- @Ignore("Remove to run test")
19
10
  @Test
20
11
  public void ageOnEarth() {
21
12
  SpaceAge age = new SpaceAge(1000000000);
@@ -28,7 +19,6 @@ public class SpaceAgeTest {
28
19
  public void ageOnMercury() {
29
20
  SpaceAge age = new SpaceAge(2134835688);
30
21
 
31
- assertEquals(67.65, age.onEarth(), MAXIMUM_DELTA);
32
22
  assertEquals(280.88, age.onMercury(), MAXIMUM_DELTA);
33
23
  }
34
24
 
@@ -37,7 +27,6 @@ public class SpaceAgeTest {
37
27
  public void ageOnVenus() {
38
28
  SpaceAge age = new SpaceAge(189839836);
39
29
 
40
- assertEquals(6.02, age.onEarth(), MAXIMUM_DELTA);
41
30
  assertEquals(9.78, age.onVenus(), MAXIMUM_DELTA);
42
31
  }
43
32
 
@@ -46,7 +35,6 @@ public class SpaceAgeTest {
46
35
  public void ageOnMars() {
47
36
  SpaceAge age = new SpaceAge(2329871239L);
48
37
 
49
- assertEquals(73.83, age.onEarth(), MAXIMUM_DELTA);
50
38
  assertEquals(39.25, age.onMars(), MAXIMUM_DELTA);
51
39
  }
52
40
 
@@ -55,7 +43,6 @@ public class SpaceAgeTest {
55
43
  public void ageOnJupiter() {
56
44
  SpaceAge age = new SpaceAge(901876382);
57
45
 
58
- assertEquals(28.58, age.onEarth(), MAXIMUM_DELTA);
59
46
  assertEquals(2.41, age.onJupiter(), MAXIMUM_DELTA);
60
47
  }
61
48
 
@@ -64,7 +51,6 @@ public class SpaceAgeTest {
64
51
  public void ageOnSaturn() {
65
52
  SpaceAge age = new SpaceAge(3000000000L);
66
53
 
67
- assertEquals(95.06, age.onEarth(), MAXIMUM_DELTA);
68
54
  assertEquals(3.23, age.onSaturn(), MAXIMUM_DELTA);
69
55
  }
70
56
 
@@ -73,7 +59,6 @@ public class SpaceAgeTest {
73
59
  public void ageOnUranus() {
74
60
  SpaceAge age = new SpaceAge(3210123456L);
75
61
 
76
- assertEquals(101.72, age.onEarth(), MAXIMUM_DELTA);
77
62
  assertEquals(1.21, age.onUranus(), MAXIMUM_DELTA);
78
63
  }
79
64
 
@@ -82,7 +67,6 @@ public class SpaceAgeTest {
82
67
  public void ageOnNeptune() {
83
68
  SpaceAge age = new SpaceAge(8210123456L);
84
69
 
85
- assertEquals(260.16, age.onEarth(), MAXIMUM_DELTA);
86
70
  assertEquals(1.58, age.onNeptune(), MAXIMUM_DELTA);
87
71
  }
88
72
  }
@@ -2,3 +2,4 @@
2
2
  .DS_Store
3
3
  bin/configlet
4
4
  bin/configlet.exe
5
+ tmp/
@@ -13,32 +13,31 @@ macro test_broken(ex)
13
13
  @test eval(current_module(), ex)
14
14
  end
15
15
 
16
- for (root, dirs, files) in walkdir("exercises")
17
- for exercise in dirs
18
- # Allow only testing specified execises
19
- if !isempty(ARGS) && !(exercise in ARGS)
20
- continue
21
- end
16
+ for exercise in readdir("exercises")
17
+ # Allow only testing specified execises
18
+ if !isempty(ARGS) && !(exercise in ARGS)
19
+ continue
20
+ end
21
+
22
+ exercise_path = joinpath("exercises", exercise)
23
+ isdir(exercise_path) || continue
24
+
25
+ # Create temporary directory
26
+ temp_path = mktempdir(".")
27
+
28
+ # Copy tests & example to the temporary directory
29
+ cp(joinpath(exercise_path, "example.jl"), joinpath(temp_path, "$exercise.jl"))
30
+ cp(joinpath(exercise_path, "runtests.jl"), joinpath(temp_path, "runtests.jl"))
22
31
 
23
- exercise_path = joinpath("exercises", exercise)
24
-
25
- # Create temporary directory
26
- temp_path = mktempdir(root)
27
-
28
- # Copy tests & example to the temporary directory
29
- cp(joinpath(exercise_path, "example.jl"), joinpath(temp_path, "$exercise.jl"))
30
- cp(joinpath(exercise_path, "runtests.jl"), joinpath(temp_path, "runtests.jl"))
31
-
32
- try
33
- # Run the tests
34
- @testset "$exercise example" begin
35
- # Run the tests within an anonymous module to prevent definitions from
36
- # one exercise leaking into another.
37
- eval(Module(), :(include(joinpath($temp_path, "runtests.jl"))))
38
- end
39
- finally
40
- # Delete the temporary directory
41
- rm(temp_path, recursive=true)
32
+ try
33
+ # Run the tests
34
+ @testset "$exercise example" begin
35
+ # Run the tests within an anonymous module to prevent definitions from
36
+ # one exercise leaking into another.
37
+ eval(Module(), :(include(joinpath($temp_path, "runtests.jl"))))
42
38
  end
39
+ finally
40
+ # Delete the temporary directory
41
+ rm(temp_path, recursive=true)
43
42
  end
44
43
  end
@@ -3,13 +3,17 @@ sudo: false
3
3
  before_script:
4
4
  - git clone https://github.com/exercism/problem-specifications.git
5
5
  - bin/fetch-configlet
6
- - docker pull rakudo-star:latest
6
+ - docker build -t exercism-rakudo-star .
7
+ - docker run
8
+ --volume $PWD:/exercism
9
+ exercism-rakudo-star perl6 -e
10
+ '.add(‘Example.pm6’).copy(.dir.first({.extension eq ‘pm6’ && .basename ne ‘Example.pm6’}))
11
+ for $*CWD.add(‘exercism/exercises’).dir' # replace stub files with complete solutions from Example.pm6
7
12
  script:
8
13
  - bin/configlet lint .
9
14
  - docker run
10
- --env EXERCISM=1
11
15
  --volume $PWD:/exercism
12
- rakudo-star prove /exercism
16
+ exercism-rakudo-star prove /exercism
13
17
  --exec perl6
14
18
  --recurse
15
19
  --jobs 2
@@ -0,0 +1,4 @@
1
+ FROM rakudo-star:latest
2
+ RUN apt-get update && \
3
+ apt-get install -y make gcc libyaml-dev && \
4
+ zef install YAML::Parser::LibYAML
@@ -1 +1 @@
1
- unit module Accumulate:ver<1>;
1
+ unit module Accumulate:ver<2>;
@@ -1,4 +1,4 @@
1
- unit module Accumulate:ver<1>;
1
+ unit module Accumulate:ver<2>;
2
2
 
3
3
  sub accumulate (@list, $function) is export {
4
4
  my @accumulated;
@@ -2,24 +2,17 @@
2
2
  use v6;
3
3
  use Test;
4
4
  use lib $?FILE.IO.dirname;
5
+ use Accumulate;
6
+ plan 6;
5
7
 
6
- my Str:D $exercise := 'Accumulate';
7
- my Version:D $version = v1;
8
- my Str $module //= $exercise;
9
- plan 7;
8
+ my Version:D $version = v2;
10
9
 
11
- use-ok $module or bail-out;
12
- require ::($module);
13
-
14
- if ::($exercise).^ver !~~ $version {
10
+ if Accumulate.^ver !~~ $version {
15
11
  warn "\nExercise version mismatch. Further tests may fail!"
16
- ~ "\n$exercise is $(::($exercise).^ver.gist). "
17
- ~ "Test is $($version.gist).\n";
18
- bail-out 'Example version must match test version.' if %*ENV<EXERCISM>;
12
+ ~ "\nAccumulate is {Accumulate.^ver.gist}. "
13
+ ~ "Test is {$version.gist}.\n";
19
14
  }
20
15
 
21
- require ::($module) <&accumulate>;
22
-
23
16
  is-deeply accumulate([ ], sub {}),
24
17
  [ ],
25
18
  'test empty';
@@ -38,5 +31,3 @@ is-deeply accumulate(['a', 'b', 'c' ], sub ($inp) { [ accumulate( [1, 2, 3], sub
38
31
  is-deeply accumulate(['the', 'quick', 'brown', 'fox'], sub { @_[0].flip }),
39
32
  ['eht', 'kciuq', 'nworb', 'xof'],
40
33
  'reverse strings';
41
-
42
- INIT { $module = 'Example' if %*ENV<EXERCISM> }