trackler 2.2.1.19 → 2.2.1.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 (96) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/bash/config.json +11 -0
  4. data/tracks/bash/docs/ABOUT.md +5 -0
  5. data/tracks/bash/exercises/word-count/README.md +24 -0
  6. data/tracks/bash/exercises/word-count/example.awk +12 -0
  7. data/tracks/bash/exercises/word-count/example.sh +21 -0
  8. data/tracks/bash/exercises/word-count/word_count_test.sh +84 -0
  9. data/tracks/coffeescript/config/maintainers.json +5 -11
  10. data/tracks/csharp/.travis.yml +3 -0
  11. data/tracks/delphi/config/maintainers.json +1 -1
  12. data/tracks/ecmascript/config.json +108 -108
  13. data/tracks/elixir/exercises/phone-number/phone_number_test.exs +21 -1
  14. data/tracks/factor/docs/SNIPPET.txt +5 -0
  15. data/tracks/idris/docs/TESTS.md +7 -0
  16. data/tracks/java/config.json +47 -47
  17. data/tracks/javascript/config.json +103 -103
  18. data/tracks/julia/config.json +121 -121
  19. data/tracks/julia/docs/RESOURCES.md +1 -1
  20. data/tracks/julia/docs/SNIPPET.txt +8 -0
  21. data/tracks/objective-c/config.json +2 -3
  22. data/tracks/objective-c/exercises/rna-transcription/RNATranscriptionExample.m +11 -32
  23. data/tracks/ocaml/.travis-ci.sh +1 -1
  24. data/tracks/ocaml/.travis.yml +1 -1
  25. data/tracks/ocaml/README.md +1 -1
  26. data/tracks/ocaml/exercises/change/test.ml +24 -21
  27. data/tracks/ocaml/tools/test-generator/src/codegen.ml +3 -7
  28. data/tracks/ocaml/tools/test-generator/src/controller.ml +4 -5
  29. data/tracks/ocaml/tools/test-generator/src/languages.ml +4 -3
  30. data/tracks/ocaml/tools/test-generator/src/model.ml +1 -2
  31. data/tracks/ocaml/tools/test-generator/src/ocaml_special_cases.ml +19 -18
  32. data/tracks/ocaml/tools/test-generator/src/parser.ml +12 -17
  33. data/tracks/ocaml/tools/test-generator/src/purescript_special_cases.ml +11 -3
  34. data/tracks/ocaml/tools/test-generator/test/codegen_test.ml +2 -3
  35. data/tracks/ocaml/tools/test-generator/test/ocaml_special_cases_test.ml +12 -4
  36. data/tracks/ocaml/tools/test-generator/test/parser_test.ml +10 -10
  37. data/tracks/purescript/exercises/bob/test/Main.purs +5 -5
  38. data/tracks/ruby/bin/generate +1 -1
  39. data/tracks/ruby/docs/24pullrequests.md +1 -1
  40. data/tracks/ruby/exercises/all-your-base/all_your_base_test.rb +24 -24
  41. data/tracks/ruby/exercises/alphametics/.meta/generator/test_template.erb +1 -1
  42. data/tracks/ruby/exercises/bowling/.meta/generator/test_template.erb +1 -1
  43. data/tracks/ruby/exercises/bowling/bowling_test.rb +10 -10
  44. data/tracks/ruby/exercises/change/.meta/.version +1 -1
  45. data/tracks/ruby/exercises/change/.meta/solutions/change.rb +1 -1
  46. data/tracks/ruby/exercises/change/change_test.rb +7 -2
  47. data/tracks/ruby/exercises/collatz-conjecture/.meta/generator/collatz_conjecture_case.rb +1 -1
  48. data/tracks/ruby/exercises/connect/.meta/generator/test_template.erb +1 -1
  49. data/tracks/ruby/exercises/dominoes/.meta/generator/test_template.erb +1 -1
  50. data/tracks/ruby/exercises/hamming/.meta/generator/hamming_case.rb +5 -1
  51. data/tracks/ruby/exercises/hamming/hamming_test.rb +7 -7
  52. data/tracks/ruby/exercises/leap/.meta/generator/test_template.erb +1 -1
  53. data/tracks/ruby/exercises/pangram/.meta/.version +1 -1
  54. data/tracks/ruby/exercises/pangram/.meta/solutions/pangram.rb +1 -1
  55. data/tracks/ruby/exercises/pangram/pangram_test.rb +3 -3
  56. data/tracks/ruby/exercises/rna-transcription/rna_transcription_test.rb +4 -4
  57. data/tracks/ruby/exercises/roman-numerals/.meta/solutions/roman_numerals.rb +1 -1
  58. data/tracks/ruby/exercises/space-age/.meta/generator/test_template.erb +1 -1
  59. data/tracks/ruby/lib/generator/test_template.erb +1 -1
  60. data/tracks/ruby/lib/generator/underscore.rb +1 -1
  61. data/tracks/ruby/lib/helper.rb +4 -4
  62. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/alpha-beta/.meta/generator/test_template.erb +1 -1
  63. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/alpha/.meta/.version +0 -0
  64. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/alpha/.meta/generator/alpha_case.rb +0 -0
  65. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/alpha/.meta/generator/test_template.erb +1 -1
  66. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/alpha/.meta/solutions/alpha.rb +0 -0
  67. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/beta/.meta/.version +0 -0
  68. data/tracks/ruby/test/fixtures/{xruby → ruby}/exercises/beta/.meta/generator/beta_case.rb +0 -0
  69. data/tracks/ruby/test/fixtures/{xruby → ruby}/lib/generator/test_template.erb +1 -1
  70. data/tracks/ruby/test/generator/files/track_files_test.rb +4 -4
  71. data/tracks/ruby/test/generator/implementation_test.rb +1 -1
  72. data/tracks/ruby/test/generator/template_values_test.rb +1 -1
  73. data/tracks/scala/exercises/rail-fence-cipher/src/main/scala/{RailFenceCipher.scala → .keep} +0 -0
  74. data/tracks/scala/exercises/rail-fence-cipher/src/test/scala/RailFenceCipherTest.scala +16 -23
  75. data/tracks/scala/exercises/say/src/test/scala/SayTest.scala +20 -33
  76. data/tracks/scala/testgen/src/main/scala/RailFenceCipherTestGenerator.scala +9 -53
  77. data/tracks/scala/testgen/src/main/scala/SayTestGenerator.scala +50 -0
  78. data/tracks/sml/bin/generate +1 -1
  79. data/tracks/sml/config.json +30 -0
  80. data/tracks/sml/exercises/all-your-base/README.md +61 -0
  81. data/tracks/sml/exercises/all-your-base/all-your-base.sml +2 -0
  82. data/tracks/sml/exercises/all-your-base/example.sml +36 -0
  83. data/tracks/sml/exercises/all-your-base/test.sml +75 -0
  84. data/tracks/sml/exercises/all-your-base/testlib.sml +159 -0
  85. data/tracks/sml/exercises/difference-of-squares/example.sml +3 -6
  86. data/tracks/sml/exercises/list-ops/README.md +40 -0
  87. data/tracks/sml/exercises/list-ops/example.sml +34 -0
  88. data/tracks/sml/exercises/list-ops/list-ops.sml +23 -0
  89. data/tracks/sml/exercises/list-ops/test.sml +85 -0
  90. data/tracks/sml/exercises/list-ops/testlib.sml +159 -0
  91. data/tracks/sml/exercises/prime-factors/README.md +66 -0
  92. data/tracks/sml/exercises/prime-factors/example.sml +15 -0
  93. data/tracks/sml/exercises/prime-factors/prime-factors.sml +2 -0
  94. data/tracks/sml/exercises/prime-factors/test.sml +35 -0
  95. data/tracks/sml/exercises/prime-factors/testlib.sml +159 -0
  96. metadata +34 -11
@@ -1,10 +1,15 @@
1
1
  require 'minitest/autorun'
2
2
  require_relative 'hamming'
3
3
 
4
- # Common test data version: 1.0.0 bb56dc7
4
+ # Common test data version: 2.0.0 a2aff5b
5
5
  class HammingTest < Minitest::Test
6
- def test_identical_strands
6
+ def test_empty_strands
7
7
  # skip
8
+ assert_equal 0, Hamming.compute('', '')
9
+ end
10
+
11
+ def test_identical_strands
12
+ skip
8
13
  assert_equal 0, Hamming.compute('A', 'A')
9
14
  end
10
15
 
@@ -63,11 +68,6 @@ class HammingTest < Minitest::Test
63
68
  assert_equal 9, Hamming.compute('GGACGGATTCTG', 'AGGACGGATTCT')
64
69
  end
65
70
 
66
- def test_empty_strands
67
- skip
68
- assert_equal 0, Hamming.compute('', '')
69
- end
70
-
71
71
  def test_disallow_first_strand_longer
72
72
  skip
73
73
  assert_raises(ArgumentError) { Hamming.compute('AATG', 'AAA') }
@@ -19,7 +19,7 @@ class YearTest < Minitest::Test
19
19
  end
20
20
 
21
21
  <% end %>
22
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
22
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
23
23
 
24
24
  def test_bookkeeping
25
25
  skip
@@ -1 +1 @@
1
- 4
1
+ 5
@@ -1,5 +1,5 @@
1
1
  module BookKeeping
2
- VERSION = 4
2
+ VERSION = 5
3
3
  end
4
4
 
5
5
  class Pangram
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require_relative 'pangram'
3
3
 
4
- # Common test data version: 1.0.0 f375051
4
+ # Common test data version: 1.1.0 fba1aef
5
5
  class PangramTest < Minitest::Test
6
6
  def test_sentence_empty
7
7
  # skip
@@ -61,7 +61,7 @@ class PangramTest < Minitest::Test
61
61
 
62
62
  def test_upper_and_lower_case_versions_of_the_same_character_should_not_be_counted_separately
63
63
  skip
64
- phrase = 'the quick brown fox jumped over the lazy FOX'
64
+ phrase = 'the quick brown fox jumps over with lazy FX'
65
65
  result = Pangram.pangram?(phrase)
66
66
  refute result, "Expected false, got: #{result.inspect}. #{phrase.inspect} is NOT a pangram"
67
67
  end
@@ -85,6 +85,6 @@ class PangramTest < Minitest::Test
85
85
 
86
86
  def test_bookkeeping
87
87
  skip
88
- assert_equal 4, BookKeeping::VERSION
88
+ assert_equal 5, BookKeeping::VERSION
89
89
  end
90
90
  end
@@ -1,7 +1,7 @@
1
1
  require 'minitest/autorun'
2
2
  require_relative 'rna_transcription'
3
3
 
4
- # Common test data version: 1.0.0 0b20fff
4
+ # Common test data version: 1.0.1 cb1fd3a
5
5
  class RnaTranscriptionTest < Minitest::Test
6
6
  def test_rna_complement_of_cytosine_is_guanine
7
7
  # skip
@@ -28,17 +28,17 @@ class RnaTranscriptionTest < Minitest::Test
28
28
  assert_equal 'UGCACCAGAAUU', Complement.of_dna('ACGTGGTCTTAA')
29
29
  end
30
30
 
31
- def test_dna_correctly_handles_invalid_input
31
+ def test_correctly_handles_invalid_input_rna_instead_of_dna
32
32
  skip
33
33
  assert_equal '', Complement.of_dna('U')
34
34
  end
35
35
 
36
- def test_dna_correctly_handles_completely_invalid_input
36
+ def test_correctly_handles_completely_invalid_dna_input
37
37
  skip
38
38
  assert_equal '', Complement.of_dna('XXX')
39
39
  end
40
40
 
41
- def test_dna_correctly_handles_partially_invalid_input
41
+ def test_correctly_handles_partially_invalid_dna_input
42
42
  skip
43
43
  assert_equal '', Complement.of_dna('ACGTXXXCTTAA')
44
44
  end
@@ -2,7 +2,7 @@ module BookKeeping
2
2
  VERSION = 2
3
3
  end
4
4
 
5
- class Fixnum
5
+ class Integer
6
6
  def to_roman
7
7
  i = self
8
8
  s = ''
@@ -15,7 +15,7 @@ class <%= exercise_name_camel %>Test < Minitest::Test
15
15
  end
16
16
 
17
17
  <% end %>
18
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
18
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
19
19
 
20
20
  def test_bookkeeping
21
21
  skip
@@ -10,7 +10,7 @@ class <%= exercise_name_camel %>Test < Minitest::Test
10
10
  end
11
11
 
12
12
  <% end %>
13
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
13
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
14
14
 
15
15
  def test_bookkeeping
16
16
  skip
@@ -10,7 +10,7 @@ module Generator
10
10
  end
11
11
  end
12
12
 
13
- refine Fixnum do
13
+ refine Integer do
14
14
  def underscore
15
15
  self.to_s.reverse.gsub(/...(?=.)/, '\&_').reverse
16
16
  end
@@ -1,5 +1,5 @@
1
- XRUBY_ROOT = File.join(File.dirname(__FILE__), '..').freeze
2
- XRUBY_LIB = File.join(XRUBY_ROOT, 'lib').freeze
3
- METADATA_REPOSITORY_PATH = File.join(XRUBY_ROOT, '..', 'problem-specifications').freeze
1
+ EXERCISM_RUBY_ROOT = File.join(File.dirname(__FILE__), '..').freeze
2
+ EXERCISM_RUBY_LIB = File.join(EXERCISM_RUBY_ROOT, 'lib').freeze
3
+ METADATA_REPOSITORY_PATH = File.join(EXERCISM_RUBY_ROOT, '..', 'problem-specifications').freeze
4
4
 
5
- $LOAD_PATH.unshift(XRUBY_LIB)
5
+ $LOAD_PATH.unshift(EXERCISM_RUBY_LIB)
@@ -10,7 +10,7 @@ class AlphaBetaTest < Minitest::Test
10
10
  end
11
11
 
12
12
  <% end %>
13
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
13
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
14
14
 
15
15
  def test_bookkeeping
16
16
  skip
@@ -12,7 +12,7 @@ class <%= exercise_name_camel %>Test < Minitest::Test
12
12
  end
13
13
 
14
14
  <% end %>
15
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
15
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
16
16
 
17
17
  def test_bookkeeping
18
18
  skip
@@ -10,7 +10,7 @@ class <%= exercise_name_camel %>Test < Minitest::Test
10
10
  end
11
11
 
12
12
  <% end %>
13
- <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
13
+ <%= IO.read(EXERCISM_RUBY_LIB + '/bookkeeping.md') %>
14
14
 
15
15
  def test_bookkeeping
16
16
  skip
@@ -5,7 +5,7 @@ module Generator
5
5
  class TrackFilesTest < Minitest::Test
6
6
  FixturePaths = Paths.new(
7
7
  metadata: 'test/fixtures/metadata',
8
- track: 'test/fixtures/xruby'
8
+ track: 'test/fixtures/ruby'
9
9
  )
10
10
 
11
11
  class TestTrackFiles
@@ -69,7 +69,7 @@ module Generator
69
69
  end
70
70
 
71
71
  def test_increment
72
- subject = TestTestsVersionFile.new(filename: 'test/fixtures/xruby/exercises/alpha/.meta/.version')
72
+ subject = TestTestsVersionFile.new(filename: 'test/fixtures/ruby/exercises/alpha/.meta/.version')
73
73
  assert_equal 2, subject.increment
74
74
  end
75
75
  end
@@ -83,7 +83,7 @@ module Generator
83
83
 
84
84
  def test_update_version
85
85
  subject = TestExampleSolutionFile.new(
86
- filename: 'test/fixtures/xruby/exercises/alpha/.meta/solutions/alpha.rb'
86
+ filename: 'test/fixtures/ruby/exercises/alpha/.meta/solutions/alpha.rb'
87
87
  )
88
88
  assert_match(/VERSION = 2/, subject.update_version(2))
89
89
  end
@@ -103,7 +103,7 @@ module Generator
103
103
  mock_erb = Minitest::Mock.new
104
104
  mock_erb.expect :result, 'new content', ['mock binding']
105
105
 
106
- subject = TestMinitestTestsFile.new(filename: 'test/fixtures/xruby/exercises/alpha/alpha_tests.rb')
106
+ subject = TestMinitestTestsFile.new(filename: 'test/fixtures/ruby/exercises/alpha/alpha_tests.rb')
107
107
  ERB.stub :new, mock_erb do
108
108
  assert_equal 'new content', subject.generate(template: mock_template, values: mock_values)
109
109
  end
@@ -4,7 +4,7 @@ module Generator
4
4
  class ImplementationTest < Minitest::Test
5
5
  FixturePaths = Paths.new(
6
6
  metadata: 'test/fixtures/metadata',
7
- track: 'test/fixtures/xruby'
7
+ track: 'test/fixtures/ruby'
8
8
  )
9
9
 
10
10
  def test_version
@@ -63,7 +63,7 @@ module Generator
63
63
  end
64
64
 
65
65
  def test_case
66
- Files::TestCaseFile.new(filename: 'test/fixtures/xruby/exercises/alpha/.meta/generator/alpha_case.rb')
66
+ Files::TestCaseFile.new(filename: 'test/fixtures/ruby/exercises/alpha/.meta/generator/alpha_case.rb')
67
67
  end
68
68
 
69
69
  include TemplateValuesFactory
@@ -1,42 +1,35 @@
1
- import org.scalatest.{FunSuite, Matchers}
1
+ import org.scalatest.{Matchers, FunSuite}
2
2
 
3
+ /** @version 1.0.1 */
3
4
  class RailFenceCipherTest extends FunSuite with Matchers {
4
5
 
5
- // Encode test cases
6
- test("test to encode with two rails") {
7
- val encoded = RailFenceCipher.encode("XOXOXOXOXOXOXOXOXO", 2)
8
- encoded should be ("XXXXXXXXXOOOOOOOOO")
6
+ test("encode with two rails") {
7
+ RailFenceCipher.encode("XOXOXOXOXOXOXOXOXO", 2) should be ("XXXXXXXXXOOOOOOOOO")
9
8
  }
10
9
 
11
- test("test to encode with three rails") {
10
+ test("encode with three rails") {
12
11
  pending
13
- val encoded = RailFenceCipher.encode("WEAREDISCOVEREDFLEEATONCE", 3)
14
- encoded should be ("WECRLTEERDSOEEFEAOCAIVDEN")
12
+ RailFenceCipher.encode("WEAREDISCOVEREDFLEEATONCE", 3) should be ("WECRLTEERDSOEEFEAOCAIVDEN")
15
13
  }
16
14
 
17
- test("test to encode with ending in the middle") {
15
+ test("encode with ending in the middle") {
18
16
  pending
19
- val encoded = RailFenceCipher.encode("EXERCISES", 4)
20
- encoded should be ("ESXIEECSR")
17
+ RailFenceCipher.encode("EXERCISES", 4) should be ("ESXIEECSR")
21
18
  }
22
19
 
23
- // Decode test cases
24
- test("test to decode with three rails") {
20
+ test("decode with three rails") {
25
21
  pending
26
- val decoded = RailFenceCipher.decode("TEITELHDVLSNHDTISEIIEA", 3)
27
- decoded should be ("THEDEVILISINTHEDETAILS")
22
+ RailFenceCipher.decode("TEITELHDVLSNHDTISEIIEA", 3) should be ("THEDEVILISINTHEDETAILS")
28
23
  }
29
24
 
30
- test("test to decode with five rails") {
25
+ test("decode with five rails") {
31
26
  pending
32
- val decoded = RailFenceCipher.decode("EIEXMSMESAORIWSCE", 5)
33
- decoded should be ("EXERCISMISAWESOME")
27
+ RailFenceCipher.decode("EIEXMSMESAORIWSCE", 5) should be ("EXERCISMISAWESOME")
34
28
  }
35
29
 
36
- test("test to decode with six rails") {
30
+ test("decode with six rails") {
37
31
  pending
38
- val decoded = RailFenceCipher.decode("133714114238148966225439541018335470986172518171757571896261", 6)
39
- decoded should be ("112358132134558914423337761098715972584418167651094617711286")
32
+ RailFenceCipher.decode("133714114238148966225439541018335470986172518171757571896261", 6) should
33
+ be ("112358132134558914423337761098715972584418167651094617711286")
40
34
  }
41
-
42
- }
35
+ }
@@ -1,93 +1,80 @@
1
1
  import org.scalatest.{Matchers, FunSuite}
2
2
 
3
+ /** @version 1.0.0 */
3
4
  class SayTest extends FunSuite with Matchers {
5
+
4
6
  test("zero") {
5
7
  Say.inEnglish(0) should be (Some("zero"))
6
8
  }
7
9
 
8
- test("one") {
10
+ test("one") {
9
11
  pending
10
12
  Say.inEnglish(1) should be (Some("one"))
11
13
  }
12
14
 
13
- test("fourteen") {
15
+ test("fourteen") {
14
16
  pending
15
17
  Say.inEnglish(14) should be (Some("fourteen"))
16
18
  }
17
19
 
18
- test("twenty") {
20
+ test("twenty") {
19
21
  pending
20
22
  Say.inEnglish(20) should be (Some("twenty"))
21
23
  }
22
24
 
23
- test("twenty-two") {
25
+ test("twenty-two") {
24
26
  pending
25
27
  Say.inEnglish(22) should be (Some("twenty-two"))
26
28
  }
27
29
 
28
- test("fifty") {
29
- pending
30
- Say.inEnglish(50) should be (Some("fifty"))
31
- }
32
-
33
- test("ninety-eight") {
34
- pending
35
- Say.inEnglish(98) should be (Some("ninety-eight"))
36
- }
37
-
38
- test("one hundred") {
30
+ test("one hundred") {
39
31
  pending
40
32
  Say.inEnglish(100) should be (Some("one hundred"))
41
33
  }
42
34
 
43
- test("one hundred twenty-three") {
35
+ test("one hundred twenty-three") {
44
36
  pending
45
37
  Say.inEnglish(123) should be (Some("one hundred twenty-three"))
46
38
  }
47
39
 
48
- test("one thousand") {
40
+ test("one thousand") {
49
41
  pending
50
42
  Say.inEnglish(1000) should be (Some("one thousand"))
51
43
  }
52
44
 
53
- test("one thousand two hundred thirty-four") {
45
+ test("one thousand two hundred thirty-four") {
54
46
  pending
55
47
  Say.inEnglish(1234) should be (Some("one thousand two hundred thirty-four"))
56
48
  }
57
49
 
58
- test("one million") {
50
+ test("one million") {
59
51
  pending
60
52
  Say.inEnglish(1000000) should be (Some("one million"))
61
53
  }
62
54
 
63
- test("one million two") {
64
- pending
65
- Say.inEnglish(1000002) should be (Some("one million two"))
66
- }
67
-
68
- test("one million two thousand three hundred forty-five") {
55
+ test("one million two thousand three hundred forty-five") {
69
56
  pending
70
57
  Say.inEnglish(1002345) should be (Some("one million two thousand three hundred forty-five"))
71
58
  }
72
59
 
73
- test("one billion") {
60
+ test("one billion") {
74
61
  pending
75
62
  Say.inEnglish(1000000000) should be (Some("one billion"))
76
63
  }
77
64
 
78
- test("A big number") {
65
+ test("a big number") {
79
66
  pending
80
- Say.inEnglish(987654321123L) should be (Some("nine hundred eighty-seven billion " +
81
- "six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three"))
67
+ Say.inEnglish(987654321123l) should
68
+ be (Some("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three"))
82
69
  }
83
70
 
84
- test("Lower bound") {
71
+ test("numbers below zero are out of range") {
85
72
  pending
86
73
  Say.inEnglish(-1) should be (None)
87
74
  }
88
75
 
89
- test("Upper bound") {
76
+ test("numbers above 999,999,999,999 are out of range") {
90
77
  pending
91
- Say.inEnglish(1000000000000L) should be (None)
78
+ Say.inEnglish(1000000000000l) should be (None)
92
79
  }
93
- }
80
+ }
@@ -1,59 +1,15 @@
1
- import play.api.libs.json.Json
1
+ import java.io.File
2
2
 
3
- import scala.io.Source
4
-
5
- // Generates test suite from json test definition for the RailFenceCipher exercise.
6
- class RailFenceCipherTestGenerator {
7
- implicit val railFenceTestCaseReader = Json.reads[RailFenceTestCase]
8
-
9
- private val filename = "rail-fence.json"
10
- private val fileContents = Source.fromFile(filename).getLines.mkString
11
- private val json = Json.parse(fileContents)
12
-
13
- def write {
14
- val testBuilder = new TestBuilder("RailFenceCipherTest")
15
- addEncodeTests(testBuilder)
16
- addDecodeTests(testBuilder)
17
- testBuilder.toFile
18
- }
19
-
20
- private def addEncodeTests(testBuilder: TestBuilder): Unit = {
21
- val description = "Encode test cases"
22
- val encodeTestCases = (json \ "encode" \ "cases").get.as[List[RailFenceTestCase]]
23
-
24
- implicit def testCaseToGen(tc: RailFenceTestCase): TestCaseGen = {
25
- val callSUT = s"""RailFenceCipher.encode("${tc.msg}", ${tc.rails})"""
26
- val expected = tc.expected
27
- val result = s"val encoded = $callSUT"
28
- val checkResult = s"""encoded should be ("$expected")"""
29
-
30
- TestCaseGen(tc.description, callSUT, expected, result, checkResult)
31
- }
32
-
33
- testBuilder.addTestCases(encodeTestCases, Some(description))
34
- }
35
-
36
- private def addDecodeTests(testBuilder: TestBuilder): Unit = {
37
- val description = "Decode test cases"
38
- val encodeTestCases = (json \ "decode" \ "cases").get.as[List[RailFenceTestCase]]
39
-
40
- implicit def testCaseToGen(tc: RailFenceTestCase): TestCaseGen = {
41
- val callSUT = s"""RailFenceCipher.decode("${tc.msg}", ${tc.rails})"""
42
- val expected = tc.expected
43
- val result = s"val decoded = $callSUT"
44
- val checkResult = s"""decoded should be ("$expected")"""
45
-
46
- TestCaseGen(tc.description, callSUT, expected, result, checkResult)
47
- }
48
-
49
- testBuilder.addTestCases(encodeTestCases, Some(description))
50
- }
51
- }
52
-
53
- case class RailFenceTestCase(description: String, msg: String, rails: Int, expected: String)
3
+ import testgen.TestSuiteBuilder._
4
+ import testgen._
54
5
 
55
6
  object RailFenceCipherTestGenerator {
56
7
  def main(args: Array[String]): Unit = {
57
- new RailFenceCipherTestGenerator().write
8
+ val file = new File("src/main/resources/rail-fence-cipher.json")
9
+
10
+ val code = TestSuiteBuilder.build(file, fromLabeledTest("msg", "rails"))
11
+ println(s"-------------")
12
+ println(code)
13
+ println(s"-------------")
58
14
  }
59
15
  }