mutant 0.3.0.rc3 → 0.3.0.rc4

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -3
  3. data/{Gemfile.devtools → Gemfile.triage} +2 -2
  4. data/README.md +14 -9
  5. data/Rakefile +2 -2
  6. data/TODO +0 -3
  7. data/config/flay.yml +1 -1
  8. data/config/rubocop.yml +22 -1
  9. data/config/{devtools.yml → triage.yml} +0 -0
  10. data/lib/mutant.rb +4 -0
  11. data/lib/mutant/cli/classifier.rb +2 -4
  12. data/lib/mutant/differ.rb +2 -6
  13. data/lib/mutant/mutator.rb +0 -1
  14. data/lib/mutant/mutator/node/argument.rb +1 -1
  15. data/lib/mutant/mutator/node/generic.rb +4 -4
  16. data/lib/mutant/mutator/node/kwbegin.rb +28 -0
  17. data/lib/mutant/mutator/node/literal/float.rb +5 -1
  18. data/lib/mutant/mutator/node/literal/range.rb +0 -1
  19. data/lib/mutant/mutator/node/loop_control.rb +35 -0
  20. data/lib/mutant/mutator/node/resbody.rb +45 -0
  21. data/lib/mutant/mutator/node/yield.rb +29 -0
  22. data/lib/mutant/reporter/cli/printer/config.rb +1 -0
  23. data/lib/mutant/subject/method/instance.rb +11 -0
  24. data/lib/mutant/version.rb +1 -1
  25. data/mutant.gemspec +3 -2
  26. data/spec/spec_helper.rb +1 -1
  27. data/spec/unit/mutant/cli/classifier/method_spec.rb +1 -1
  28. data/spec/unit/mutant/cli/classifier/namespace/flat_spec.rb +3 -3
  29. data/spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb +3 -3
  30. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +15 -0
  31. data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +2 -1
  32. data/spec/unit/mutant/mutator/node/kwbegin/mutation_spec.rb +16 -0
  33. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +50 -15
  34. data/spec/unit/mutant/mutator/node/loop_ctrl_spec.rb +37 -0
  35. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +60 -11
  36. data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +4 -2
  37. data/spec/unit/mutant/runner/config/subjects_spec.rb +2 -2
  38. data/spec/unit/mutant/strategy_spec.rb +0 -1
  39. data/spec/unit/mutant/subject/method/instance_spec.rb +35 -0
  40. metadata +33 -13
  41. data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +0 -15
  42. data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc1edb6a066367798606c3707b5c77927e5dafbe
4
- data.tar.gz: d1e2b2225fca865cf99a5b74bb9e19a08ec0a6d5
3
+ metadata.gz: 87d33982459e4caf9811b385e18475535904176c
4
+ data.tar.gz: 3c92be157bed88329abe5dcd26969aa6f8d0b112
5
5
  SHA512:
6
- metadata.gz: cd359fe733c8fd859bdff3c5046ce2846a5d84a844f983deecc396a885747420abc31f30be1132b8d5ef85f21f9c35aa888e85456d57a9d662f0f41617f535ab
7
- data.tar.gz: 331ae4cddc5e811c84826dd0ab0927b5099bc0ed8bc3909532169a2045c363e49e0be56843e24c38eb30751f7c9f947a6b91b1b9d15ebb1c9a49f16f837e687d
6
+ metadata.gz: eefc160831c193a9c6cc08b76b1272421dde563bd4a0d6702c5030c0939a007b8b3661a390bad70183ec950bfb97d0b0605b01ee6669cabbdccbb4c993c120af
7
+ data.tar.gz: 65fb0f377537f48b934cd5be1838f9ef657cba877f34180ba28033d7f2a702ffaf27caf53cb1238ba704193268c722e363b21353613d592cf61620b8451f443f
data/Gemfile CHANGED
@@ -7,7 +7,6 @@ gemspec
7
7
  gem 'mutant', path: '.'
8
8
 
9
9
  group :development, :test do
10
- gem 'devtools', git: 'https://github.com/rom-rb/devtools.git'
10
+ gem 'triage', git: 'https://github.com/rom-rb/devtools.git', branch: 'triage-rename'
11
+ gem 'triage-deps', git: 'https://github.com/rom-rb/devtools.git', branch: 'triage-rename'
11
12
  end
12
-
13
- eval_gemfile File.join(File.dirname(__FILE__), 'Gemfile.devtools')
@@ -30,11 +30,11 @@ group :guard do
30
30
  end
31
31
 
32
32
  group :metrics do
33
- gem 'coveralls', '~> 0.6.7'
33
+ gem 'coveralls', '~> 0.7.0'
34
34
  gem 'flay', '~> 2.4.0'
35
35
  gem 'flog', '~> 4.1.1'
36
36
  gem 'reek', '~> 1.3.2'
37
- gem 'rubocop', '~> 0.13.0'
37
+ gem 'rubocop', '~> 0.14.1'
38
38
  gem 'simplecov', '~> 0.7.1'
39
39
  gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
40
40
 
data/README.md CHANGED
@@ -33,6 +33,8 @@ The following projects adopted mutant, and aim 100% mutation coverage:
33
33
  * [quacky](https://github.com/benmoss/quacky)
34
34
  * [substation](https://github.com/snusnu/substation)
35
35
  * [large_binomials](https://github.com/filipvanlaenen/large_binomials)
36
+ * [promise.rb](https://github.com/lgierth/promise.rb)
37
+ * [full_name](https://github.com/AGILiDEE/full_name)
36
38
  * various small/minor stuff under https://github.com/mbj
37
39
 
38
40
  Feel free to ping me to add your project to the list!
@@ -84,15 +86,23 @@ Examples
84
86
  ```
85
87
  cd virtus
86
88
  # Run mutant on virtus namespace
87
- mutant --rspec '::Virtus*'
89
+ mutant --include lib --require virtus --rspec ::Virtus*
88
90
  # Run mutant on specific virtus class
89
- mutant --rspec ::Virtus::Attribute
91
+ mutant --include lib --require virtus --rspec ::Virtus::Attribute
90
92
  # Run mutant on specific virtus class method
91
- mutant --rspec ::Virtus::Attribute.build
93
+ mutant --include lib --require virtus --rspec ::Virtus::Attribute.build
92
94
  # Run mutant on specific virtus instance method
93
- mutant --rspec ::Virtus::Attribute#name
95
+ mutant --include lib --require virtus --rspec ::Virtus::Attribute#type
94
96
  ```
95
97
 
98
+ Presentations:
99
+ --------------
100
+
101
+ There are some presentations about mutant in the wild:
102
+
103
+ * [Eurocamp-2013](http://2013.eurucamp.org/) / FrOSCon-2013 http://slid.es/markusschirp/mutation-testing
104
+ * [Cologne.rb](http://www.colognerb.de/topics/mutation-testing-mit-mutant) https://github.com/DonSchado/colognerb-on-mutant/blob/master/mutation_testing_slides.pdf
105
+
96
106
  Subjects:
97
107
  ---------
98
108
 
@@ -114,11 +124,6 @@ current prefix level, these example groups *must* kill the mutation.
114
124
  This test selection strategy is compatible with the old `--rspec-dm2` and `--rspec-unit` strategy.
115
125
  The old flags where removed. It allows to define very fine grained specs, or coarse grained - as you like.
116
126
 
117
- Alternatives
118
- ------------
119
-
120
- * [heckle](https://github.com/seattlerb/heckle)
121
-
122
127
  Support
123
128
  -------
124
129
 
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'devtools'
3
+ require 'triage'
4
4
 
5
- Devtools.init_rake_tasks
5
+ Triage.init_rake_tasks
6
6
 
7
7
  Rake.application.load_imports
8
8
  task('metrics:mutant').clear
data/TODO CHANGED
@@ -1,6 +1,5 @@
1
1
  Code:
2
2
  * Test mutant with dynamically created zombie.
3
- * Break up lib/mutant/mutator/node/send.rb in class specific files
4
3
  * Log all warnings through reporter, so remove random $stderr.puts calls
5
4
 
6
5
  Mutations:
@@ -12,9 +11,7 @@ Mutations:
12
11
  * Mutate options on Regexp literals
13
12
  * Add mutations for dynamic regexp symbol and string literals
14
13
  * Mutate "def foo; bar; end" to "def foo; self; end"?
15
- * Emit negative and positive mutations
16
14
  * Mutate Block catch "def foo(&block)" and block pass "foo(&block)"
17
- * Mutate super arguments just like send arguments
18
15
  * Binary operator mutations
19
16
  * Add timeout to terminate infinite loops
20
17
 
data/config/flay.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  ---
2
2
  threshold: 18
3
- total_score: 762
3
+ total_score: 784
data/config/rubocop.yml CHANGED
@@ -1,8 +1,14 @@
1
+ # General note about rubocop.
2
+ # It does NOT allow to silence a specific rule violation.
3
+ # For that reason I sometimes have to disable a whole cop where
4
+ # I just tried to whitelist a specific occurence.
5
+
6
+
1
7
  AllCops:
2
8
  Includes:
3
9
  - '../**/*.rake'
4
10
  - 'Gemfile'
5
- - 'Gemfile.devtools'
11
+ - 'Gemfile.triage'
6
12
  - 'mutant.gemspec'
7
13
  Excludes:
8
14
  - '**/vendor/**'
@@ -83,3 +89,18 @@ TrivialAccessors:
83
89
  # And also have a differend opinion here
84
90
  AndOr:
85
91
  Enabled: false
92
+
93
+ # I like my raise
94
+ SignalException:
95
+ Enabled: false
96
+
97
+ # I need to chain optparse builder, else it is more ugly
98
+ MultilineBlockChain:
99
+ Enabled: false
100
+
101
+ ClassLength:
102
+ Max: 105
103
+
104
+ # I align private keywords with class body
105
+ IndentationWidth:
106
+ Enabled: false
File without changes
data/lib/mutant.rb CHANGED
@@ -68,12 +68,15 @@ require 'mutant/mutator/node/connective/binary'
68
68
  require 'mutant/mutator/node/const'
69
69
  require 'mutant/mutator/node/dstr'
70
70
  require 'mutant/mutator/node/dsym'
71
+ require 'mutant/mutator/node/kwbegin'
71
72
  require 'mutant/mutator/node/named_value/access'
72
73
  require 'mutant/mutator/node/named_value/constant_assignment'
73
74
  require 'mutant/mutator/node/named_value/variable_assignment'
75
+ require 'mutant/mutator/node/loop_control'
74
76
  require 'mutant/mutator/node/noop'
75
77
  require 'mutant/mutator/node/op_asgn'
76
78
  require 'mutant/mutator/node/while'
79
+ require 'mutant/mutator/node/yield'
77
80
  require 'mutant/mutator/node/super'
78
81
  require 'mutant/mutator/node/zsuper'
79
82
  require 'mutant/mutator/node/restarg'
@@ -89,6 +92,7 @@ require 'mutant/mutator/node/block'
89
92
  require 'mutant/mutator/node/if'
90
93
  require 'mutant/mutator/node/case'
91
94
  require 'mutant/mutator/node/splat'
95
+ require 'mutant/mutator/node/resbody'
92
96
  require 'mutant/config'
93
97
  require 'mutant/loader'
94
98
  require 'mutant/context'
@@ -44,11 +44,9 @@ module Mutant
44
44
  # @api private
45
45
  #
46
46
  def self.constant_lookup(location)
47
- location
48
- .sub(CBASE_PATTERN, EMPTY_STRING)
49
- .split(SCOPE_OPERATOR)
47
+ location.sub(CBASE_PATTERN, EMPTY_STRING).split(SCOPE_OPERATOR)
50
48
  .reduce(Object) do |parent, name|
51
- parent.const_get(name, nil)
49
+ parent.const_get(name, nil)
52
50
  end
53
51
  end
54
52
 
data/lib/mutant/differ.rb CHANGED
@@ -16,16 +16,12 @@ module Mutant
16
16
  # @api private
17
17
  #
18
18
  def diff
19
- output = ''
20
19
  case diffs.length
21
20
  when 0
22
21
  nil
23
22
  when 1
24
- output =
25
- Diff::LCS::Hunk.new(
26
- old, new, diffs.first, max_length, 0
27
- ).diff(:unified)
28
- output << "\n"
23
+ Diff::LCS::Hunk.new(old, new, diffs.first, max_length, 0)
24
+ .diff(:unified) << "\n"
29
25
  else
30
26
  $stderr.puts(
31
27
  'Mutation resulted in more than one diff, should not happen! ' +
@@ -8,7 +8,6 @@ module Mutant
8
8
  # Run mutator on input
9
9
  #
10
10
  # @param [Parser::AST::Node] node
11
- # @param [#call] block
12
11
  #
13
12
  # @return [self]
14
13
  #
@@ -21,7 +21,6 @@ module Mutant
21
21
  # @api private
22
22
  #
23
23
  def dispatch
24
- return if skip?
25
24
  emit_name_mutation
26
25
  end
27
26
 
@@ -32,6 +31,7 @@ module Mutant
32
31
  # @api private
33
32
  #
34
33
  def emit_name_mutation
34
+ return if skip?
35
35
  Mutator::Util::Symbol.each(name, self) do |name|
36
36
  emit_name(name)
37
37
  end
@@ -10,12 +10,12 @@ module Mutant
10
10
  # These nodes still need a dedicated mutator,
11
11
  # your contribution is that close!
12
12
  handle(
13
- :next, :break, :ensure,
14
- :yield, :rescue, :redo, :defined?,
15
- :regopt, :resbody, :retry, :arg_expr,
13
+ :ensure,
14
+ :rescue, :redo, :defined?,
15
+ :regopt, :retry, :arg_expr,
16
16
  :kwrestarg, :kwoptarg, :kwarg, :undef, :module, :empty,
17
17
  :alias, :for, :xstr, :back_ref, :class,
18
- :sclass, :match_with_lvasgn, :match_current_line, :kwbegin
18
+ :sclass, :match_with_lvasgn, :match_current_line
19
19
  )
20
20
 
21
21
  private
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+
7
+ # Kwbegin mutator
8
+ class Kwbegin < Generic
9
+
10
+ handle(:kwbegin)
11
+
12
+ private
13
+
14
+ # Emit mutations
15
+ #
16
+ # @return [undefined]
17
+ #
18
+ # @api private
19
+ #
20
+ def dispatch
21
+ super
22
+ emit_nil
23
+ end
24
+
25
+ end # Kwbegin
26
+ end # Node
27
+ end # Mutator
28
+ end # Mutant
@@ -49,7 +49,11 @@ module Mutant
49
49
  # @api private
50
50
  #
51
51
  def values
52
- [0.0, 1.0, -children.first]
52
+ original = children.first
53
+ # Work around a bug in RBX/MRI or JRUBY:
54
+ [0.0, 1.0, -original].delete_if do |value|
55
+ value.eql?(original)
56
+ end
53
57
  end
54
58
 
55
59
  end # Float
@@ -7,7 +7,6 @@ module Mutant
7
7
 
8
8
  # Abstract literal range mutator
9
9
  class Range < self
10
- include AbstractType
11
10
 
12
11
  MAP = {
13
12
  irange: :erange,
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+
7
+ # Mutator for loop control keywords
8
+ class LoopControl < Generic
9
+
10
+ INVERSE = IceNine.deep_freeze(
11
+ next: :break,
12
+ break: :next
13
+ )
14
+
15
+ handle(*INVERSE.keys)
16
+
17
+ private
18
+
19
+ # Emit mutations
20
+ #
21
+ # @return [undefined]
22
+ #
23
+ # @api private
24
+ #
25
+ def dispatch
26
+ super
27
+ children.each_index(&method(:delete_child))
28
+ emit(s(INVERSE.fetch(node.type), *children))
29
+ emit_nil
30
+ end
31
+
32
+ end # Next
33
+ end # Node
34
+ end # Mutator
35
+ end # Mutant
@@ -0,0 +1,45 @@
1
+ module Mutant
2
+ class Mutator
3
+ class Node
4
+ # Mutator for resbody nodes
5
+ class Resbody < self
6
+
7
+ handle(:resbody)
8
+
9
+ children :captures, :assignment, :block
10
+
11
+ private
12
+
13
+ # Emit mutations
14
+ #
15
+ # @return [undefined]
16
+ #
17
+ # @api private
18
+ #
19
+ def dispatch
20
+ emit_assignment(nil)
21
+ emit_block_mutations if block
22
+ mutate_captures
23
+ end
24
+
25
+ # Mutate captures
26
+ #
27
+ # @return [undefined]
28
+ #
29
+ # @api private
30
+ #
31
+ def mutate_captures
32
+ return unless captures
33
+ emit_captures(nil)
34
+ Util::Array.each(captures.children, self) do |matchers|
35
+ next if matchers.empty?
36
+ emit_captures(s(:array, *matchers))
37
+ # p capture
38
+ # emit_captures(s(:array, *capture))
39
+ end
40
+ end
41
+
42
+ end # Resbody
43
+ end # Node
44
+ end # Mutator
45
+ end # Mutant
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Mutant
4
+ class Mutator
5
+ class Node
6
+
7
+ # Yield mutator
8
+ class Yield < Generic
9
+
10
+ handle(:yield)
11
+
12
+ private
13
+
14
+ # Emit mutations
15
+ #
16
+ # @return [undefined]
17
+ #
18
+ # @api private
19
+ #
20
+ def dispatch
21
+ super
22
+ children.each_index(&method(:delete_child))
23
+ emit_nil
24
+ end
25
+
26
+ end # Yield
27
+ end # Node
28
+ end # Mutator
29
+ end # Mutant
@@ -117,6 +117,7 @@ module Mutant
117
117
  #
118
118
  def print_generic_stats
119
119
  stats = generic_stats.to_a.sort_by(&:last)
120
+ return if stats.empty?
120
121
  info('Nodes handled by generic mutator (type:occurrences):')
121
122
  stats.reverse_each do |type, amount|
122
123
  info('%-10s: %d', type, amount)
@@ -30,6 +30,17 @@ module Mutant
30
30
  class Memoized < self
31
31
  include NodeHelpers
32
32
 
33
+ # Return source
34
+ #
35
+ # @return [String]
36
+ #
37
+ # @api private
38
+ #
39
+ def source
40
+ Unparser.unparse(memoizer_node(node))
41
+ end
42
+ memoize :source
43
+
33
44
  private
34
45
 
35
46
  # Return mutations
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # The current mutant version
5
- VERSION = '0.3.0.rc3'.freeze
5
+ VERSION = '0.3.0.rc4'.freeze
6
6
  end # Mutant
data/mutant.gemspec CHANGED
@@ -18,8 +18,9 @@ Gem::Specification.new do |gem|
18
18
  gem.extra_rdoc_files = %w[TODO LICENSE]
19
19
  gem.executables = %w[mutant]
20
20
 
21
- gem.add_runtime_dependency('parser', '~> 2.0.0.pre7')
22
- gem.add_runtime_dependency('unparser', '~> 0.1.2')
21
+ gem.add_runtime_dependency('parser', '~> 2.0.0')
22
+ gem.add_runtime_dependency('abstract_type', '~> 0.0.7')
23
+ gem.add_runtime_dependency('unparser', '~> 0.1.4')
23
24
  gem.add_runtime_dependency('ice_nine', '~> 0.9')
24
25
  gem.add_runtime_dependency('descendants_tracker', '~> 0.0.1')
25
26
  gem.add_runtime_dependency('adamantium', '~> 0.1.0')
data/spec/spec_helper.rb CHANGED
@@ -22,7 +22,7 @@ if ENV['COVERAGE'] == 'true'
22
22
  end
23
23
 
24
24
  require 'equalizer'
25
- require 'devtools/spec_helper'
25
+ require 'triage/spec_helper'
26
26
  require 'mutant'
27
27
 
28
28
  $LOAD_PATH << File.join(TestApp.root, 'lib')
@@ -11,7 +11,7 @@ describe Mutant::CLI::Classifier::Method, '#each' do
11
11
  let(:unknown_method) { '::TestApp::Literal#unknown' }
12
12
 
13
13
  context 'with a block' do
14
- subject { object.each {} }
14
+ subject { object.each { } }
15
15
 
16
16
  context 'with an instance method name' do
17
17
  let(:input) { instance_method }
@@ -9,7 +9,7 @@ describe Mutant::CLI::Classifier::Namespace::Flat, '#each' do
9
9
  let(:unknown_namespace) { '::TestApp::Object' }
10
10
 
11
11
  context 'with a block' do
12
- subject { object.each {} }
12
+ subject { object.each { } }
13
13
 
14
14
  context 'with a known namespace' do
15
15
  let(:input) { known_namespace }
@@ -32,7 +32,7 @@ describe Mutant::CLI::Classifier::Namespace::Flat, '#each' do
32
32
  end
33
33
 
34
34
  context 'without a block' do
35
- subject { object.each }
35
+ subject { object.each }
36
36
 
37
37
  context 'with a known namespace' do
38
38
  let(:input) { known_namespace }
@@ -51,7 +51,7 @@ describe Mutant::CLI::Classifier::Namespace::Flat, '#each' do
51
51
  let(:input) { unknown_namespace }
52
52
 
53
53
  it 'raises an exception when #each is called' do
54
- expect { subject.each {} }.to raise_error(NameError)
54
+ expect { subject.each { } }.to raise_error(NameError)
55
55
  end
56
56
  end
57
57
  end
@@ -9,7 +9,7 @@ describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
9
9
  let(:unknown_namespace) { '::TestApp::Object' }
10
10
 
11
11
  context 'with a block' do
12
- subject { object.each {} }
12
+ subject { object.each { } }
13
13
 
14
14
  context 'with a known namespace' do
15
15
  let(:input) { known_namespace }
@@ -32,7 +32,7 @@ describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
32
32
  end
33
33
 
34
34
  context 'without a block' do
35
- subject { object.each }
35
+ subject { object.each }
36
36
 
37
37
  context 'with a known namespace' do
38
38
  let(:input) { known_namespace }
@@ -51,7 +51,7 @@ describe Mutant::CLI::Classifier::Namespace::Recursive, '#each' do
51
51
  let(:input) { unknown_namespace }
52
52
 
53
53
  it 'raises an exception when #each is called' do
54
- expect { subject.each {} }.to raise_error(NameError)
54
+ expect { subject.each { } }.to raise_error(NameError)
55
55
  end
56
56
  end
57
57
  end
@@ -79,6 +79,21 @@ describe Mutant::Mutator, 'def' do
79
79
  it_should_behave_like 'a mutator'
80
80
  end
81
81
 
82
+ context 'with optional argument beginning in an underscore' do
83
+ let(:source) { 'def foo(_unused = true); end' }
84
+
85
+ let(:mutations) do
86
+ mutations = []
87
+ mutations << 'def foo(_unused = nil); end'
88
+ mutations << 'def foo(_unused = false); end'
89
+ mutations << 'def foo(_unused = true); raise; end'
90
+ mutations << 'def foo(_unused); end'
91
+ mutations << 'def foo; end'
92
+ end
93
+
94
+ it_should_behave_like 'a mutator'
95
+ end
96
+
82
97
  context 'default argument' do
83
98
  let(:source) { 'def foo(a = true); end' }
84
99
 
@@ -3,12 +3,13 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Generic, 'ensure' do
6
- let(:source) { 'begin; rescue; ensure; true; end' }
6
+ let(:source) { 'begin; rescue; ensure; true; end' }
7
7
 
8
8
  let(:mutations) do
9
9
  mutations = []
10
10
  mutations << 'begin; rescue; ensure; false; end'
11
11
  mutations << 'begin; rescue; ensure; nil; end'
12
+ mutations << 'nil'
12
13
  end
13
14
 
14
15
  it_should_behave_like 'a mutator'
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Kwbegin, 'kwbegin' do
6
+ let(:source) { 'begin; true; end' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'begin; false; end'
11
+ mutations << 'begin; nil; end'
12
+ mutations << 'nil'
13
+ end
14
+
15
+ it_should_behave_like 'a mutator'
16
+ end
@@ -3,25 +3,60 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Literal, 'float' do
6
- let(:source) { '10.0' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'nil'
11
- mutations << '0.0'
12
- mutations << '1.0'
13
- mutations << random_float.to_s
14
- mutations << '(0.0 / 0.0)'
15
- mutations << '(1.0 / 0.0)'
16
- mutations << '(-1.0 / 0.0)'
17
- mutations << '-10.0'
6
+
7
+ before do
8
+ Mutant::Random.stub(float: random_float)
18
9
  end
19
10
 
20
11
  let(:random_float) { 7.123 }
21
12
 
22
- before do
23
- Mutant::Random.stub(float: random_float)
13
+ context 'positive number' do
14
+ let(:source) { '10.0' }
15
+
16
+ let(:mutations) do
17
+ mutations = []
18
+ mutations << 'nil'
19
+ mutations << '0.0'
20
+ mutations << '1.0'
21
+ mutations << random_float.to_s
22
+ mutations << '(0.0 / 0.0)'
23
+ mutations << '(1.0 / 0.0)'
24
+ mutations << '(-1.0 / 0.0)'
25
+ mutations << '-10.0'
26
+ end
27
+
28
+ it_should_behave_like 'a mutator'
24
29
  end
25
30
 
26
- it_should_behave_like 'a mutator'
31
+ context '0.0' do
32
+ let(:source) { '0.0' }
33
+
34
+ let(:mutations) do
35
+ mutations = []
36
+ mutations << 'nil'
37
+ mutations << '1.0'
38
+ mutations << random_float.to_s
39
+ mutations << '(0.0 / 0.0)'
40
+ mutations << '(1.0 / 0.0)'
41
+ mutations << '(-1.0 / 0.0)'
42
+ end
43
+
44
+ it_should_behave_like 'a mutator'
45
+ end
46
+
47
+ context '-0.0' do
48
+ let(:source) { '-0.0' }
49
+
50
+ let(:mutations) do
51
+ mutations = []
52
+ mutations << 'nil'
53
+ mutations << '1.0'
54
+ mutations << random_float.to_s
55
+ mutations << '(0.0 / 0.0)'
56
+ mutations << '(1.0 / 0.0)'
57
+ mutations << '(-1.0 / 0.0)'
58
+ end
59
+
60
+ it_should_behave_like 'a mutator'
61
+ end
27
62
  end
@@ -0,0 +1,37 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::LoopControl do
6
+
7
+ context 'with break node' do
8
+ let(:source) { 'break true' }
9
+
10
+ let(:mutations) do
11
+ mutations = []
12
+ mutations << 'break false'
13
+ mutations << 'break nil'
14
+ mutations << 'break'
15
+ mutations << 'nil'
16
+ mutations << 'next true'
17
+ end
18
+
19
+ it_should_behave_like 'a mutator'
20
+
21
+ end
22
+
23
+ context 'with next node' do
24
+ let(:source) { 'next true' }
25
+
26
+ let(:mutations) do
27
+ mutations = []
28
+ mutations << 'next false'
29
+ mutations << 'next nil'
30
+ mutations << 'next'
31
+ mutations << 'nil'
32
+ mutations << 'break true'
33
+ end
34
+
35
+ it_should_behave_like 'a mutator'
36
+ end
37
+ end
@@ -3,22 +3,71 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Mutant::Mutator::Node::Generic, 'rescue' do
6
- let(:source) { 'begin; rescue Exception => e; true end' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'begin; rescue Exception => srandom; true; end'
11
- mutations << 'begin; rescue Exception => e; false; end'
12
- mutations << 'begin; rescue Exception => e; nil; end'
13
- mutations << 'begin; rescue nil => e; true; end'
14
- # mutations << 'begin; rescue => e; true; end' # FIXME
15
- end
16
6
 
17
7
  before do
18
8
  Mutant::Random.stub(hex_string: 'random')
19
9
  end
20
10
 
21
- pending do
11
+ context 'multiple exception selectors and assignment' do
12
+ let(:source) { 'begin; rescue ExceptionA, ExceptionB => error; true; end' }
13
+
14
+ let(:mutations) do
15
+ mutations = []
16
+ mutations << 'nil'
17
+ # mutations << 'begin; rescue ExceptionA, ExceptionB => error; true; end'
18
+ mutations << 'begin; rescue ExceptionA, ExceptionB; true; end'
19
+ mutations << 'begin; rescue ExceptionA, ExceptionB => error; false; end'
20
+ mutations << 'begin; rescue ExceptionA, ExceptionB => error; nil; end'
21
+ mutations << 'begin; rescue ExceptionA, nil => error; true; end'
22
+ mutations << 'begin; rescue ExceptionA => error; true; end'
23
+ mutations << 'begin; rescue ExceptionB => error; true; end'
24
+ mutations << 'begin; rescue nil, ExceptionB => error; true; end'
25
+ mutations << 'begin; rescue => error; true; end'
26
+ end
27
+
28
+ it_should_behave_like 'a mutator'
29
+ end
30
+
31
+ context 'single exception selector and assignment' do
32
+ let(:source) { 'begin; rescue Exception => error; true; end' }
33
+
34
+ let(:mutations) do
35
+ mutations = []
36
+ mutations << 'nil'
37
+ mutations << 'begin; rescue Exception; true; end'
38
+ mutations << 'begin; rescue Exception => error; false; end'
39
+ mutations << 'begin; rescue Exception => error; nil; end'
40
+ mutations << 'begin; rescue nil => error; true; end'
41
+ mutations << 'begin; rescue => error; true; end'
42
+ end
43
+
44
+ it_should_behave_like 'a mutator'
45
+ end
46
+
47
+ context 'no exection selector and assignment' do
48
+ let(:source) { 'begin; rescue => error; true end' }
49
+
50
+ let(:mutations) do
51
+ mutations = []
52
+ mutations << 'nil'
53
+ mutations << 'begin; rescue => error; false; end'
54
+ mutations << 'begin; rescue => error; nil; end'
55
+ mutations << 'begin; rescue; true; end'
56
+ end
57
+
58
+ it_should_behave_like 'a mutator'
59
+ end
60
+
61
+ context 'no exection selector and no assignment' do
62
+ let(:source) { 'begin; rescue; true end' }
63
+
64
+ let(:mutations) do
65
+ mutations = []
66
+ mutations << 'nil'
67
+ mutations << 'begin; rescue; false; end'
68
+ mutations << 'begin; rescue; nil; end'
69
+ end
70
+
22
71
  it_should_behave_like 'a mutator'
23
72
  end
24
73
  end
@@ -2,13 +2,15 @@
2
2
 
3
3
  require 'spec_helper'
4
4
 
5
- describe Mutant::Mutator::Node::Generic, 'yield' do
6
- let(:source) { 'yield true' }
5
+ describe Mutant::Mutator::Node::Yield, 'yield' do
6
+ let(:source) { 'yield true' }
7
7
 
8
8
  let(:mutations) do
9
9
  mutations = []
10
10
  mutations << 'yield false'
11
11
  mutations << 'yield nil'
12
+ mutations << 'yield'
13
+ mutations << 'nil'
12
14
  end
13
15
 
14
16
  it_should_behave_like 'a mutator'
@@ -32,7 +32,7 @@ describe Mutant::Runner::Config, '#subjects' do
32
32
  Mutant::Runner.stub(:run).with(config, subject_b).and_return(runner_b)
33
33
  end
34
34
 
35
- context 'without earily stop' do
35
+ context 'without early stop' do
36
36
  let(:stop_a) { false }
37
37
  let(:stop_b) { false }
38
38
 
@@ -41,7 +41,7 @@ describe Mutant::Runner::Config, '#subjects' do
41
41
  it_should_behave_like 'an idempotent method'
42
42
  end
43
43
 
44
- context 'with earily stop' do
44
+ context 'with early stop' do
45
45
  let(:stop_a) { true }
46
46
  let(:stop_b) { false }
47
47
 
@@ -20,4 +20,3 @@ describe Mutant::Strategy do
20
20
  it_should_behave_like 'a command method'
21
21
  end
22
22
  end
23
-
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe Mutant::Subject::Method::Instance do
4
+ include Mutant::NodeHelpers
5
+
6
+ let(:object) { described_class.new(context, node) }
7
+ let(:context) { double }
8
+
9
+ let(:node) do
10
+ s(:def, :foo, s(:args))
11
+ end
12
+
13
+ describe '#source' do
14
+ subject { object.source }
15
+
16
+ it { should eql("def foo\nend") }
17
+ end
18
+ end
19
+
20
+ describe Mutant::Subject::Method::Instance::Memoized do
21
+ include Mutant::NodeHelpers
22
+
23
+ let(:object) { described_class.new(context, node) }
24
+ let(:context) { double }
25
+
26
+ let(:node) do
27
+ s(:def, :foo, s(:args))
28
+ end
29
+
30
+ describe '#source' do
31
+ subject { object.source }
32
+
33
+ it { should eql("def foo\nend\nmemoize(:foo)") }
34
+ end
35
+ end
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.rc3
4
+ version: 0.3.0.rc4
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-09-15 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.pre7
19
+ version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.pre7
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: abstract_type
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.7
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: unparser
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ~>
32
46
  - !ruby/object:Gem::Version
33
- version: 0.1.2
47
+ version: 0.1.4
34
48
  type: :runtime
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - ~>
39
53
  - !ruby/object:Gem::Version
40
- version: 0.1.2
54
+ version: 0.1.4
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: ice_nine
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -186,7 +200,7 @@ files:
186
200
  - .travis.yml
187
201
  - Changelog.md
188
202
  - Gemfile
189
- - Gemfile.devtools
203
+ - Gemfile.triage
190
204
  - Guardfile
191
205
  - LICENSE
192
206
  - README.md
@@ -194,12 +208,12 @@ files:
194
208
  - TODO
195
209
  - bin/mutant
196
210
  - circle.yml
197
- - config/devtools.yml
198
211
  - config/flay.yml
199
212
  - config/flog.yml
200
213
  - config/mutant.yml
201
214
  - config/reek.yml
202
215
  - config/rubocop.yml
216
+ - config/triage.yml
203
217
  - config/yardstick.yml
204
218
  - lib/mutant.rb
205
219
  - lib/mutant/cache.rb
@@ -248,6 +262,7 @@ files:
248
262
  - lib/mutant/mutator/node/dsym.rb
249
263
  - lib/mutant/mutator/node/generic.rb
250
264
  - lib/mutant/mutator/node/if.rb
265
+ - lib/mutant/mutator/node/kwbegin.rb
251
266
  - lib/mutant/mutator/node/literal.rb
252
267
  - lib/mutant/mutator/node/literal/array.rb
253
268
  - lib/mutant/mutator/node/literal/boolean.rb
@@ -260,6 +275,7 @@ files:
260
275
  - lib/mutant/mutator/node/literal/regex.rb
261
276
  - lib/mutant/mutator/node/literal/string.rb
262
277
  - lib/mutant/mutator/node/literal/symbol.rb
278
+ - lib/mutant/mutator/node/loop_control.rb
263
279
  - lib/mutant/mutator/node/masgn.rb
264
280
  - lib/mutant/mutator/node/mlhs.rb
265
281
  - lib/mutant/mutator/node/named_value/access.rb
@@ -268,6 +284,7 @@ files:
268
284
  - lib/mutant/mutator/node/noop.rb
269
285
  - lib/mutant/mutator/node/nthref.rb
270
286
  - lib/mutant/mutator/node/op_asgn.rb
287
+ - lib/mutant/mutator/node/resbody.rb
271
288
  - lib/mutant/mutator/node/restarg.rb
272
289
  - lib/mutant/mutator/node/return.rb
273
290
  - lib/mutant/mutator/node/send.rb
@@ -276,6 +293,7 @@ files:
276
293
  - lib/mutant/mutator/node/super.rb
277
294
  - lib/mutant/mutator/node/when.rb
278
295
  - lib/mutant/mutator/node/while.rb
296
+ - lib/mutant/mutator/node/yield.rb
279
297
  - lib/mutant/mutator/node/zsuper.rb
280
298
  - lib/mutant/mutator/registry.rb
281
299
  - lib/mutant/mutator/util.rb
@@ -358,7 +376,6 @@ files:
358
376
  - spec/unit/mutant/mutator/node/block/mutation_spec.rb
359
377
  - spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb
360
378
  - spec/unit/mutant/mutator/node/blockarg/mutation_spec.rb
361
- - spec/unit/mutant/mutator/node/break/mutation_spec.rb
362
379
  - spec/unit/mutant/mutator/node/case/mutation_spec.rb
363
380
  - spec/unit/mutant/mutator/node/cbase/mutation_spec.rb
364
381
  - spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb
@@ -369,6 +386,7 @@ files:
369
386
  - spec/unit/mutant/mutator/node/dsym/mutation_spec.rb
370
387
  - spec/unit/mutant/mutator/node/ensure/mutation_spec.rb
371
388
  - spec/unit/mutant/mutator/node/if/mutation_spec.rb
389
+ - spec/unit/mutant/mutator/node/kwbegin/mutation_spec.rb
372
390
  - spec/unit/mutant/mutator/node/literal/array_spec.rb
373
391
  - spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb
374
392
  - spec/unit/mutant/mutator/node/literal/fixnum_spec.rb
@@ -379,12 +397,12 @@ files:
379
397
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
380
398
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
381
399
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
400
+ - spec/unit/mutant/mutator/node/loop_ctrl_spec.rb
382
401
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
383
402
  - spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb
384
403
  - spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb
385
404
  - spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
386
405
  - spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
387
- - spec/unit/mutant/mutator/node/next/mutation_spec.rb
388
406
  - spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
389
407
  - spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb
390
408
  - spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb
@@ -404,6 +422,7 @@ files:
404
422
  - spec/unit/mutant/runner/subject/success_predicate_spec.rb
405
423
  - spec/unit/mutant/strategy_spec.rb
406
424
  - spec/unit/mutant/subject/context_spec.rb
425
+ - spec/unit/mutant/subject/method/instance_spec.rb
407
426
  - spec/unit/mutant/subject/mutations_spec.rb
408
427
  - spec/unit/mutant/subject/node_spec.rb
409
428
  - spec/unit/mutant/subject_spec.rb
@@ -440,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
440
459
  version: 1.3.1
441
460
  requirements: []
442
461
  rubyforge_project:
443
- rubygems_version: 2.0.2
462
+ rubygems_version: 2.0.14
444
463
  signing_key:
445
464
  specification_version: 4
446
465
  summary: Mutation testing tool for ruby under MRI and Rubinius
@@ -484,7 +503,6 @@ test_files:
484
503
  - spec/unit/mutant/mutator/node/block/mutation_spec.rb
485
504
  - spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb
486
505
  - spec/unit/mutant/mutator/node/blockarg/mutation_spec.rb
487
- - spec/unit/mutant/mutator/node/break/mutation_spec.rb
488
506
  - spec/unit/mutant/mutator/node/case/mutation_spec.rb
489
507
  - spec/unit/mutant/mutator/node/cbase/mutation_spec.rb
490
508
  - spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb
@@ -495,6 +513,7 @@ test_files:
495
513
  - spec/unit/mutant/mutator/node/dsym/mutation_spec.rb
496
514
  - spec/unit/mutant/mutator/node/ensure/mutation_spec.rb
497
515
  - spec/unit/mutant/mutator/node/if/mutation_spec.rb
516
+ - spec/unit/mutant/mutator/node/kwbegin/mutation_spec.rb
498
517
  - spec/unit/mutant/mutator/node/literal/array_spec.rb
499
518
  - spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb
500
519
  - spec/unit/mutant/mutator/node/literal/fixnum_spec.rb
@@ -505,12 +524,12 @@ test_files:
505
524
  - spec/unit/mutant/mutator/node/literal/regex_spec.rb
506
525
  - spec/unit/mutant/mutator/node/literal/string_spec.rb
507
526
  - spec/unit/mutant/mutator/node/literal/symbol_spec.rb
527
+ - spec/unit/mutant/mutator/node/loop_ctrl_spec.rb
508
528
  - spec/unit/mutant/mutator/node/masgn/mutation_spec.rb
509
529
  - spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb
510
530
  - spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb
511
531
  - spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb
512
532
  - spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb
513
- - spec/unit/mutant/mutator/node/next/mutation_spec.rb
514
533
  - spec/unit/mutant/mutator/node/nthref/mutation_spec.rb
515
534
  - spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb
516
535
  - spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb
@@ -530,6 +549,7 @@ test_files:
530
549
  - spec/unit/mutant/runner/subject/success_predicate_spec.rb
531
550
  - spec/unit/mutant/strategy_spec.rb
532
551
  - spec/unit/mutant/subject/context_spec.rb
552
+ - spec/unit/mutant/subject/method/instance_spec.rb
533
553
  - spec/unit/mutant/subject/mutations_spec.rb
534
554
  - spec/unit/mutant/subject/node_spec.rb
535
555
  - spec/unit/mutant/subject_spec.rb
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Generic, 'break' do
6
- let(:source) { 'break true' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'break false'
11
- mutations << 'break nil'
12
- end
13
-
14
- it_should_behave_like 'a mutator'
15
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Generic, 'next' do
6
- let(:source) { 'next true' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'next false'
11
- mutations << 'next nil'
12
- end
13
-
14
- it_should_behave_like 'a mutator'
15
- end