trackler 2.0.5.17 → 2.0.5.18

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 849e8ea841fb367877c5cb1e81da718b5ec56a51
4
- data.tar.gz: c78ef2f6983bf16650a42642507cbd83dc2b77c9
3
+ metadata.gz: 0e7c06fc89a5ffca1963642be2420915b5abbd66
4
+ data.tar.gz: 4f214cfaf73d2e479d2f92dc699bb5504ee54888
5
5
  SHA512:
6
- metadata.gz: 9b004ae9d1106f5404bb0987f52b6bc9c200e4e9802cfb7d55900f38e519b2ab288dfa598e5e0585bf83634423a1800b72e42bda3e3db27f220468397da9d380
7
- data.tar.gz: a75697e21fdf6167bac7af0e2698086c402a1591bd934ef40d0d4354799c0e1329cb7ff46413b3dff21edc256fdb3b64339b484ccb335b8c42ba887db70a40c2
6
+ metadata.gz: 812c5d0923c243341aa725db3d642403a2523e9aeb36d05b56568920e056faa4ec7786151ea0975210f840c9b63bf4b29f16f94172e3e1217ec0c5b490dcad6a
7
+ data.tar.gz: c1086a51f4174584877f2452d93d52d494bf9c0abe25ca8e5f5272e97e272eefc3ffee474bff82d8a0700af67e483fceb1407f95703597deeb0813ade8f7cd97
@@ -1,3 +1,3 @@
1
1
  module Trackler
2
- VERSION = "2.0.5.17"
2
+ VERSION = "2.0.5.18"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  # xPerl6
2
2
 
3
- [![Gitter](https://badges.gitter.im/exercism/xperl.svg)](https://gitter.im/exercism/xperl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
3
+ [![Build Status](https://travis-ci.org/exercism/xperl6.svg?branch=master)](https://travis-ci.org/exercism/xperl6) [![Gitter](https://badges.gitter.im/exercism/xperl.svg)](https://gitter.im/exercism/xperl?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
4
+
4
5
  Exercism exercises in Perl 6
5
6
 
6
7
  ## Contributing Guide
@@ -86,6 +86,11 @@
86
86
  "slug": "trinary",
87
87
  "topics": []
88
88
  },
89
+ {
90
+ "difficulty" : 1,
91
+ "slug" : "allergies",
92
+ "topics" : []
93
+ },
89
94
  {
90
95
  "difficulty": 1,
91
96
  "slug": "space-age",
@@ -0,0 +1,18 @@
1
+ our @allergens = <
2
+ eggs
3
+ peanuts
4
+ shellfish
5
+ strawberries
6
+ tomatoes
7
+ chocolate
8
+ pollen
9
+ cats
10
+ >;
11
+
12
+ sub allergic-to($code,$substance) is export {
13
+ return so $code +& ( 2 ** @allergens.first({ $_ eq $substance},:k) )
14
+ }
15
+
16
+ sub list-allergies($code) is export {
17
+ return grep { allergic-to($code,$_) }, @allergens;
18
+ }
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env perl6
2
+
3
+ use Test;
4
+ use JSON::Tiny;
5
+
6
+ use lib ( my $dir = IO::Path.new($?FILE).parent ).path;
7
+
8
+ my $module_name = %*ENV<EXERCISM>.so ?? 'Example' !! 'Allergies';
9
+ my @potential_module = <p6 pm6 pm>.map: $module_name ~ '.' ~ *;
10
+
11
+ my $module = first { $dir.child($_).e }, |@potential_module
12
+ or die "No file '$module_name.p6' found\n";
13
+
14
+ require $module <&allergic-to &list-allergies>;
15
+
16
+ plan 2;
17
+
18
+ my %cases = from-json $dir.child('cases.json').slurp;
19
+
20
+ subtest 'allergic-to' => {
21
+ my @cases = |%cases{'allergic_to'}{'cases'};
22
+
23
+ plan +@cases;
24
+
25
+ for |@cases -> %case {
26
+ subtest %case.<description> => {
27
+ plan +|%case.<expected>;
28
+ for |%case.<expected> -> %expected {
29
+ is allergic-to(%case.<score>,%expected.<substance>), %expected.<result>
30
+ or diag %expected;
31
+ }
32
+ }
33
+ }
34
+ };
35
+
36
+ subtest 'list' => {
37
+ my @cases = |%cases{'list'}{'cases'};
38
+
39
+ plan +@cases;
40
+
41
+ for |@cases {
42
+ is list-allergies(.<score>), .<expected>, .<description>
43
+ or diag $_;
44
+ }
45
+ };
@@ -0,0 +1,109 @@
1
+ {
2
+ "allergic_to": {
3
+ "description": [
4
+ "Given a number and a substance, indicate whether Tom is allergic ",
5
+ "to that substance.",
6
+ "Test cases for this method involve more than one assertion.",
7
+ "Each case in 'expected' specifies what the method should return for",
8
+ "the given substance."
9
+ ],
10
+ "cases": [
11
+ {
12
+ "description": "no allergies means not allergic",
13
+ "score": 0,
14
+ "expected": [
15
+ {
16
+ "substance": "peanuts",
17
+ "result": false
18
+ },
19
+ {
20
+ "substance": "cats",
21
+ "result": false
22
+ },
23
+ {
24
+ "substance": "strawberries",
25
+ "result": false
26
+ }
27
+ ]
28
+ },
29
+ {
30
+ "description": "is allergic to eggs",
31
+ "score": 1,
32
+ "expected": [
33
+ {
34
+ "substance": "eggs",
35
+ "result": true
36
+ }
37
+ ]
38
+ },
39
+ {
40
+ "description": "allergic to eggs in addition to other stuff",
41
+ "score": 5,
42
+ "expected": [
43
+ {
44
+ "substance": "eggs",
45
+ "result": true
46
+ },
47
+ {
48
+ "substance": "shellfish",
49
+ "result": true
50
+ },
51
+ {
52
+ "substance": "strawberries",
53
+ "result": false
54
+ }
55
+ ]
56
+ }
57
+ ]
58
+ },
59
+ "list": {
60
+ "description": ["Given a number, list all things Tom is allergic to"],
61
+ "cases": [
62
+ {
63
+ "description": "no allergies at all",
64
+ "score": 0,
65
+ "expected": []
66
+ },
67
+ {
68
+ "description": "allergic to just eggs",
69
+ "score": 1,
70
+ "expected": ["eggs"]
71
+ },
72
+ {
73
+ "description": "allergic to just peanuts",
74
+ "score": 2,
75
+ "expected": ["peanuts"]
76
+ },
77
+ {
78
+ "description": "allergic to just strawberries",
79
+ "score": 8,
80
+ "expected": ["strawberries"]
81
+ },
82
+ {
83
+ "description": "allergic to eggs and peanuts",
84
+ "score": 3,
85
+ "expected": ["eggs", "peanuts"]
86
+ },
87
+ {
88
+ "description": "allergic to more than eggs but not peanuts",
89
+ "score": 5,
90
+ "expected": ["eggs", "shellfish"]
91
+ },
92
+ {
93
+ "description": "allergic to lots of stuff",
94
+ "score": 248,
95
+ "expected": ["strawberries", "tomatoes", "chocolate", "pollen", "cats"]
96
+ },
97
+ {
98
+ "description": "allergic to everything",
99
+ "score": 255,
100
+ "expected": ["eggs", "peanuts", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats"]
101
+ },
102
+ {
103
+ "description": "ignore non allergen score parts",
104
+ "score": 509,
105
+ "expected": ["eggs", "shellfish", "strawberries", "tomatoes", "chocolate", "pollen", "cats"]
106
+ }
107
+ ]
108
+ }
109
+ }
@@ -1,9 +1,14 @@
1
+ module BookKeeping
2
+ VERSION = 1
3
+ end
4
+
1
5
  module Grains
2
6
  def self.square(number)
7
+ fail ArgumentError if number <= 0 || number > 64
3
8
  2**(number - 1)
4
9
  end
5
10
 
6
11
  def self.total
7
- square(65) - 1
12
+ 2**64 - 1
8
13
  end
9
14
  end
@@ -0,0 +1,17 @@
1
+ require 'minitest/autorun'
2
+ require_relative 'grains'
3
+
4
+ # Test data version: <%= sha1 %>
5
+ class GrainsTest < Minitest::Test<% test_cases.each do |test_case| %>
6
+ def <%= test_case.test_name %>
7
+ <%= test_case.skipped %>
8
+ <%= test_case.workload %>
9
+ end
10
+ <% end %>
11
+
12
+ <%= IO.read(XRUBY_LIB + '/bookkeeping.md') %>
13
+ def test_bookkeeping
14
+ skip
15
+ assert_equal <%= version.next %>, BookKeeping::VERSION
16
+ end
17
+ end
@@ -1,45 +1,81 @@
1
- #!/usr/bin/env ruby
2
- gem 'minitest', '>= 5.0.0'
3
1
  require 'minitest/autorun'
4
2
  require_relative 'grains'
5
3
 
4
+ # Test data version: aa12f2e
6
5
  class GrainsTest < Minitest::Test
7
- def test_square_1
6
+ def test_1
7
+ # skip
8
8
  assert_equal 1, Grains.square(1)
9
9
  end
10
10
 
11
- def test_square_2
11
+ def test_2
12
12
  skip
13
13
  assert_equal 2, Grains.square(2)
14
14
  end
15
15
 
16
- def test_square_3
16
+ def test_3
17
17
  skip
18
18
  assert_equal 4, Grains.square(3)
19
19
  end
20
20
 
21
- def test_square_4
21
+ def test_4
22
22
  skip
23
23
  assert_equal 8, Grains.square(4)
24
24
  end
25
25
 
26
- def test_square_16
26
+ def test_16
27
27
  skip
28
28
  assert_equal 32_768, Grains.square(16)
29
29
  end
30
30
 
31
- def test_square_32
31
+ def test_32
32
32
  skip
33
33
  assert_equal 2_147_483_648, Grains.square(32)
34
34
  end
35
35
 
36
- def test_square_64
36
+ def test_64
37
37
  skip
38
38
  assert_equal 9_223_372_036_854_775_808, Grains.square(64)
39
39
  end
40
40
 
41
- def test_total_grains
41
+ def test_square_0_raises_an_exception
42
+ skip
43
+ assert_raises(ArgumentError) { Grains.square(0) }
44
+ end
45
+
46
+ def test_negative_square_raises_an_exception
47
+ skip
48
+ assert_raises(ArgumentError) { Grains.square(-1) }
49
+ end
50
+
51
+ def test_square_greater_than_64_raises_an_exception
52
+ skip
53
+ assert_raises(ArgumentError) { Grains.square(65) }
54
+ end
55
+
56
+ def test_returns_the_total_number_of_grains_on_the_board
42
57
  skip
43
58
  assert_equal 18_446_744_073_709_551_615, Grains.total
44
59
  end
60
+
61
+ # Problems in exercism evolve over time, as we find better ways to ask
62
+ # questions.
63
+ # The version number refers to the version of the problem you solved,
64
+ # not your solution.
65
+ #
66
+ # Define a constant named VERSION inside of the top level BookKeeping
67
+ # module, which may be placed near the end of your file.
68
+ #
69
+ # In your file, it will look like this:
70
+ #
71
+ # module BookKeeping
72
+ # VERSION = 1 # Where the version number matches the one in the test.
73
+ # end
74
+ #
75
+ # If you are curious, read more about constants on RubyDoc:
76
+ # http://ruby-doc.org/docs/ruby-doc-bundle/UsersGuide/rg/constants.html
77
+ def test_bookkeeping
78
+ skip
79
+ assert_equal 1, BookKeeping::VERSION
80
+ end
45
81
  end
@@ -0,0 +1,51 @@
1
+ class GrainsCase < OpenStruct
2
+ def test_name
3
+ 'test_%s' % description.downcase.tr_s(' ', '_')
4
+ end
5
+
6
+ def workload
7
+ fail NotImplementedError
8
+ end
9
+
10
+ def skipped
11
+ index.zero? ? '# skip' : 'skip'
12
+ end
13
+
14
+ private
15
+
16
+ def underscore_format(number)
17
+ number.to_s.reverse.gsub(/...(?=.)/,'\&_').reverse
18
+ end
19
+ end
20
+
21
+ class GrainsCase::SquareMethod < GrainsCase
22
+ def workload
23
+ return error_assertion if expected < 0
24
+
25
+ "assert_equal #{underscore_format(expected)}, Grains.square(#{input})"
26
+ end
27
+
28
+ private
29
+
30
+ def error_assertion
31
+ "assert_raises(ArgumentError) { Grains.square(#{input}) }"
32
+ end
33
+ end
34
+
35
+ class GrainsCase::TotalMethod < GrainsCase
36
+ def workload
37
+ "assert_equal #{underscore_format(expected)}, Grains.total"
38
+ end
39
+ end
40
+
41
+ GrainsCases = proc do |data|
42
+ data = JSON.parse(data)
43
+
44
+ cases = data['square']['cases'].map.with_index do |row, i|
45
+ GrainsCase::SquareMethod.new(row.merge('index' => i))
46
+ end
47
+
48
+ cases << GrainsCase::TotalMethod.new(
49
+ data['total'].merge('index' => cases.size)
50
+ )
51
+ end
@@ -0,0 +1,103 @@
1
+ require 'json'
2
+ require_relative 'test_helper'
3
+
4
+ class GrainsTest < Minitest::Test
5
+ def test_test_name
6
+ test_case = GrainsCase.new(description: 'description')
7
+
8
+ assert_equal 'test_description', test_case.test_name
9
+ end
10
+
11
+ def test_test_name_when_description_has_spaces
12
+ test_case = GrainsCase.new(description: 'description with spaces')
13
+
14
+ assert_equal 'test_description_with_spaces', test_case.test_name
15
+ end
16
+
17
+ def test_workload_is_not_implemented
18
+ assert_raises(NotImplementedError) { GrainsCase.new.workload }
19
+ end
20
+
21
+ def test_skipped_with_zero_index
22
+ assert_equal '# skip', GrainsCase.new(index: 0).skipped
23
+ end
24
+
25
+ def test_skipped_with_non_zero_index
26
+ assert_equal 'skip', GrainsCase.new(index: 1).skipped
27
+ end
28
+ end
29
+
30
+ class SquareMethodTest < Minitest::Test
31
+ def test_workload_when_expected_is_negative
32
+ test_case = GrainsCase::SquareMethod.new(expected: -1, input: 10)
33
+
34
+ assert_equal 'assert_raises(ArgumentError) { Grains.square(10) }',
35
+ test_case.workload
36
+ end
37
+
38
+ def test_workload_when_expected_is_positive
39
+ test_case = GrainsCase::SquareMethod.new(expected: 1, input: 10)
40
+
41
+ assert_equal 'assert_equal 1, Grains.square(10)', test_case.workload
42
+ end
43
+
44
+ def test_workload_with_large_expected_number
45
+ test_case = GrainsCase::SquareMethod.new(expected: 10000, input: 10)
46
+
47
+ assert_equal 'assert_equal 10_000, Grains.square(10)', test_case.workload
48
+ end
49
+ end
50
+
51
+ class TotalMethodTest < Minitest::Test
52
+ def test_workload
53
+ test_case = GrainsCase::TotalMethod.new(expected: 1)
54
+
55
+ assert_equal 'assert_equal 1, Grains.total', test_case.workload
56
+ end
57
+
58
+ def test_workload_with_large_expected_number
59
+ test_case = GrainsCase::TotalMethod.new(expected: 10000)
60
+
61
+ assert_equal 'assert_equal 10_000, Grains.total', test_case.workload
62
+ end
63
+ end
64
+
65
+ class GrainsCasesTest < Minitest::Test
66
+ def test_handling_of_json
67
+ json = {
68
+ square: {
69
+ cases: [
70
+ {},
71
+ {},
72
+ ],
73
+ },
74
+ total: {
75
+ }
76
+ }.to_json
77
+
78
+ cases = GrainsCases.call(json)
79
+
80
+ assert_instance_of GrainsCase::SquareMethod, cases[0]
81
+ assert_instance_of GrainsCase::SquareMethod, cases[1]
82
+ assert_instance_of GrainsCase::TotalMethod, cases[2]
83
+ end
84
+
85
+ def test_continuous_index
86
+ json = {
87
+ square: {
88
+ cases: [
89
+ {},
90
+ {},
91
+ ],
92
+ },
93
+ total: {
94
+ }
95
+ }.to_json
96
+
97
+ cases = GrainsCases.call(json)
98
+
99
+ assert_equal 0, cases[0].index
100
+ assert_equal 1, cases[1].index
101
+ assert_equal 2, cases[2].index
102
+ end
103
+ end
@@ -1,3 +1,4 @@
1
+ require 'json'
1
2
  require_relative 'test_helper'
2
3
 
3
4
  class WordyCaseTest < Minitest::Test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trackler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5.17
4
+ version: 2.0.5.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-01 00:00:00.000000000 Z
11
+ date: 2017-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -5292,6 +5292,9 @@ files:
5292
5292
  - tracks/perl6/docs/TESTS.md
5293
5293
  - tracks/perl6/exercises/accumulate/Example.pm
5294
5294
  - tracks/perl6/exercises/accumulate/accumulate.t
5295
+ - tracks/perl6/exercises/allergies/Example.p6
5296
+ - tracks/perl6/exercises/allergies/allergies.t
5297
+ - tracks/perl6/exercises/allergies/cases.json
5295
5298
  - tracks/perl6/exercises/anagram/Example.pm
5296
5299
  - tracks/perl6/exercises/anagram/anagram.t
5297
5300
  - tracks/perl6/exercises/binary/Example.pm
@@ -5988,7 +5991,9 @@ files:
5988
5991
  - tracks/ruby/exercises/gigasecond/gigasecond_test.rb
5989
5992
  - tracks/ruby/exercises/grade-school/example.rb
5990
5993
  - tracks/ruby/exercises/grade-school/grade_school_test.rb
5994
+ - tracks/ruby/exercises/grains/.meta/.version
5991
5995
  - tracks/ruby/exercises/grains/example.rb
5996
+ - tracks/ruby/exercises/grains/example.tt
5992
5997
  - tracks/ruby/exercises/grains/grains_test.rb
5993
5998
  - tracks/ruby/exercises/hamming/.meta/.version
5994
5999
  - tracks/ruby/exercises/hamming/example.rb
@@ -6163,6 +6168,7 @@ files:
6163
6168
  - tracks/ruby/lib/dominoes_cases.rb
6164
6169
  - tracks/ruby/lib/generator.rb
6165
6170
  - tracks/ruby/lib/gigasecond_cases.rb
6171
+ - tracks/ruby/lib/grains_cases.rb
6166
6172
  - tracks/ruby/lib/hamming_cases.rb
6167
6173
  - tracks/ruby/lib/hello_world_cases.rb
6168
6174
  - tracks/ruby/lib/helper.rb
@@ -6189,6 +6195,7 @@ files:
6189
6195
  - tracks/ruby/test/fixtures/exercises/alpha/example.tt
6190
6196
  - tracks/ruby/test/fixtures/metadata/exercises/alpha/canonical-data.json
6191
6197
  - tracks/ruby/test/generator_test.rb
6198
+ - tracks/ruby/test/grains_cases_test.rb
6192
6199
  - tracks/ruby/test/test_helper.rb
6193
6200
  - tracks/ruby/test/wordy_cases_test.rb
6194
6201
  - tracks/rust/.git