trackler 2.1.0.19 → 2.1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/bin/verify-metadata +1 -1
  3. data/lib/trackler/implementation.rb +1 -9
  4. data/lib/trackler/version.rb +1 -1
  5. data/tracks/go/exercises/tree-building/tree_test.go +1 -1
  6. data/tracks/haskell/.travis.yml +1 -0
  7. data/tracks/haskell/bin/test-example +17 -5
  8. data/tracks/haskell/bin/test-stub +14 -3
  9. data/tracks/java/exercises/build.gradle +3 -3
  10. data/tracks/java/exercises/difference-of-squares/src/test/java/DifferenceOfSquaresCalculatorTest.java +1 -1
  11. data/tracks/javascript/config.json +21 -1
  12. data/tracks/javascript/exercises/alphametics/alphametics.spec.js +95 -0
  13. data/tracks/javascript/exercises/alphametics/example.js +107 -0
  14. data/tracks/perl6/bin/README.md +5 -3
  15. data/tracks/perl6/docs/LEARNING.md +7 -0
  16. data/tracks/r/exercises/anagram/test_anagram.R +33 -52
  17. data/tracks/r/exercises/bob/test_bob.R +52 -73
  18. data/tracks/r/exercises/difference-of-squares/test_difference-of-squares.R +1 -2
  19. data/tracks/r/exercises/grains/test_grains.R +1 -1
  20. data/tracks/r/exercises/hamming/test_hamming.R +1 -1
  21. data/tracks/r/exercises/hello-world/test_hello-world.R +1 -1
  22. data/tracks/r/exercises/isogram/test_isogram.R +1 -1
  23. data/tracks/r/exercises/largest-series-product/test_largest-series-product.R +8 -8
  24. data/tracks/r/exercises/leap/test_leap.R +1 -1
  25. data/tracks/r/exercises/luhn/test_luhn.R +1 -1
  26. data/tracks/r/exercises/pascals-triangle/test_pascals-triangle.R +1 -1
  27. data/tracks/r/exercises/perfect-numbers/test_perfect-numbers.R +1 -1
  28. data/tracks/r/exercises/phone-number/test_phone-number.R +1 -1
  29. data/tracks/r/exercises/prime-factors/test_prime-factors.R +16 -21
  30. data/tracks/r/exercises/raindrops/test_raindrops.R +1 -1
  31. data/tracks/r/exercises/rna-transcription/test_rna-transcription.R +1 -1
  32. data/tracks/r/exercises/rotational-cipher/test_rotational-cipher.R +1 -1
  33. data/tracks/r/exercises/scrabble-score/test_scrabble-score.R +1 -1
  34. data/tracks/r/exercises/secret-handshake/test_secret-handshake.R +1 -1
  35. data/tracks/r/exercises/sieve/test_sieve.R +18 -17
  36. data/tracks/r/exercises/space-age/test_space-age.R +2 -2
  37. data/tracks/r/exercises/sum-of-multiples/test_sum-of-multiples.R +11 -11
  38. data/tracks/r/exercises/tournament/test_tournament.R +142 -107
  39. data/tracks/r/exercises/word-count/test_word-count.R +38 -17
  40. data/tracks/vimscript/config.json +23 -0
  41. data/tracks/vimscript/exercises/anagram/anagram.vader +95 -0
  42. data/tracks/vimscript/exercises/anagram/anagram.vim +19 -0
  43. data/tracks/vimscript/exercises/anagram/example.vim +18 -0
  44. data/tracks/vimscript/exercises/difference-of-squares/difference_of_squares.vader +35 -0
  45. data/tracks/vimscript/exercises/difference-of-squares/difference_of_squares.vim +24 -0
  46. data/tracks/vimscript/exercises/difference-of-squares/example.vim +19 -0
  47. data/tracks/vimscript/exercises/raindrops/example.vim +9 -0
  48. data/tracks/vimscript/exercises/raindrops/raindrops.vader +53 -0
  49. data/tracks/vimscript/exercises/raindrops/raindrops.vim +18 -0
  50. data/tracks/vimscript/exercises/rna-transcription/example.vim +3 -0
  51. data/tracks/vimscript/exercises/rna-transcription/rna_transcription.vader +23 -0
  52. data/tracks/vimscript/exercises/rna-transcription/rna_transcription.vim +20 -0
  53. metadata +16 -2
@@ -1,4 +1,4 @@
1
- source('./difference-of-squares.R')
1
+ source("./difference-of-squares.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("difference of squares 0", {
@@ -20,4 +20,3 @@ test_that("difference of squares 100", {
20
20
  input <- 100
21
21
  expect_equal(difference_of_squares(input), 25164150)
22
22
  })
23
-
@@ -1,4 +1,4 @@
1
- source('./grains.R')
1
+ source("./grains.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("Case 1", {
@@ -1,4 +1,4 @@
1
- source('./hamming.R')
1
+ source("./hamming.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("identical strands", {
@@ -1,4 +1,4 @@
1
- source('./hello-world.R')
1
+ source("./hello-world.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("no name", {
@@ -1,4 +1,4 @@
1
- source('./isogram.R')
1
+ source("./isogram.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("empty string", {
@@ -1,4 +1,4 @@
1
- source('./largest-series-product.R')
1
+ source("./largest-series-product.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("finds the largest product if span equals length", {
@@ -66,13 +66,13 @@ test_that("rejects span longer than string length", {
66
66
  # There is one 0-character string contained in the empty string.
67
67
  # That's the empty string itself.
68
68
  # The empty product is 1 (the identity for multiplication).
69
- # Therefore LSP('', 0) is 1.
70
- # It's NOT the case that LSP('', 0) takes max of an empty list.
69
+ # Therefore LSP("", 0) is 1.
70
+ # It's NOT the case that LSP("", 0) takes max of an empty list.
71
71
  # So there is no error.
72
- # Compare against LSP('123', 4):
73
- # There are zero 4-character strings in '123'.
74
- # So LSP('123', 4) really DOES take the max of an empty list.
75
- # So LSP('123', 4) errors and LSP('', 0) does NOT.
72
+ # Compare against LSP("123", 4):
73
+ # There are zero 4-character strings in "123".
74
+ # So LSP("123", 4) really DOES take the max of an empty list.
75
+ # So LSP("123", 4) errors and LSP("", 0) does NOT.
76
76
 
77
77
  test_that("reports 1 for empty string and empty product (0 span)", {
78
78
  digits <- ""
@@ -80,7 +80,7 @@ test_that("reports 1 for empty string and empty product (0 span)", {
80
80
  expect_equal(largestSeriesProduct(digits, span), 1)
81
81
  })
82
82
 
83
- # As above, there is one 0-character string in '123'.
83
+ # As above, there is one 0-character string in "123".
84
84
  # So again no error. It's the empty product, 1.
85
85
 
86
86
  test_that("reports 1 for nonempty string and empty product (0 span)", {
@@ -1,4 +1,4 @@
1
- source('./leap.R')
1
+ source("./leap.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("year not divisible by 4: common year", {
@@ -1,4 +1,4 @@
1
- source('./luhn.R')
1
+ source("./luhn.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("single digit strings can not be valid", {
@@ -1,4 +1,4 @@
1
- source('./pascals-triangle.R')
1
+ source("./pascals-triangle.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("zero rows", {
@@ -1,4 +1,4 @@
1
- source('./perfect-numbers.R')
1
+ source("./perfect-numbers.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("first perfect number", {
@@ -1,4 +1,4 @@
1
- source('./phone-number.R')
1
+ source("./phone-number.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("cleans the number", {
@@ -1,52 +1,47 @@
1
- source('./prime-factors.R')
2
- suppressPackageStartupMessages({ library(testthat) })
1
+ source("./prime-factors.R")
2
+ suppressPackageStartupMessages({
3
+ library(testthat)
4
+ })
3
5
 
4
6
  test_that("no factors", {
5
7
  number <- 1
6
8
  expect_equal(prime_factors(number),
7
- c()
8
- )
9
+ c())
9
10
  })
10
11
 
11
12
  test_that("prime number", {
12
13
  number <- 2
13
14
  expect_equal(prime_factors(number),
14
- c(2)
15
- )
15
+ c(2))
16
16
  })
17
17
 
18
18
  test_that("square of a prime", {
19
19
  number <- 9
20
- expect_equal(prime_factors(number),
21
- c(3, 3)
22
- )
20
+ expect_equal(prime_factors(number),
21
+ c(3, 3))
23
22
  })
24
23
 
25
24
  test_that("cube of a prime", {
26
25
  number <- 8
27
- expect_equal(prime_factors(number),
28
- c(2, 2, 2)
29
- )
26
+ expect_equal(prime_factors(number),
27
+ c(2, 2, 2))
30
28
  })
31
29
 
32
30
  test_that("product of primes and non-primes", {
33
31
  number <- 12
34
- expect_equal(prime_factors(number),
35
- c(2, 2, 3)
36
- )
32
+ expect_equal(prime_factors(number),
33
+ c(2, 2, 3))
37
34
  })
38
35
 
39
36
  test_that("product of primes", {
40
37
  number <- 901255
41
- expect_equal(prime_factors(number),
42
- c(5, 17, 23, 461)
43
- )
38
+ expect_equal(prime_factors(number),
39
+ c(5, 17, 23, 461))
44
40
  })
45
41
  test_that("factors include a large prime", {
46
42
  number <- 93819012551
47
- expect_equal(prime_factors(number),
48
- c(11, 9539, 894119)
49
- )
43
+ expect_equal(prime_factors(number),
44
+ c(11, 9539, 894119))
50
45
  })
51
46
 
52
47
  print("All tests passed!")
@@ -1,4 +1,4 @@
1
- source('./raindrops.R')
1
+ source("./raindrops.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("the sound for 1 is 1", {
@@ -1,4 +1,4 @@
1
- source('./rna-transcription.R')
1
+ source("./rna-transcription.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("rna complement of cytosine is guanine", {
@@ -1,4 +1,4 @@
1
- source('./rotational-cipher.R')
1
+ source("./rotational-cipher.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("rotate a by 1", {
@@ -1,4 +1,4 @@
1
- source('./scrabble-score.R')
1
+ source("./scrabble-score.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("lowercase letter", {
@@ -1,4 +1,4 @@
1
- source('./secret-handshake.R')
1
+ source("./secret-handshake.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("wink for 1", {
@@ -1,4 +1,4 @@
1
- source('./sieve.R')
1
+ source("./sieve.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("no primes under two", {
@@ -10,28 +10,29 @@ test_that("find first prime", {
10
10
  })
11
11
 
12
12
  test_that("find primes up to 10", {
13
- expect_equal(sieve(10), c(2,3,5,7))
13
+ expect_equal(sieve(10), c(2, 3, 5, 7))
14
14
  })
15
15
 
16
16
  test_that("limit is prime", {
17
- expect_equal(sieve(13), c(2,3,5,7,11,13))
17
+ expect_equal(sieve(13), c(2, 3, 5, 7, 11, 13))
18
18
  })
19
19
 
20
20
  test_that("find primes up to 1000", {
21
- expect_equal(sieve(1000),
22
- c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
23
- 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127,
24
- 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
25
- 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269,
26
- 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
27
- 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431,
28
- 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
29
- 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
30
- 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673,
31
- 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761,
32
- 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857,
33
- 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947,
34
- 953, 967, 971, 977, 983, 991, 997))
21
+ expect_equal(sieve(1000),
22
+ c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53,
23
+ 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
24
+ 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
25
+ 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251,
26
+ 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317,
27
+ 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397,
28
+ 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
29
+ 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557,
30
+ 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619,
31
+ 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
32
+ 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787,
33
+ 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
34
+ 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953,
35
+ 967, 971, 977, 983, 991, 997))
35
36
  })
36
37
 
37
38
  print("All tests passed!")
@@ -1,4 +1,4 @@
1
- source('./space-age.R')
1
+ source("./space-age.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("Age on Earth", {
@@ -33,7 +33,7 @@ test_that("Age on Saturn", {
33
33
 
34
34
  test_that("Age on Uranus", {
35
35
  seconds <- 3210123456
36
- expect_equal(space_age(seconds,"uranus"), 1.21)
36
+ expect_equal(space_age(seconds, "uranus"), 1.21)
37
37
  })
38
38
 
39
39
  test_that("Age on Neptune", {
@@ -1,44 +1,44 @@
1
- source('./sum-of-multiples.R')
1
+ source("./sum-of-multiples.R")
2
2
  library(testthat)
3
3
 
4
4
  test_that("Case 1", {
5
- expect_equal(sum_of_multiples(c(3,5), 1), 0)
5
+ expect_equal(sum_of_multiples(c(3, 5), 1), 0)
6
6
  })
7
7
 
8
8
  test_that("Case 2", {
9
- expect_equal(sum_of_multiples(c(3,5), 4), 3)
9
+ expect_equal(sum_of_multiples(c(3, 5), 4), 3)
10
10
  })
11
11
 
12
12
  test_that("Case 3", {
13
- expect_equal(sum_of_multiples(c(3,5), 10), 23)
13
+ expect_equal(sum_of_multiples(c(3, 5), 10), 23)
14
14
  })
15
15
 
16
16
  test_that("Case 4", {
17
- expect_equal(sum_of_multiples(c(3,5), 100), 2318)
17
+ expect_equal(sum_of_multiples(c(3, 5), 100), 2318)
18
18
  })
19
19
 
20
20
  test_that("Case 5", {
21
- expect_equal(sum_of_multiples(c(3,5), 1000), 233168)
21
+ expect_equal(sum_of_multiples(c(3, 5), 1000), 233168)
22
22
  })
23
23
 
24
24
  test_that("Case 6", {
25
- expect_equal(sum_of_multiples(c(7,13,17), 20), 51)
25
+ expect_equal(sum_of_multiples(c(7, 13, 17), 20), 51)
26
26
  })
27
27
 
28
28
  test_that("Case 7", {
29
- expect_equal(sum_of_multiples(c(4,6), 15), 30)
29
+ expect_equal(sum_of_multiples(c(4, 6), 15), 30)
30
30
  })
31
31
 
32
32
  test_that("Case 8", {
33
- expect_equal(sum_of_multiples(c(5,6,8), 150), 4419)
33
+ expect_equal(sum_of_multiples(c(5, 6, 8), 150), 4419)
34
34
  })
35
35
 
36
36
  test_that("Case 9", {
37
- expect_equal(sum_of_multiples(c(5,25), 51), 275)
37
+ expect_equal(sum_of_multiples(c(5, 25), 51), 275)
38
38
  })
39
39
 
40
40
  test_that("Case 10", {
41
- expect_equal(sum_of_multiples(c(43,47), 10000), 2203160)
41
+ expect_equal(sum_of_multiples(c(43, 47), 10000), 2203160)
42
42
  })
43
43
 
44
44
  test_that("Case 11", {
@@ -1,140 +1,175 @@
1
- source('./tournament.R')
1
+ source("./tournament.R")
2
2
  library(testthat)
3
3
 
4
4
  options(stringsAsFactors = FALSE)
5
5
 
6
6
  test_that("typical input", {
7
- input <- c("Allegoric Alaskans;Blithering Badgers;win",
8
- "Devastating Donkeys;Courageous Californians;draw",
9
- "Devastating Donkeys;Allegoric Alaskans;win",
10
- "Courageous Californians;Blithering Badgers;loss",
11
- "Blithering Badgers;Devastating Donkeys;loss",
12
- "Allegoric Alaskans;Courageous Californians;win")
13
- expect_equal(tournament(input),
14
- data.frame(
15
- Team = c("Devastating Donkeys","Allegoric Alaskans",
16
- "Blithering Badgers","Courageous Californians"),
17
- MP = c(3, 3, 3, 3),
18
- W = c(2, 2, 1, 0),
19
- D = c(1, 0, 0, 1),
20
- L = c(0, 1, 2, 2),
21
- P = c(7, 6, 3, 1)
22
- )
7
+ input <- c(
8
+ "Allegoric Alaskans;Blithering Badgers;win",
9
+ "Devastating Donkeys;Courageous Californians;draw",
10
+ "Devastating Donkeys;Allegoric Alaskans;win",
11
+ "Courageous Californians;Blithering Badgers;loss",
12
+ "Blithering Badgers;Devastating Donkeys;loss",
13
+ "Allegoric Alaskans;Courageous Californians;win"
23
14
  )
15
+ expect_equal(tournament(input),
16
+ data.frame(
17
+ Team = c(
18
+ "Devastating Donkeys",
19
+ "Allegoric Alaskans",
20
+ "Blithering Badgers",
21
+ "Courageous Californians"
22
+ ),
23
+ MP = c(3, 3, 3, 3),
24
+ W = c(2, 2, 1, 0),
25
+ D = c(1, 0, 0, 1),
26
+ L = c(0, 1, 2, 2),
27
+ P = c(7, 6, 3, 1)
28
+ ))
24
29
  })
25
30
 
26
31
  test_that("incomplete competition (not all pairs have played)", {
27
- input <- c("Allegoric Alaskans;Blithering Badgers;loss",
28
- "Devastating Donkeys;Allegoric Alaskans;loss",
29
- "Courageous Californians;Blithering Badgers;draw",
30
- "Allegoric Alaskans;Courageous Californians;win")
31
- expect_equal(tournament(input),
32
- data.frame(
33
- Team = c("Allegoric Alaskans","Blithering Badgers",
34
- "Courageous Californians","Devastating Donkeys"),
35
- MP = c(3, 2, 2, 1),
36
- W = c(2, 1, 0, 0),
37
- D = c(0, 1, 1, 0),
38
- L = c(1, 0, 1, 1),
39
- P = c(6, 4, 1, 0)
40
- )
32
+ input <- c(
33
+ "Allegoric Alaskans;Blithering Badgers;loss",
34
+ "Devastating Donkeys;Allegoric Alaskans;loss",
35
+ "Courageous Californians;Blithering Badgers;draw",
36
+ "Allegoric Alaskans;Courageous Californians;win"
41
37
  )
38
+ expect_equal(tournament(input),
39
+ data.frame(
40
+ Team = c(
41
+ "Allegoric Alaskans",
42
+ "Blithering Badgers",
43
+ "Courageous Californians",
44
+ "Devastating Donkeys"
45
+ ),
46
+ MP = c(3, 2, 2, 1),
47
+ W = c(2, 1, 0, 0),
48
+ D = c(0, 1, 1, 0),
49
+ L = c(1, 0, 1, 1),
50
+ P = c(6, 4, 1, 0)
51
+ ))
42
52
  })
43
53
 
44
54
  test_that("ties broken alphabetically", {
45
- input <- c("Courageous Californians;Devastating Donkeys;win",
46
- "Allegoric Alaskans;Blithering Badgers;win",
47
- "Devastating Donkeys;Allegoric Alaskans;loss",
48
- "Courageous Californians;Blithering Badgers;win",
49
- "Blithering Badgers;Devastating Donkeys;draw",
50
- "Allegoric Alaskans;Courageous Californians;draw")
51
- expect_equal(tournament(input),
52
- data.frame(
53
- Team = c("Allegoric Alaskans","Courageous Californians",
54
- "Blithering Badgers","Devastating Donkeys"),
55
- MP = c(3, 3, 3, 3),
56
- W = c(2, 2, 0, 0),
57
- D = c(1, 1, 1, 1),
58
- L = c(0, 0, 2, 2),
59
- P = c(7, 7, 1, 1)
60
- )
55
+ input <- c(
56
+ "Courageous Californians;Devastating Donkeys;win",
57
+ "Allegoric Alaskans;Blithering Badgers;win",
58
+ "Devastating Donkeys;Allegoric Alaskans;loss",
59
+ "Courageous Californians;Blithering Badgers;win",
60
+ "Blithering Badgers;Devastating Donkeys;draw",
61
+ "Allegoric Alaskans;Courageous Californians;draw"
61
62
  )
63
+ expect_equal(tournament(input),
64
+ data.frame(
65
+ Team = c(
66
+ "Allegoric Alaskans",
67
+ "Courageous Californians",
68
+ "Blithering Badgers",
69
+ "Devastating Donkeys"
70
+ ),
71
+ MP = c(3, 3, 3, 3),
72
+ W = c(2, 2, 0, 0),
73
+ D = c(1, 1, 1, 1),
74
+ L = c(0, 0, 2, 2),
75
+ P = c(7, 7, 1, 1)
76
+ ))
62
77
  })
63
78
 
64
79
  test_that("an empty line", {
65
- input <- c("Allegoric Alaskans;Blithering Badgers;loss",
66
- "Devastating Donkeys;Allegoric Alaskans;loss",
67
- "",
68
- "Courageous Californians;Blithering Badgers;draw",
69
- "Allegoric Alaskans;Courageous Californians;win")
70
- expect_equal(tournament(input),
71
- data.frame(
72
- Team = c("Allegoric Alaskans","Blithering Badgers",
73
- "Courageous Californians","Devastating Donkeys"),
74
- MP = c(3, 2, 2, 1),
75
- W = c(2, 1, 0, 0),
76
- D = c(0, 1, 1, 0),
77
- L = c(1, 0, 1, 1),
78
- P = c(6, 4, 1, 0)
79
- )
80
+ input <- c(
81
+ "Allegoric Alaskans;Blithering Badgers;loss",
82
+ "Devastating Donkeys;Allegoric Alaskans;loss",
83
+ "",
84
+ "Courageous Californians;Blithering Badgers;draw",
85
+ "Allegoric Alaskans;Courageous Californians;win"
80
86
  )
87
+ expect_equal(tournament(input),
88
+ data.frame(
89
+ Team = c(
90
+ "Allegoric Alaskans",
91
+ "Blithering Badgers",
92
+ "Courageous Californians",
93
+ "Devastating Donkeys"
94
+ ),
95
+ MP = c(3, 2, 2, 1),
96
+ W = c(2, 1, 0, 0),
97
+ D = c(0, 1, 1, 0),
98
+ L = c(1, 0, 1, 1),
99
+ P = c(6, 4, 1, 0)
100
+ ))
81
101
  })
82
102
 
83
103
  test_that("wrong separator used", {
84
- input <- c("Allegoric Alaskans;Blithering Badgers;loss",
85
- "Devastating Donkeys;Allegoric Alaskans;loss",
86
- "Courageous Californians;Blithering Badgers;draw",
87
- "Devastating Donkeys@Courageous Californians;draw",
88
- "Allegoric Alaskans;Courageous Californians;win")
89
- expect_equal(tournament(input),
90
- data.frame(
91
- Team = c("Allegoric Alaskans","Blithering Badgers",
92
- "Courageous Californians","Devastating Donkeys"),
93
- MP = c(3, 2, 2, 1),
94
- W = c(2, 1, 0, 0),
95
- D = c(0, 1, 1, 0),
96
- L = c(1, 0, 1, 1),
97
- P = c(6, 4, 1, 0)
98
- )
104
+ input <- c(
105
+ "Allegoric Alaskans;Blithering Badgers;loss",
106
+ "Devastating Donkeys;Allegoric Alaskans;loss",
107
+ "Courageous Californians;Blithering Badgers;draw",
108
+ "Devastating Donkeys@Courageous Californians;draw",
109
+ "Allegoric Alaskans;Courageous Californians;win"
99
110
  )
111
+ expect_equal(tournament(input),
112
+ data.frame(
113
+ Team = c(
114
+ "Allegoric Alaskans",
115
+ "Blithering Badgers",
116
+ "Courageous Californians",
117
+ "Devastating Donkeys"
118
+ ),
119
+ MP = c(3, 2, 2, 1),
120
+ W = c(2, 1, 0, 0),
121
+ D = c(0, 1, 1, 0),
122
+ L = c(1, 0, 1, 1),
123
+ P = c(6, 4, 1, 0)
124
+ ))
100
125
  })
101
126
 
102
127
  test_that("too many separators", {
103
- input <- c("Allegoric Alaskans;Blithering Badgers;loss",
104
- "Devastating Donkeys;Courageous Californians;draw;5",
105
- "Devastating Donkeys;Allegoric Alaskans;loss",
106
- "Courageous Californians;Blithering Badgers;draw",
107
- "Allegoric Alaskans;Courageous Californians;win")
108
- expect_equal(tournament(input),
109
- data.frame(
110
- Team = c("Allegoric Alaskans","Blithering Badgers",
111
- "Courageous Californians","Devastating Donkeys"),
112
- MP = c(3, 2, 2, 1),
113
- W = c(2, 1, 0, 0),
114
- D = c(0, 1, 1, 0),
115
- L = c(1, 0, 1, 1),
116
- P = c(6, 4, 1, 0)
117
- )
128
+ input <- c(
129
+ "Allegoric Alaskans;Blithering Badgers;loss",
130
+ "Devastating Donkeys;Courageous Californians;draw;5",
131
+ "Devastating Donkeys;Allegoric Alaskans;loss",
132
+ "Courageous Californians;Blithering Badgers;draw",
133
+ "Allegoric Alaskans;Courageous Californians;win"
118
134
  )
135
+ expect_equal(tournament(input),
136
+ data.frame(
137
+ Team = c(
138
+ "Allegoric Alaskans",
139
+ "Blithering Badgers",
140
+ "Courageous Californians",
141
+ "Devastating Donkeys"
142
+ ),
143
+ MP = c(3, 2, 2, 1),
144
+ W = c(2, 1, 0, 0),
145
+ D = c(0, 1, 1, 0),
146
+ L = c(1, 0, 1, 1),
147
+ P = c(6, 4, 1, 0)
148
+ ))
119
149
  })
120
150
 
121
151
  test_that("invalid match result", {
122
- input <- c("Allegoric Alaskans;Blithering Badgers;loss",
123
- "Devastating Donkeys;Allegoric Alaskans;loss",
124
- "Courageous Californians;Blithering Badgers;draw",
125
- "Allegoric Alaskans;Courageous Californians;win",
126
- "Devastating Donkeys;Allegoric Alaskans;dra")
127
- expect_equal(tournament(input),
128
- data.frame(
129
- Team = c("Allegoric Alaskans","Blithering Badgers",
130
- "Courageous Californians","Devastating Donkeys"),
131
- MP = c(3, 2, 2, 1),
132
- W = c(2, 1, 0, 0),
133
- D = c(0, 1, 1, 0),
134
- L = c(1, 0, 1, 1),
135
- P = c(6, 4, 1, 0)
136
- )
152
+ input <- c(
153
+ "Allegoric Alaskans;Blithering Badgers;loss",
154
+ "Devastating Donkeys;Allegoric Alaskans;loss",
155
+ "Courageous Californians;Blithering Badgers;draw",
156
+ "Allegoric Alaskans;Courageous Californians;win",
157
+ "Devastating Donkeys;Allegoric Alaskans;dra"
137
158
  )
159
+ expect_equal(tournament(input),
160
+ data.frame(
161
+ Team = c(
162
+ "Allegoric Alaskans",
163
+ "Blithering Badgers",
164
+ "Courageous Californians",
165
+ "Devastating Donkeys"
166
+ ),
167
+ MP = c(3, 2, 2, 1),
168
+ W = c(2, 1, 0, 0),
169
+ D = c(0, 1, 1, 0),
170
+ L = c(1, 0, 1, 1),
171
+ P = c(6, 4, 1, 0)
172
+ ))
138
173
  })
139
174
 
140
175
  print("All tests passed!")