trackler 2.0.5.7 → 2.0.5.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/common/exercises/book-store/canonical-data.json +106 -0
  3. data/common/exercises/phone-number/canonical-data.json +57 -0
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/elm/exercises/accumulate/package.json +1 -1
  6. data/tracks/elm/exercises/allergies/package.json +1 -1
  7. data/tracks/elm/exercises/anagram/package.json +1 -1
  8. data/tracks/elm/exercises/atbash-cipher/package.json +1 -1
  9. data/tracks/elm/exercises/bob/package.json +1 -1
  10. data/tracks/elm/exercises/difference-of-squares/package.json +1 -1
  11. data/tracks/elm/exercises/gigasecond/package.json +1 -1
  12. data/tracks/elm/exercises/grade-school/package.json +1 -1
  13. data/tracks/elm/exercises/hamming/package.json +1 -1
  14. data/tracks/elm/exercises/hello-world/package.json +1 -1
  15. data/tracks/elm/exercises/largest-series-product/package.json +1 -1
  16. data/tracks/elm/exercises/leap/package.json +1 -1
  17. data/tracks/elm/exercises/list-ops/package.json +1 -1
  18. data/tracks/elm/exercises/nucleotide-count/package.json +1 -1
  19. data/tracks/elm/exercises/pangram/package.json +1 -1
  20. data/tracks/elm/exercises/phone-number/package.json +1 -1
  21. data/tracks/elm/exercises/raindrops/package.json +1 -1
  22. data/tracks/elm/exercises/rna-transcription/package.json +1 -1
  23. data/tracks/elm/exercises/robot-simulator/package.json +1 -1
  24. data/tracks/elm/exercises/roman-numerals/package.json +1 -1
  25. data/tracks/elm/exercises/run-length-encoding/package.json +1 -1
  26. data/tracks/elm/exercises/say/package.json +1 -1
  27. data/tracks/elm/exercises/scrabble-score/package.json +1 -1
  28. data/tracks/elm/exercises/series/package.json +1 -1
  29. data/tracks/elm/exercises/space-age/package.json +1 -1
  30. data/tracks/elm/exercises/strain/package.json +1 -1
  31. data/tracks/elm/exercises/sublist/package.json +1 -1
  32. data/tracks/elm/exercises/sum-of-multiples/package.json +1 -1
  33. data/tracks/elm/exercises/triangle/package.json +1 -1
  34. data/tracks/elm/exercises/word-count/package.json +1 -1
  35. data/tracks/go/exercises/house/example.go +58 -28
  36. data/tracks/go/exercises/house/house_test.go +27 -36
  37. data/tracks/go/exercises/sum-of-multiples/example.go +9 -10
  38. data/tracks/go/exercises/sum-of-multiples/sum_of_multiples_test.go +9 -44
  39. data/tracks/pascal/README.md +9 -5
  40. data/tracks/pascal/config.json +123 -8
  41. data/tracks/pascal/docs/ABOUT.md +10 -0
  42. data/tracks/pascal/docs/INSTALLATION.md +18 -0
  43. data/tracks/pascal/docs/LEARNING.md +5 -0
  44. data/tracks/scala/exercises/bowling/build.sbt +2 -2
  45. data/tracks/scala/exercises/bowling/src/test/scala/BowlingSuite.scala +26 -104
  46. data/tracks/scala/exercises/forth/build.sbt +2 -2
  47. data/tracks/scala/exercises/forth/src/main/scala/Forth.scala +6 -0
  48. data/tracks/scala/exercises/nucleotide-count/HINTS.md +12 -12
  49. data/tracks/scala/exercises/nucleotide-count/build.sbt +2 -2
  50. data/tracks/scala/exercises/nucleotide-count/example.scala +4 -4
  51. data/tracks/scala/exercises/nucleotide-count/src/main/scala/DNA.scala +6 -0
  52. metadata +6 -3
  53. data/tracks/scala/exercises/nucleotide-count/src/main/scala/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1670d4b0f4e9733c78b72f304ee7f444006f3893
4
- data.tar.gz: b9c57626d8be12e5ee6a595de9102d227bef8932
3
+ metadata.gz: 5a0e02be1736f9ad6f815b3593e22e0338b90bb5
4
+ data.tar.gz: f6a8a9b2ee6b9afaa21cee8f4fdce3b2962b6db4
5
5
  SHA512:
6
- metadata.gz: 28f6717d05cb7a26a951c4eeec5ed377eebacb92648a9ce97ce7c8887b0b4c2f5aed141b7f807bd80e718089d467399b7a894848dbedca67b7860e781aa48295
7
- data.tar.gz: d6781601a6a2fa0a822f4dbd02870c3607a25e75d38f1af23f78b588af22d8c46aec21328332067dbd54d08d7e4151c50b715a32e8708203f311282247752962
6
+ metadata.gz: cab4b14cee19781307d566eed637b27a43e1dd980f9227881a1b9c066bee293ebabd741850259e437d3c42248bbc758ef97daadb4275cfe7e105c4e751a1b609
7
+ data.tar.gz: 9ccafd1cfc519b3903983fa6e291ca8f0f77afbc2be851144e8edc12416f3280b74e983e501d5beb93d7b63d5d84fafe70480f91a44031e9783c04df26e92762
@@ -0,0 +1,106 @@
1
+ {
2
+ "book-store": {
3
+ "description": [
4
+ "Calculate lowest price for shopping basket only ",
5
+ "containing books from a single series. There is no ",
6
+ "discount advantage for having more than one copy of ",
7
+ "any single book in a grouping."
8
+ ],
9
+ "cases": [
10
+ {
11
+ "description": "A basket containing only a single book.",
12
+ "basket": [1],
13
+ "targetgrouping": [[1]],
14
+ "expected": 8.0
15
+ },
16
+ {
17
+ "description": "A basket containing only two of the same book.",
18
+ "basket": [2, 2],
19
+ "targetgrouping": [[2], [2]],
20
+ "expected": 16.0
21
+ },
22
+ {
23
+ "description": "No charge to carry around an empty basket.",
24
+ "basket": [],
25
+ "targetgrouping": [],
26
+ "expected": 0.0
27
+ },
28
+ {
29
+ "description": "A basket containing only two different books.",
30
+ "basket": [1, 2],
31
+ "targetgrouping": [[1, 2]],
32
+ "expected": 15.2
33
+ },
34
+ {
35
+ "description": "A basket of three different books.",
36
+ "basket": [1, 2, 3],
37
+ "targetgrouping": [[1, 2, 3]],
38
+ "expected": 21.60
39
+ },
40
+ {
41
+ "description": "A basket of four different books.",
42
+ "basket": [1, 2, 3, 4],
43
+ "targetgrouping": [[1, 2, 3, 4]],
44
+ "expected": 25.60
45
+ },
46
+ {
47
+ "description": "A basket of five different books.",
48
+ "basket": [1, 2, 3, 4, 5],
49
+ "targetgrouping": [[1, 2, 3, 4, 5]],
50
+ "expected": 30.00
51
+ },
52
+ {
53
+ "description": [
54
+ "A basket containing eight books consisting of a ",
55
+ "pair each of the first three books plus one copy ",
56
+ "each of the last two books. Please pay careful ",
57
+ "attention to this particular target grouping, it ",
58
+ "is not intuitive, but does grant the largest ",
59
+ "discount."
60
+ ],
61
+ "basket": [1, 1, 2, 2, 3, 3, 4, 5],
62
+ "targetgrouping": [[1, 2, 3, 4], [1, 2, 3, 5]],
63
+ "expected": 51.20
64
+ },
65
+ {
66
+ "description": [
67
+ "A basket containing nine books consisting of a ",
68
+ "pair each of the first four books plus one of ",
69
+ "the last book."
70
+ ],
71
+ "basket": [1, 1, 2, 2, 3, 3, 4, 4, 5],
72
+ "targetgrouping": [[1, 2, 3, 4, 5], [1, 2, 3, 4]],
73
+ "expected": 55.60
74
+ },
75
+ {
76
+ "description": [
77
+ "A basket containing ten books consisting of two ",
78
+ "copies of each book in the series."
79
+ ],
80
+ "basket": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],
81
+ "targetgrouping": [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],
82
+ "expected": 60.00
83
+ },
84
+ {
85
+ "description": [
86
+ "A basket containing eleven books consisting ",
87
+ "of three copies of the first book plus two each ",
88
+ "of the remaining four books in the series."
89
+ ],
90
+ "basket": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1],
91
+ "targetgrouping": [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1]],
92
+ "expected": 68.00
93
+ },
94
+ {
95
+ "description": [
96
+ "A basket containing twelve books consisting of ",
97
+ "three copies of the first two books, plus two ",
98
+ "each of the remaining three books in the series."
99
+ ],
100
+ "basket": [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2],
101
+ "targetgrouping": [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2]],
102
+ "expected": 75.20
103
+ }
104
+ ]
105
+ }
106
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "number": {
3
+ "description": "Cleanup user-entered phone numbers",
4
+ "cases": [
5
+ {
6
+ "description": "cleans the number",
7
+ "phrase": "(123) 456-7890",
8
+ "expected": "1234567890"
9
+ },
10
+ {
11
+ "description": "cleans numbers with dots",
12
+ "phrase": "123.456.7890",
13
+ "expected": "1234567890"
14
+ },
15
+ {
16
+ "description": "cleans numbers with multiple spaces",
17
+ "phrase": "123 456 7890 ",
18
+ "expected": "1234567890"
19
+ },
20
+ {
21
+ "description": "invalid when 9 digits",
22
+ "phrase": "123456789",
23
+ "expected": null
24
+ },
25
+ {
26
+ "description": "invalid when 11 digits",
27
+ "phrase": "21234567890",
28
+ "expected": null
29
+ },
30
+ {
31
+ "description": "valid when 11 digits and starting with 1",
32
+ "phrase": "11234567890",
33
+ "expected": "1234567890"
34
+ },
35
+ {
36
+ "description": "invalid when 12 digits",
37
+ "phrase": "321234567890",
38
+ "expected": null
39
+ },
40
+ {
41
+ "description": "invalid with letters",
42
+ "phrase": "123-abc-7890",
43
+ "expected": null
44
+ },
45
+ {
46
+ "description": "invalid with punctuations",
47
+ "phrase": "123-@:!-7890",
48
+ "expected": null
49
+ },
50
+ {
51
+ "description": "invalid with right number of digits but letters mixed in",
52
+ "phrase": "1a2b3c4d5e6f7g8h9i0j",
53
+ "expected": null
54
+ }
55
+ ]
56
+ }
57
+ }
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.5.7"
2
+ VERSION = "2.0.5.8"
3
3
  end
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "description": "Excercism/Elm",
2
+ "description": "Exercism/Elm",
3
3
  "repository": "https://github.com/exercism/xelm.git",
4
4
  "license": "MIT",
5
5
  "scripts": {
@@ -1,39 +1,69 @@
1
1
  package house
2
2
 
3
- func Embed(relPhrase, nounPhrase string) string {
4
- return relPhrase + " " + nounPhrase
3
+ const testVersion = 1
4
+
5
+ var songLines = []string{
6
+ "the horse and the hound and the horn\nthat belonged to",
7
+ "the farmer sowing his corn\nthat kept",
8
+ "the rooster that crowed in the morn\nthat woke",
9
+ "the priest all shaven and shorn\nthat married",
10
+ "the man all tattered and torn\nthat kissed",
11
+ "the maiden all forlorn\nthat milked",
12
+ "the cow with the crumpled horn\nthat tossed",
13
+ "the dog\nthat worried",
14
+ "the cat\nthat killed",
15
+ "the rat\nthat ate",
16
+ "the malt\nthat lay in",
5
17
  }
6
18
 
7
- func Verse(subject string, relPhrases []string, nounPhrase string) string {
8
- return subject + " " + recurse(relPhrases, nounPhrase)
19
+ // Recursive Solution
20
+
21
+ func Verse(v int) (verse string) {
22
+ v--
23
+ i := len(songLines) - v
24
+ verse += buildVerse(songLines[i:], "This is ")
25
+ verse += "the house that Jack built."
26
+ return
9
27
  }
10
28
 
11
- func recurse(relPhrases []string, nounPhrase string) string {
12
- if len(relPhrases) == 0 {
13
- return nounPhrase
29
+ func buildVerse(songLines []string, cur string) string {
30
+ if len(songLines) == 0 {
31
+ return cur
14
32
  }
15
- return Embed(relPhrases[0], recurse(relPhrases[1:], nounPhrase))
33
+ cur += songLines[0]
34
+ cur += " "
35
+ return buildVerse(songLines[1:], cur)
16
36
  }
17
37
 
18
- func Song() string {
19
- relPhrases := []string{
20
- "the horse and the hound and the horn\nthat belonged to",
21
- "the farmer sowing his corn\nthat kept",
22
- "the rooster that crowed in the morn\nthat woke",
23
- "the priest all shaven and shorn\nthat married",
24
- "the man all tattered and torn\nthat kissed",
25
- "the maiden all forlorn\nthat milked",
26
- "the cow with the crumpled horn\nthat tossed",
27
- "the dog\nthat worried",
28
- "the cat\nthat killed",
29
- "the rat\nthat ate",
30
- "the malt\nthat lay in",
31
- }
32
- subject := "This is"
33
- nounPhrase := "the house that Jack built."
34
- s := subject + " " + nounPhrase
35
- for c := len(relPhrases) - 1; c >= 0; c-- {
36
- s += "\n\n" + Verse(subject, relPhrases[c:], nounPhrase)
38
+ func Song() (song string) {
39
+ for i := 0; i <= len(songLines); i++ {
40
+ song += Verse(i + 1)
41
+ if i < len(songLines) {
42
+ song += "\n\n"
43
+ }
37
44
  }
38
- return s
45
+ return
39
46
  }
47
+
48
+ // Iterative Solution
49
+
50
+ // func Verse(v int) (verse string) {
51
+ // v--
52
+ // verse += "This is "
53
+ // verse += strings.Join(songLines[len(songLines)-v:], " ")
54
+ // if v > 0 {
55
+ // verse += " "
56
+ // }
57
+ // verse += "the house that Jack built."
58
+ // return
59
+ // }
60
+ //
61
+ // func Song() (song string) {
62
+ // for i := 0; i <= len(songLines); i++ {
63
+ // song += Verse(i + 1)
64
+ // if i < len(songLines) {
65
+ // song += "\n\n"
66
+ // }
67
+ // }
68
+ // return
69
+ // }
@@ -1,19 +1,12 @@
1
- // Embed places a phrase with another phrase.
2
- //
3
- // func Embed(prefixPhrase, suffixPhrase string) string
4
-
5
- // Verse generates a verse with relative phrases that have a recursive structure.
6
- //
7
- // func Verse(prefixPhrase string, relPhrases []string, suffixPhrase string) string
8
-
9
- // As ever, there are different ways to do this. Try using Embed as a
10
- // subroutine of Verse, and using programmatic recursion to generate the return
11
- // value, reflecting the grammatical recursion of the song.
1
+ // As ever, there are different ways to complete this exercise.
2
+ // Try using using programmatic recursion to generate the verses of the song,
3
+ // thus reflecting the song's grammatical recursion.
12
4
 
13
- // Song generates the full text of "The House That Jack Built". Of course, you
14
- // could return a string literal, but humor us; try using Verse as a subroutine.
5
+ // While recursion isn't always the simplest or most efficient solution to a problem,
6
+ // it's a powerful programming technique nonetheless.
15
7
  //
16
- // func Song() string
8
+ // New to recursion? Here's a quick introduction:
9
+ // https://www.golang-book.com/books/intro/7#section5
17
10
 
18
11
  package house
19
12
 
@@ -22,15 +15,10 @@ import (
22
15
  "testing"
23
16
  )
24
17
 
18
+ const targetTestVersion = 1
19
+
25
20
  var (
26
- s = "This is"
27
- r = []string{
28
- "the cat that broke",
29
- "the vase that was on",
30
- }
31
- p = "the shelf."
32
- last = len(r) - 1
33
- // song copied from readme
21
+ // song copied from README
34
22
  song = `This is the house that Jack built.
35
23
 
36
24
  This is the malt
@@ -120,22 +108,14 @@ that worried the cat
120
108
  that killed the rat
121
109
  that ate the malt
122
110
  that lay in the house that Jack built.`
123
- )
124
111
 
125
- func TestEmbed(t *testing.T) {
126
- l := r[last]
127
- want := l + " " + p
128
- if e := Embed(l, p); e != want {
129
- t.Fatalf("Embed(%q, %q) = %q, want %q.", l, p, e, want)
130
- }
131
- }
112
+ verses = strings.Split(song, "\n\n")
113
+ )
132
114
 
133
115
  func TestVerse(t *testing.T) {
134
- for i := len(r); i >= 0; i-- {
135
- ri := r[i:]
136
- want := s + " " + strings.Join(append(ri, p), " ")
137
- if v := Verse(s, ri, p); v != want {
138
- t.Fatalf("Verse(%q, %q, %q) = %q, want %q.", s, ri, p, v, want)
116
+ for v := 0; v < len(verses); v++ {
117
+ if ret := Verse(v + 1); ret != verses[v] {
118
+ t.Fatalf("Verse(%d) =\n%q\n want:\n%q", v+1, ret, verses[v])
139
119
  }
140
120
  }
141
121
  }
@@ -146,6 +126,11 @@ func TestSong(t *testing.T) {
146
126
  return
147
127
  }
148
128
  // a little help in locating an error
129
+ gotStanzas := len(strings.Split(s, "\n\n"))
130
+ wantStanzas := len(verses)
131
+ if wantStanzas != gotStanzas {
132
+ t.Fatalf("Song() has %d verse(s), want %d verses", gotStanzas, wantStanzas)
133
+ }
149
134
  got := strings.Split(s, "\n")
150
135
  want := strings.Split(song, "\n")
151
136
  var g, w string
@@ -159,5 +144,11 @@ func TestSong(t *testing.T) {
159
144
  break
160
145
  }
161
146
  }
162
- t.Fatalf("Song() line %d = %q, want %q", i+1, g, w)
147
+ t.Fatalf("Song() line %d =\n%q\n want \n%q", i+1, g, w)
148
+ }
149
+
150
+ func TestTestVersion(t *testing.T) {
151
+ if testVersion != targetTestVersion {
152
+ t.Errorf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
153
+ }
163
154
  }