trackler 2.1.0.0 → 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/connect/description.md +2 -1
  3. data/common/exercises/crypto-square/canonical-data.json +2 -2
  4. data/common/exercises/two-bucket/canonical-data.json +27 -1
  5. data/lib/trackler/version.rb +1 -1
  6. data/tracks/c/exercises/perfect-numbers/src/example.c +8 -4
  7. data/tracks/clojure/config.json +5 -0
  8. data/tracks/clojure/exercises/secret-handshake/project.clj +4 -0
  9. data/tracks/clojure/exercises/secret-handshake/src/example.clj +19 -0
  10. data/tracks/clojure/exercises/secret-handshake/test/secret_handshake_test.clj +55 -0
  11. data/tracks/cpp/.travis.yml +4 -3
  12. data/tracks/cpp/README.md +1 -1
  13. data/tracks/cpp/config.json +171 -67
  14. data/tracks/cpp/docs/ABOUT.md +2 -2
  15. data/tracks/cpp/docs/INSTALLATION.md +22 -28
  16. data/tracks/cpp/docs/TESTS.md +1 -1
  17. data/tracks/cpp/exercises/anagram/CMakeLists.txt +2 -9
  18. data/tracks/cpp/exercises/beer-song/CMakeLists.txt +2 -9
  19. data/tracks/cpp/exercises/binary/CMakeLists.txt +2 -9
  20. data/tracks/cpp/exercises/bob/CMakeLists.txt +2 -9
  21. data/tracks/cpp/exercises/clock/CMakeLists.txt +2 -9
  22. data/tracks/cpp/exercises/clock/clock_test.cpp +188 -64
  23. data/tracks/cpp/exercises/clock/example.cpp +17 -12
  24. data/tracks/cpp/exercises/clock/example.h +1 -0
  25. data/tracks/cpp/exercises/crypto-square/CMakeLists.txt +2 -9
  26. data/tracks/cpp/exercises/difference-of-squares/CMakeLists.txt +2 -9
  27. data/tracks/cpp/exercises/etl/CMakeLists.txt +2 -9
  28. data/tracks/cpp/exercises/etl/etl_test.cpp +5 -5
  29. data/tracks/cpp/exercises/food-chain/CMakeLists.txt +2 -9
  30. data/tracks/cpp/exercises/gigasecond/CMakeLists.txt +2 -9
  31. data/tracks/cpp/exercises/gigasecond/example.cpp +2 -6
  32. data/tracks/cpp/exercises/gigasecond/example.h +2 -2
  33. data/tracks/cpp/exercises/gigasecond/gigasecond_test.cpp +26 -8
  34. data/tracks/cpp/exercises/grade-school/CMakeLists.txt +2 -9
  35. data/tracks/cpp/exercises/grade-school/grade_school_test.cpp +5 -6
  36. data/tracks/cpp/exercises/grains/CMakeLists.txt +2 -9
  37. data/tracks/cpp/exercises/hamming/CMakeLists.txt +2 -9
  38. data/tracks/cpp/exercises/hello-world/CMakeLists.txt +2 -9
  39. data/tracks/cpp/exercises/hexadecimal/CMakeLists.txt +2 -9
  40. data/tracks/cpp/exercises/leap/CMakeLists.txt +2 -9
  41. data/tracks/cpp/exercises/meetup/CMakeLists.txt +2 -9
  42. data/tracks/cpp/exercises/meetup/meetup_test.cpp +1 -1
  43. data/tracks/cpp/exercises/nth-prime/CMakeLists.txt +2 -9
  44. data/tracks/cpp/exercises/nucleotide-count/CMakeLists.txt +2 -9
  45. data/tracks/cpp/exercises/nucleotide-count/nucleotide_count_test.cpp +3 -4
  46. data/tracks/cpp/exercises/phone-number/CMakeLists.txt +2 -9
  47. data/tracks/cpp/exercises/prime-factors/CMakeLists.txt +2 -9
  48. data/tracks/cpp/exercises/queen-attack/CMakeLists.txt +2 -9
  49. data/tracks/cpp/exercises/raindrops/CMakeLists.txt +2 -9
  50. data/tracks/cpp/exercises/rna-transcription/CMakeLists.txt +2 -9
  51. data/tracks/cpp/exercises/robot-name/CMakeLists.txt +2 -9
  52. data/tracks/cpp/exercises/roman-numerals/CMakeLists.txt +2 -9
  53. data/tracks/cpp/exercises/say/CMakeLists.txt +2 -9
  54. data/tracks/cpp/exercises/scrabble-score/CMakeLists.txt +2 -9
  55. data/tracks/cpp/exercises/series/CMakeLists.txt +2 -9
  56. data/tracks/cpp/exercises/series/series_test.cpp +11 -11
  57. data/tracks/cpp/exercises/sieve/CMakeLists.txt +2 -9
  58. data/tracks/cpp/exercises/space-age/CMakeLists.txt +2 -9
  59. data/tracks/cpp/exercises/sum-of-multiples/CMakeLists.txt +2 -9
  60. data/tracks/cpp/exercises/triangle/CMakeLists.txt +2 -9
  61. data/tracks/cpp/exercises/trinary/CMakeLists.txt +2 -9
  62. data/tracks/cpp/exercises/word-count/CMakeLists.txt +2 -9
  63. data/tracks/cpp/exercises/word-count/word_count_test.cpp +14 -15
  64. data/tracks/go/README.md +27 -13
  65. data/tracks/go/config.json +1 -0
  66. data/tracks/go/exercises/connect/.meta/gen.go +1 -3
  67. data/tracks/go/exercises/connect/cases_test.go +2 -1
  68. data/tracks/go/exercises/custom-set/.meta/gen.go +122 -101
  69. data/tracks/go/exercises/custom-set/cases_test.go +13 -4
  70. data/tracks/go/exercises/custom-set/custom_set_test.go +2 -2
  71. data/tracks/go/exercises/hamming/.meta/gen.go +1 -3
  72. data/tracks/go/exercises/hamming/cases_test.go +7 -1
  73. data/tracks/go/exercises/hamming/example.go +1 -1
  74. data/tracks/go/exercises/hamming/hamming_test.go +1 -1
  75. data/tracks/go/exercises/hello-world/{hello_example_test.go → example_helloworld_test.go} +0 -0
  76. data/tracks/go/exercises/house/house_test.go +8 -8
  77. data/tracks/go/exercises/meetup/.meta/gen.go +1 -3
  78. data/tracks/go/exercises/meetup/cases_test.go +2 -1
  79. data/tracks/go/exercises/palindrome-products/example.go +1 -1
  80. data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +1 -1
  81. data/tracks/go/exercises/pascals-triangle/pascals_triangle_test.go +24 -4
  82. data/tracks/go/exercises/rna-transcription/.meta/gen.go +1 -3
  83. data/tracks/go/exercises/rna-transcription/cases_test.go +2 -1
  84. data/tracks/go/exercises/roman-numerals/.meta/gen.go +1 -3
  85. data/tracks/go/exercises/roman-numerals/cases_test.go +2 -1
  86. data/tracks/go/exercises/roman-numerals/example.go +1 -1
  87. data/tracks/go/exercises/transpose/.meta/gen.go +1 -3
  88. data/tracks/go/exercises/transpose/cases_test.go +2 -1
  89. data/tracks/go/exercises/transpose/transpose_test.go +5 -0
  90. data/tracks/go/exercises/word-count/.meta/gen.go +1 -3
  91. data/tracks/go/exercises/word-count/cases_test.go +2 -1
  92. data/tracks/go/gen/gen.go +3 -2
  93. data/tracks/java/config.json +5 -0
  94. data/tracks/java/exercises/saddle-points/build.gradle +17 -0
  95. data/tracks/java/exercises/saddle-points/src/example/java/Matrix.java +44 -0
  96. data/tracks/java/exercises/saddle-points/src/example/java/MatrixCoordinate.java +31 -0
  97. data/tracks/java/exercises/saddle-points/src/main/java/Matrix.java +5 -0
  98. data/tracks/java/exercises/saddle-points/src/main/java/MatrixCoordinate.java +31 -0
  99. data/tracks/java/exercises/saddle-points/src/test/java/MatrixTest.java +82 -0
  100. data/tracks/java/exercises/settings.gradle +1 -0
  101. data/tracks/javascript/.travis.yml +3 -1
  102. data/tracks/javascript/Makefile +2 -8
  103. data/tracks/javascript/SETUP.md +1 -2
  104. data/tracks/javascript/docs/INSTALLATION.md +3 -4
  105. data/tracks/javascript/docs/TESTS.md +14 -26
  106. data/tracks/javascript/exercises/hamming/example.js +7 -11
  107. data/tracks/javascript/exercises/hello-world/HINTS.md +3 -3
  108. data/tracks/javascript/exercises/robot-simulator/example.js +72 -73
  109. data/tracks/perl6/config.json +5 -0
  110. data/tracks/perl6/exercises/clock/Clock.pm6 +4 -0
  111. data/tracks/perl6/exercises/clock/Example.pm6 +12 -0
  112. data/tracks/perl6/exercises/clock/clock.t +534 -0
  113. data/tracks/perl6/exercises/clock/example.yaml +16 -0
  114. data/tracks/perl6/exercises/robot-name/Example.pm +11 -4
  115. data/tracks/php/exercises/hello-world/hello-world.php +1 -1
  116. data/tracks/php/exercises/hello-world/hello-world_test.php +1 -11
  117. data/tracks/php/exercises/robot-name/robot-name_test.php +1 -0
  118. data/tracks/purescript/config.json +7 -0
  119. data/tracks/purescript/exercises/largest-series-product/bower.json +16 -0
  120. data/tracks/purescript/exercises/largest-series-product/examples/src/LargestSeriesProduct.purs +31 -0
  121. data/tracks/purescript/exercises/largest-series-product/src/LargestSeriesProduct.purs +3 -0
  122. data/tracks/purescript/exercises/largest-series-product/test/Main.purs +73 -0
  123. data/tracks/python/exercises/sublist/sublist_test.py +94 -55
  124. data/tracks/ruby/README.md +38 -25
  125. data/tracks/ruby/exercises/hamming/example.tt +6 -4
  126. data/tracks/ruby/exercises/hamming/hamming_test.rb +4 -5
  127. data/tracks/ruby/exercises/linked-list/linked_list_test.rb +16 -0
  128. data/tracks/ruby/exercises/luhn/luhn_test.rb +5 -5
  129. data/tracks/ruby/exercises/ocr-numbers/.meta/.version +1 -0
  130. data/tracks/ruby/exercises/ocr-numbers/example.rb +42 -61
  131. data/tracks/ruby/exercises/ocr-numbers/example.tt +21 -0
  132. data/tracks/ruby/exercises/ocr-numbers/ocr_numbers_test.rb +63 -138
  133. data/tracks/ruby/lib/generator/exercise_cases.rb +43 -0
  134. data/tracks/ruby/lib/generator/underscore.rb +9 -0
  135. data/tracks/ruby/lib/hamming_cases.rb +9 -14
  136. data/tracks/ruby/lib/luhn_cases.rb +2 -18
  137. data/tracks/ruby/lib/ocr_numbers_cases.rb +20 -0
  138. data/tracks/ruby/lib/pig_latin_cases.rb +2 -12
  139. data/tracks/ruby/test/generator/underscore_test.rb +23 -0
  140. data/tracks/scala/config.json +316 -316
  141. metadata +26 -10
  142. data/tracks/cpp/exercises/etl/require_equal_containers.h +0 -88
  143. data/tracks/cpp/exercises/grade-school/require_equal_containers.h +0 -88
  144. data/tracks/cpp/exercises/nucleotide-count/require_equal_containers.h +0 -88
  145. data/tracks/cpp/exercises/series/require_equal_containers.h +0 -88
  146. data/tracks/cpp/exercises/word-count/require_equal_containers.h +0 -88
  147. data/tracks/javascript/exercises/acronym/package.json +0 -12
  148. data/tracks/javascript/package.json +0 -12
@@ -1,7 +1,8 @@
1
1
  package connect
2
2
 
3
3
  // Source: exercism/x-common
4
- // Commit: 038124b triangle: Add JSON test data
4
+ // Commit: 327db7f connect: Fix canonical-data.json formatting
5
+ // x-common version: 1.0.0
5
6
 
6
7
  var testCases = []struct {
7
8
  description string
@@ -3,6 +3,7 @@
3
3
  package main
4
4
 
5
5
  import (
6
+ "errors"
6
7
  "log"
7
8
  "strconv"
8
9
  "text/template"
@@ -12,8 +13,10 @@ import (
12
13
 
13
14
  func main() {
14
15
  t := template.New("").Funcs(template.FuncMap{
15
- "str": str,
16
- "strs": strSlice,
16
+ "str": str,
17
+ "strs": strSlice,
18
+ "istrs": istrSlice,
19
+ "dict": dict,
17
20
  })
18
21
  t, err := t.Parse(tmpl)
19
22
  if err != nil {
@@ -25,6 +28,7 @@ func main() {
25
28
  }
26
29
  }
27
30
 
31
+ // str converts an integer 1..26 to a letter 'a'..'z'.
28
32
  func str(n int) string {
29
33
  if n >= 1 && n <= 26 {
30
34
  return string('a' - 1 + n)
@@ -32,6 +36,7 @@ func str(n int) string {
32
36
  return strconv.Itoa(n)
33
37
  }
34
38
 
39
+ // strSlice converts a slice of int to a slice of string.
35
40
  func strSlice(ns []int) []string {
36
41
  s := make([]string, len(ns))
37
42
  for i, n := range ns {
@@ -40,66 +45,76 @@ func strSlice(ns []int) []string {
40
45
  return s
41
46
  }
42
47
 
43
- // The JSON structure we expect to be able to unmarshal into
44
- type js struct {
45
- IsEmpty unaryBool `json:"empty"`
46
- Contains eleBool
47
- Subset binaryBool
48
- Disjoint binaryBool
49
- Equal binaryBool
50
- Add eleOp
51
- Intersection binaryOp
52
- Difference binaryOp
53
- Union binaryOp
48
+ // istrSlice converts a slice of interface{} values whose
49
+ // underlying members should be float64(JSON decoded integers)
50
+ // to a slice of string.
51
+ func istrSlice(ns []interface{}) []string {
52
+ s := make([]string, len(ns))
53
+ for i, n := range ns {
54
+ if fn, ok := n.(float64); ok {
55
+ s[i] = str(int(fn))
56
+ }
57
+ }
58
+ return s
54
59
  }
55
60
 
56
- type unaryBool struct {
57
- Description string
58
- Cases []struct {
59
- Description string
60
- Set []int
61
- Expected bool
61
+ // dict sets up and returns a map for pairs of items given;
62
+ // it is used in order to pass multiple parameters in a template call.
63
+ func dict(values ...interface{}) (map[string]interface{}, error) {
64
+ if len(values)%2 != 0 {
65
+ return nil, errors.New("invalid dict call: odd number of values given")
66
+ }
67
+ valueMap := make(map[string]interface{}, len(values)/2)
68
+ for i := 0; i < len(values); i += 2 {
69
+ key, ok := values[i].(string)
70
+ if !ok {
71
+ return nil, errors.New("Expected string for dict key")
72
+ }
73
+ valueMap[key] = values[i+1]
62
74
  }
75
+ return valueMap, nil
63
76
  }
64
77
 
65
- type eleBool struct {
66
- Description string
67
- Cases []struct {
68
- Description string
69
- Set []int
70
- Element int
71
- Expected bool
72
- }
78
+ // The JSON structure we expect to be able to unmarshal into
79
+ type js struct {
80
+ Groups TestGroups `json:"Cases"`
73
81
  }
74
82
 
75
- type binaryBool struct {
83
+ type TestGroups []struct {
76
84
  Description string
77
- Cases []struct {
78
- Description string
79
- Set1 []int
80
- Set2 []int
81
- Expected bool
82
- }
85
+ Cases []OneCase
83
86
  }
84
87
 
85
- type eleOp struct {
88
+ type OneCase struct {
86
89
  Description string
87
- Cases []struct {
88
- Description string
89
- Set []int
90
- Element int
91
- Expected []int
92
- }
90
+ Property string
91
+ Set []int // "empty"/"contains"/"add" cases
92
+ Set1 []int // "subset"/"disjoint"/"equal"/"difference"/"intersection"/"union" cases
93
+ Set2 []int // "subset"/"disjoint"/"equal"/"difference"/"intersection"/"union" cases
94
+ Element int // "contains"/"add" cases
95
+ Expected interface{} // bool or []int
93
96
  }
94
97
 
95
- type binaryOp struct {
96
- Description string
97
- Cases []struct {
98
- Description string
99
- Set1 []int
100
- Set2 []int
101
- Expected []int
98
+ func (c OneCase) PropertyMatch(property string) bool { return c.Property == property }
99
+
100
+ // GroupComment looks in each of the test case groups to find the
101
+ // group for which every test case has the .Property matching given property;
102
+ // it returns the .Description field for the matching property group,
103
+ // or a 'Note: ...' if no test group consistently matches given property.
104
+ func (groups TestGroups) GroupComment(property string) string {
105
+ for _, group := range groups {
106
+ propertyGroupMatch := true
107
+ for _, testcase := range group.Cases {
108
+ if !testcase.PropertyMatch(property) {
109
+ propertyGroupMatch = false
110
+ break
111
+ }
112
+ }
113
+ if propertyGroupMatch {
114
+ return group.Description
115
+ }
102
116
  }
117
+ return "Note: Apparent inconsistent use of \"property\": \"" + property + "\" within test case group!"
103
118
  }
104
119
 
105
120
  // template applied to above data structure generates the Go test cases
@@ -110,72 +125,78 @@ type binaryOp struct {
110
125
  var tmpl = `
111
126
  {{/* nested templates for repeated stuff */}}
112
127
 
113
- {{define "binaryBool"}} = []binBoolCase{
114
- {{range .}}{ // {{.Description}}
115
- {{strs .Set1 | printf "%#v"}},
116
- {{strs .Set2 | printf "%#v"}},
128
+ {{define "unaryBool"}}{{$property := .PropertyType}}{{with .Groups}}
129
+ // {{ .GroupComment $property}}
130
+ var {{$property}}Cases = []unaryBoolCase{ {{range .}} {{range .Cases}}
131
+ {{if .PropertyMatch $property}} { // {{.Description}}
132
+ {{strs .Set | printf "%#v"}},
117
133
  {{.Expected}},
118
134
  },
119
- {{end}}}{{end}}
120
-
121
- {{define "binaryOp"}} = []binOpCase{
122
- {{range .}}{ // {{.Description}}
123
- {{strs .Set1 | printf "%#v"}},
124
- {{strs .Set2 | printf "%#v"}},
125
- {{strs .Expected | printf "%#v"}},
126
- },
127
- {{end}}}{{end}}
135
+ {{- end}}{{end}}{{end}}
136
+ }
137
+ {{end}}{{end}}
128
138
 
129
- {{define "eleOp"}} = []eleOpCase{
130
- {{range .}}{ // {{.Description}}
139
+ {{define "eleBool"}}{{$property := .PropertyType}}{{with .Groups}}
140
+ // {{ .GroupComment $property}}
141
+ var {{$property}}Cases = []eleBoolCase{ {{range .}} {{range .Cases}}
142
+ {{if .PropertyMatch $property}} { // {{.Description}}
131
143
  {{strs .Set | printf "%#v"}},
132
144
  {{str .Element | printf "%q"}},
133
- {{strs .Expected | printf "%#v"}},
134
- },
135
- {{end}}}{{end}}
136
-
137
- {{/* begin template body */}}
138
- package stringset
139
-
140
- // Source: {{.Ori}}
141
- {{if .Commit}}// Commit: {{.Commit}}
142
- {{end}}
143
-
144
- // {{.J.IsEmpty.Description}}
145
- var emptyCases = []unaryBoolCase{
146
- {{range .J.IsEmpty.Cases}}{ // {{.Description}}
147
- {{strs .Set | printf "%#v"}},
148
145
  {{.Expected}},
149
146
  },
150
- {{end}}}
147
+ {{- end}}{{end}}{{end}}
148
+ }
149
+ {{end}}{{end}}
151
150
 
152
- // {{.J.Contains.Description}}
153
- var hasCases = []eleBoolCase{
154
- {{range .J.Contains.Cases}}{ // {{.Description}}
151
+ {{define "eleOp"}}{{$property := .PropertyType}}{{with .Groups}}
152
+ // {{ .GroupComment $property}}
153
+ var {{$property}}Cases = []eleOpCase{ {{range .}} {{range .Cases}}
154
+ {{if .PropertyMatch $property}} { // {{.Description}}
155
155
  {{strs .Set | printf "%#v"}},
156
156
  {{str .Element | printf "%q"}},
157
- {{.Expected}},
157
+ {{istrs .Expected | printf "%#v"}},
158
158
  },
159
- {{end}}}
160
-
161
- // {{.J.Subset.Description}}
162
- var subsetCases{{template "binaryBool" .J.Subset.Cases}}
163
-
164
- // {{.J.Disjoint.Description}}
165
- var disjointCases{{template "binaryBool" .J.Disjoint.Cases}}
166
-
167
- // {{.J.Equal.Description}}
168
- var eqCases{{template "binaryBool" .J.Equal.Cases}}
159
+ {{- end}}{{end}}{{end}}
160
+ }
161
+ {{end}}{{end}}
169
162
 
170
- // {{.J.Add.Description}}
171
- var addCases{{template "eleOp" .J.Add.Cases}}
163
+ {{define "binaryBool"}}{{$property := .PropertyType}}{{with .Groups}}
164
+ // {{ .GroupComment $property}}
165
+ var {{$property}}Cases = []binBoolCase{ {{range .}} {{range .Cases}}
166
+ {{if .PropertyMatch $property}} { // {{.Description}}
167
+ {{strs .Set1 | printf "%#v"}},
168
+ {{strs .Set2 | printf "%#v"}},
169
+ {{.Expected}},
170
+ },
171
+ {{- end}}{{end}}{{end}}
172
+ }
173
+ {{end}}{{end}}
172
174
 
173
- // {{.J.Intersection.Description}}
174
- var intersectionCases{{template "binaryOp" .J.Intersection.Cases}}
175
+ {{define "binaryOp"}}{{$property := .PropertyType}}{{with .Groups}}
176
+ // {{ .GroupComment $property}}
177
+ var {{$property}}Cases = []binOpCase{ {{range .}} {{range .Cases}}
178
+ {{if .PropertyMatch $property}} { // {{.Description}}
179
+ {{strs .Set1 | printf "%#v"}},
180
+ {{strs .Set2 | printf "%#v"}},
181
+ {{istrs .Expected | printf "%#v"}},
182
+ },
183
+ {{- end}}{{end}}{{end}}
184
+ }
185
+ {{end}}{{end}}
175
186
 
176
- // {{.J.Difference.Description}}
177
- var differenceCases{{template "binaryOp" .J.Difference.Cases}}
187
+ {{/* begin template body */}}
188
+ package stringset
178
189
 
179
- // {{.J.Union.Description}}
180
- var unionCases{{template "binaryOp" .J.Union.Cases}}
190
+ {{.Header}}
191
+
192
+ {{/* These template calls utilize a dict helper function in order to pass multiple parameters. */}}
193
+ {{template "unaryBool" dict "PropertyType" "empty" "Groups" .J.Groups}}
194
+ {{template "eleBool" dict "PropertyType" "contains" "Groups" .J.Groups}}
195
+ {{template "binaryBool" dict "PropertyType" "subset" "Groups" .J.Groups}}
196
+ {{template "binaryBool" dict "PropertyType" "disjoint" "Groups" .J.Groups}}
197
+ {{template "binaryBool" dict "PropertyType" "equal" "Groups" .J.Groups}}
198
+ {{template "eleOp" dict "PropertyType" "add" "Groups" .J.Groups}}
199
+ {{template "binaryOp" dict "PropertyType" "intersection" "Groups" .J.Groups}}
200
+ {{template "binaryOp" dict "PropertyType" "difference" "Groups" .J.Groups}}
201
+ {{template "binaryOp" dict "PropertyType" "union" "Groups" .J.Groups}}
181
202
  `
@@ -1,7 +1,8 @@
1
1
  package stringset
2
2
 
3
3
  // Source: exercism/x-common
4
- // Commit: cda8f98 Create new exercises structure
4
+ // Commit: 4527635 custom-set: Fix description to match property name
5
+ // x-common version: 1.0.1
5
6
 
6
7
  // Returns true if the set contains no elements
7
8
  var emptyCases = []unaryBoolCase{
@@ -16,7 +17,8 @@ var emptyCases = []unaryBoolCase{
16
17
  }
17
18
 
18
19
  // Sets can report if they contain an element
19
- var hasCases = []eleBoolCase{
20
+ var containsCases = []eleBoolCase{
21
+
20
22
  { // nothing is contained in an empty set
21
23
  []string{},
22
24
  "a",
@@ -36,6 +38,7 @@ var hasCases = []eleBoolCase{
36
38
 
37
39
  // A set is a subset if all of its elements are contained in the other set
38
40
  var subsetCases = []binBoolCase{
41
+
39
42
  { // empty set is a subset of another empty set
40
43
  []string{},
41
44
  []string{},
@@ -70,6 +73,7 @@ var subsetCases = []binBoolCase{
70
73
 
71
74
  // Sets are disjoint if they share no elements
72
75
  var disjointCases = []binBoolCase{
76
+
73
77
  { // the empty set is disjoint with itself
74
78
  []string{},
75
79
  []string{},
@@ -98,7 +102,8 @@ var disjointCases = []binBoolCase{
98
102
  }
99
103
 
100
104
  // Sets with the same elements are equal
101
- var eqCases = []binBoolCase{
105
+ var equalCases = []binBoolCase{
106
+
102
107
  { // empty sets are equal
103
108
  []string{},
104
109
  []string{},
@@ -128,6 +133,7 @@ var eqCases = []binBoolCase{
128
133
 
129
134
  // Unique elements can be added to a set
130
135
  var addCases = []eleOpCase{
136
+
131
137
  { // add to empty set
132
138
  []string{},
133
139
  "c",
@@ -145,8 +151,9 @@ var addCases = []eleOpCase{
145
151
  },
146
152
  }
147
153
 
148
- // Intersect returns a set of all shared elements
154
+ // Intersection returns a set of all shared elements
149
155
  var intersectionCases = []binOpCase{
156
+
150
157
  { // intersection of two empty sets is an empty set
151
158
  []string{},
152
159
  []string{},
@@ -176,6 +183,7 @@ var intersectionCases = []binOpCase{
176
183
 
177
184
  // Difference (or Complement) of a set is a set of all elements that are only in the first set
178
185
  var differenceCases = []binOpCase{
186
+
179
187
  { // difference of two empty sets is an empty set
180
188
  []string{},
181
189
  []string{},
@@ -200,6 +208,7 @@ var differenceCases = []binOpCase{
200
208
 
201
209
  // Union returns a set of all elements in either set
202
210
  var unionCases = []binOpCase{
211
+
203
212
  { // union of empty sets is an empty set
204
213
  []string{},
205
214
  []string{},
@@ -122,7 +122,7 @@ func TestIsEmpty(t *testing.T) {
122
122
  }
123
123
 
124
124
  func TestHas(t *testing.T) {
125
- for _, tc := range hasCases {
125
+ for _, tc := range containsCases {
126
126
  s := NewFromSlice(tc.set)
127
127
  got := s.Has(tc.ele)
128
128
  if got != tc.want {
@@ -152,7 +152,7 @@ func TestDisjoint(t *testing.T) {
152
152
  }
153
153
 
154
154
  func TestEqual(t *testing.T) {
155
- testBinBool("Equal", Equal, eqCases, t)
155
+ testBinBool("Equal", Equal, equalCases, t)
156
156
  }
157
157
 
158
158
  func TestAdd(t *testing.T) {
@@ -33,9 +33,7 @@ type js struct {
33
33
  // template applied to above data structure generates the Go test cases
34
34
  var tmpl = `package hamming
35
35
 
36
- // Source: {{.Ori}}
37
- {{if .Commit}}// Commit: {{.Commit}}
38
- {{end}}
36
+ {{.Header}}
39
37
 
40
38
  var testCases = []struct {
41
39
  s1 string
@@ -1,7 +1,8 @@
1
1
  package hamming
2
2
 
3
3
  // Source: exercism/x-common
4
- // Commit: c84e435 Merge pull request #51 from soniakeys/master
4
+ // Commit: bb56dc7 Fix canonical-data.json formatting
5
+ // x-common version: 1.0.0
5
6
 
6
7
  var testCases = []struct {
7
8
  s1 string
@@ -53,6 +54,11 @@ var testCases = []struct {
53
54
  "AGA",
54
55
  1,
55
56
  },
57
+ { // same nucleotides in different positions
58
+ "TAG",
59
+ "GAT",
60
+ 2,
61
+ },
56
62
  { // large distance
57
63
  "GATACA",
58
64
  "GCATAA",
@@ -2,7 +2,7 @@ package hamming
2
2
 
3
3
  import "errors"
4
4
 
5
- const testVersion = 5
5
+ const testVersion = 6
6
6
 
7
7
  func Distance(a, b string) (d int, err error) {
8
8
  if len(b) != len(a) {
@@ -2,7 +2,7 @@ package hamming
2
2
 
3
3
  import "testing"
4
4
 
5
- const targetTestVersion = 5
5
+ const targetTestVersion = 6
6
6
 
7
7
  func TestTestVersion(t *testing.T) {
8
8
  if testVersion != targetTestVersion {