mutant 0.3.0.beta18 → 0.3.0.beta19

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: 89bc8e83f49c94e59ba0950d67bced72a35bb072
4
- data.tar.gz: aa8fe5e09af20fdc68063ec8647c1188bfe27fe4
3
+ metadata.gz: cd13dcc39d401fa798781aa0bf540654ccda03d3
4
+ data.tar.gz: 32b01710b1a1214b94996389fbd95cb2e06eca15
5
5
  SHA512:
6
- metadata.gz: ae3957cab51a09be0c87e94e5372ecb7ee67b7c73debba0e75e5003990ebe7c39ded769a402c03f3d9162deeb24cccbb4237f95d88168e6edb104936aabe216a
7
- data.tar.gz: 8afc1deb30fccd538d3f4d67d14ebf6afb6895cef7a013aa582fc10a9d111f7531665c2c461e6997315dfaf225091eeb19e44376f72de757e908841990d354de
6
+ metadata.gz: 08e171e88fd7fd7dbae3130694c983ca35db23f9b8018f395e0bb1ba8c6f5e43876e9fe510d54b0d405f4d651f2129688baf40ad4002a2bf72f417dbbda84d13
7
+ data.tar.gz: e483bea1d72eeb4c5010589fe68cb73e05b5da52c8735d1b4fb76c118728d424a7d18100754ea5667d802c1122d666b7884b9b72a389031c478e28a16b291568
data/Gemfile.devtools CHANGED
@@ -14,26 +14,27 @@ group :guard do
14
14
  gem 'guard', '~> 1.8.1'
15
15
  gem 'guard-bundler', '~> 1.0.0'
16
16
  gem 'guard-rspec', '~> 3.0.2'
17
- # gem 'guard-rubocop', '~> 0.2.0'
17
+ gem 'guard-rubocop', '~> 0.2.0'
18
+ gem 'guard-mutant', '~> 0.0.1'
18
19
 
19
20
  # file system change event handling
20
21
  gem 'listen', '~> 1.2.2'
21
- gem 'rb-fchange', '~> 0.0.6', :require => false
22
- gem 'rb-fsevent', '~> 0.9.3', :require => false
23
- gem 'rb-inotify', '~> 0.9.0', :require => false
22
+ gem 'rb-fchange', '~> 0.0.6', require: false
23
+ gem 'rb-fsevent', '~> 0.9.3', require: false
24
+ gem 'rb-inotify', '~> 0.9.0', require: false
24
25
 
25
26
  # notification handling
26
- gem 'libnotify', '~> 0.8.0', :require => false
27
- gem 'rb-notifu', '~> 0.0.4', :require => false
28
- gem 'terminal-notifier-guard', '~> 1.5.3', :require => false
27
+ gem 'libnotify', '~> 0.8.0', require: false
28
+ gem 'rb-notifu', '~> 0.0.4', require: false
29
+ gem 'terminal-notifier-guard', '~> 1.5.3', require: false
29
30
  end
30
31
 
31
32
  group :metrics do
32
33
  gem 'coveralls', '~> 0.6.7'
33
34
  gem 'flay', '~> 2.3.1'
34
35
  gem 'flog', '~> 4.1.1'
35
- gem 'reek', '~> 1.3.1', :git => 'https://github.com/troessner/reek.git'
36
- # gem 'rubocop', '~> 0.9.1'
36
+ gem 'reek', '~> 1.3.1', git: 'https://github.com/troessner/reek.git'
37
+ gem 'rubocop', '~> 0.10.0', git: 'https://github.com/bbatsov/rubocop.git'
37
38
  gem 'simplecov', '~> 0.7.1'
38
39
  gem 'yardstick', '~> 0.9.6'
39
40
 
@@ -41,10 +42,6 @@ group :metrics do
41
42
  gem 'yard-spellcheck', '~> 0.1.5'
42
43
  end
43
44
 
44
- platforms :ruby_19 do
45
- gem 'json', '~> 1.8.0'
46
- end
47
-
48
45
  platforms :rbx do
49
46
  gem 'pelusa', '~> 0.2.2'
50
47
  end
data/README.md CHANGED
@@ -56,7 +56,7 @@ Mutations
56
56
  Mutant supports a very wide range of mutation operators. Listing them all in detail would blow this document up.
57
57
 
58
58
  It is planned to parse a list of mutation operators from the source. In the meantime please refer to the
59
- [code](https://github.com/mbj/mutant/tree/master/lib/mutant/mutator/node) each subclass of `Mutant::Mutator::Node`
59
+ [code](https://github.com/mbj/mutant/tree/master/lib/mutant/mutator/node) each subclass of `Mutant::Mutator::Node`
60
60
  emits around 3-6 mutations.
61
61
 
62
62
  Currently mutant covers the majority of ruby's complex nodes that often occur in method bodies.
@@ -75,7 +75,7 @@ Alive: 57 # Amount of alive mutations.
75
75
  ```
76
76
 
77
77
 
78
- Nodes still missing a dedicated mutator are handled via the
78
+ Nodes still missing a dedicated mutator are handled via the
79
79
  [Generic](https://github.com/mbj/mutant/blob/master/lib/mutant/mutator/node/generic.rb) mutator.
80
80
  The goal is to remove this mutator and have dedicated mutator for every type of node and removing
81
81
  the Generic handler altogether.
data/config/rubocop.yml CHANGED
@@ -1,8 +1,11 @@
1
1
  AllCops:
2
2
  Includes:
3
3
  - '../**/*.rake'
4
+ - 'Gemfile'
5
+ - 'Gemfile.devtools'
4
6
  Excludes:
5
- - '../vendor/**'
7
+ - '**/vendor/**'
8
+ - '**/benchmarks/**'
6
9
 
7
10
  # Avoid parameter lists longer than five parameters.
8
11
  ParameterLists:
data/lib/mutant.rb CHANGED
@@ -20,7 +20,9 @@ require 'concord'
20
20
 
21
21
  # Library namespace
22
22
  module Mutant
23
- end
23
+ # The empty string used within this namespace
24
+ EMPTY_STRING = ''.freeze
25
+ end # Mutant
24
26
 
25
27
  require 'mutant/cache'
26
28
  require 'mutant/node_helpers'
@@ -56,6 +58,7 @@ require 'mutant/mutator/node/assignment'
56
58
  require 'mutant/mutator/node/argument'
57
59
  require 'mutant/mutator/node/arguments'
58
60
  require 'mutant/mutator/node/begin'
61
+ require 'mutant/mutator/node/lvar'
59
62
  require 'mutant/mutator/node/while'
60
63
  require 'mutant/mutator/node/super'
61
64
  require 'mutant/mutator/node/send'
@@ -10,7 +10,8 @@ module Mutant
10
10
  OPERATOR_PATTERN = Regexp.union(*OPERATOR_METHODS.map(&:to_s)).freeze
11
11
  METHOD_NAME_PATTERN = /([_A-Za-z][A-Za-z0-9_]*[!?=]?|#{OPERATOR_PATTERN})/.freeze
12
12
  SCOPE_PATTERN = /(?:::)?#{SCOPE_NAME_PATTERN}(?:::#{SCOPE_NAME_PATTERN})*/.freeze
13
-
13
+ CBASE_PATTERN = /\A::/.freeze
14
+ SCOPE_OPERATOR = '::'.freeze
14
15
  SINGLETON_PATTERN = %r(\A(#{SCOPE_PATTERN})\z).freeze
15
16
 
16
17
  REGISTRY = []
@@ -35,7 +36,7 @@ module Mutant
35
36
  # @api private
36
37
  #
37
38
  def self.constant_lookup(location)
38
- location.gsub(%r(\A::), '').split('::').inject(Object) do |parent, name|
39
+ location.gsub(CBASE_PATTERN, EMPTY_STRING).split(SCOPE_OPERATOR).inject(Object) do |parent, name|
39
40
  parent.const_get(name)
40
41
  end
41
42
  end
@@ -20,12 +20,7 @@ module Mutant
20
20
  # TODO: replace with real streams from configuration
21
21
  require 'stringio'
22
22
  null = StringIO.new
23
- argv = command_line_arguments
24
- begin
25
- !::RSpec::Core::Runner.run(argv, null, null).zero?
26
- rescue StandardError
27
- true
28
- end
23
+ !::RSpec::Core::Runner.run(command_line_arguments, null, null).zero?
29
24
  end
30
25
 
31
26
  # Return command line arguments
@@ -1,6 +1,7 @@
1
1
  module Mutant
2
2
  class Mutator
3
3
  class Node
4
+
4
5
  # Generic mutator
5
6
  class Generic < self
6
7
 
@@ -12,7 +13,7 @@ module Mutant
12
13
  :zsuper, :not, :or, :and, :defined,
13
14
  :next, :break, :match, :gvar, :cvar, :ensure,
14
15
  :dstr, :dsym, :yield, :rescue, :redo, :defined?,
15
- :lvar, :const, :blockarg, :block_pass, :op_asgn, :and_asgn,
16
+ :const, :blockarg, :block_pass, :op_asgn, :and_asgn,
16
17
  :regopt, :ivar, :restarg, :casgn, :resbody, :retry, :arg_expr,
17
18
  :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :cbase, :empty,
18
19
  :alias, :for, :xstr, :back_ref, :nth_ref, :class,
@@ -7,8 +7,6 @@ module Mutant
7
7
 
8
8
  handle(:regexp)
9
9
 
10
- EMPTY_STRING = ''.freeze
11
-
12
10
  # No input can ever be matched with this
13
11
  NULL_REGEXP_SOURCE = 'a\A'.freeze
14
12
 
@@ -0,0 +1,25 @@
1
+ module Mutant
2
+ class Mutator
3
+ class Node
4
+
5
+ # Mutation emitter to handle local variable nodes
6
+ class LocalVariable < self
7
+
8
+ handle(:lvar)
9
+
10
+ private
11
+
12
+ # Emit mutations
13
+ #
14
+ # @return [undefined]
15
+ #
16
+ # @api private
17
+ #
18
+ def dispatch
19
+ emit_nil
20
+ end
21
+
22
+ end # LocalVariable
23
+ end # Node
24
+ end # Mutator
25
+ end # Mutant
@@ -2,7 +2,7 @@ module Mutant
2
2
  class Mutator
3
3
  class Node
4
4
 
5
- # Mutation emitter to handle multipl assignment nodes
5
+ # Mutation emitter to handle multiple assignment nodes
6
6
  class MultipleAssignment < self
7
7
 
8
8
  handle(:masgn)
data/mutant.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'mutant'
5
- gem.version = '0.3.0.beta18'
5
+ gem.version = '0.3.0.beta19'
6
6
  gem.authors = [ 'Markus Schirp' ]
7
7
  gem.email = [ 'mbj@schirp-dso.com' ]
8
8
 
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Mutator, 'lvar' do
4
+
5
+ before do
6
+ Mutant::Random.stub(:hex_string => 'random')
7
+ end
8
+
9
+ let(:source) { 'a = nil; a' }
10
+
11
+ let(:mutations) do
12
+ mutants = []
13
+ mutants << 'a = nil; nil'
14
+ mutants << 'a = nil'
15
+ mutants << 'a'
16
+ mutants << 'a = ::Object.new; a'
17
+ mutants << 'srandom = nil; a'
18
+ end
19
+
20
+ it_should_behave_like 'a mutator'
21
+ end
@@ -6,7 +6,6 @@ describe Mutant::Mutator, 'masgn' do
6
6
  Mutant::Random.stub(:hex_string => 'random')
7
7
  end
8
8
 
9
-
10
9
  let(:source) { 'a, b = c, d' }
11
10
 
12
11
  let(:mutations) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.beta18
4
+ version: 0.3.0.beta19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-21 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -240,6 +240,7 @@ files:
240
240
  - lib/mutant/mutator/node/literal/regex.rb
241
241
  - lib/mutant/mutator/node/literal/string.rb
242
242
  - lib/mutant/mutator/node/literal/symbol.rb
243
+ - lib/mutant/mutator/node/lvar.rb
243
244
  - lib/mutant/mutator/node/masgn.rb
244
245
  - lib/mutant/mutator/node/mlhs.rb
245
246
  - lib/mutant/mutator/node/return.rb
@@ -334,6 +335,7 @@ files:
334
335
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
335
336
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
336
337
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
338
+ - spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
337
339
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
338
340
  - spec/unit/mutant/mutator/node/return/mutation_spec.rb
339
341
  - spec/unit/mutant/mutator/node/send/mutation_spec.rb
@@ -441,6 +443,7 @@ test_files:
441
443
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
442
444
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
443
445
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
446
+ - spec/unit/mutant/mutator/node/lvar/mutation_spec.rb
444
447
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
445
448
  - spec/unit/mutant/mutator/node/return/mutation_spec.rb
446
449
  - spec/unit/mutant/mutator/node/send/mutation_spec.rb