mutant 0.3.0.beta21 → 0.3.0.beta22

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 (223) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +37 -6
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.travis.yml +13 -7
  6. data/Gemfile +8 -3
  7. data/Gemfile.devtools +2 -6
  8. data/Guardfile +22 -8
  9. data/README.md +3 -1
  10. data/Rakefile +3 -0
  11. data/bin/mutant +4 -3
  12. data/config/devtools.yml +1 -1
  13. data/config/flay.yml +1 -1
  14. data/config/flog.yml +1 -1
  15. data/config/reek.yml +7 -6
  16. data/config/rubocop.yml +55 -0
  17. data/lib/mutant.rb +3 -1
  18. data/lib/mutant/cache.rb +2 -0
  19. data/lib/mutant/cli.rb +14 -10
  20. data/lib/mutant/cli/classifier.rb +22 -10
  21. data/lib/mutant/cli/classifier/method.rb +14 -15
  22. data/lib/mutant/cli/classifier/namespace.rb +6 -2
  23. data/lib/mutant/cli/classifier/scope.rb +3 -1
  24. data/lib/mutant/color.rb +7 -3
  25. data/lib/mutant/config.rb +2 -0
  26. data/lib/mutant/constants.rb +5 -4
  27. data/lib/mutant/context.rb +2 -0
  28. data/lib/mutant/context/scope.rb +3 -1
  29. data/lib/mutant/differ.rb +10 -2
  30. data/lib/mutant/killer.rb +4 -1
  31. data/lib/mutant/killer/forked.rb +2 -0
  32. data/lib/mutant/killer/forking.rb +2 -0
  33. data/lib/mutant/killer/rspec.rb +19 -3
  34. data/lib/mutant/killer/static.rb +2 -0
  35. data/lib/mutant/loader.rb +8 -1
  36. data/lib/mutant/matcher.rb +2 -0
  37. data/lib/mutant/matcher/chain.rb +2 -0
  38. data/lib/mutant/matcher/method.rb +15 -3
  39. data/lib/mutant/matcher/method/finder.rb +2 -0
  40. data/lib/mutant/matcher/method/instance.rb +4 -1
  41. data/lib/mutant/matcher/method/singleton.rb +7 -1
  42. data/lib/mutant/matcher/methods.rb +3 -1
  43. data/lib/mutant/matcher/namespace.rb +4 -2
  44. data/lib/mutant/matcher/scope.rb +2 -0
  45. data/lib/mutant/mutation.rb +19 -5
  46. data/lib/mutant/mutation/evil.rb +12 -0
  47. data/lib/mutant/mutation/filter.rb +2 -0
  48. data/lib/mutant/mutation/filter/code.rb +3 -1
  49. data/lib/mutant/mutation/filter/regexp.rb +2 -0
  50. data/lib/mutant/mutation/filter/whitelist.rb +2 -0
  51. data/lib/mutant/mutation/neutral.rb +25 -0
  52. data/lib/mutant/mutator.rb +4 -6
  53. data/lib/mutant/mutator/node.rb +5 -1
  54. data/lib/mutant/mutator/node/argument.rb +2 -0
  55. data/lib/mutant/mutator/node/arguments.rb +2 -0
  56. data/lib/mutant/mutator/node/begin.rb +2 -0
  57. data/lib/mutant/mutator/node/block.rb +2 -0
  58. data/lib/mutant/mutator/node/case.rb +3 -1
  59. data/lib/mutant/mutator/node/connective/binary.rb +3 -1
  60. data/lib/mutant/mutator/node/const.rb +2 -0
  61. data/lib/mutant/mutator/node/define.rb +2 -0
  62. data/lib/mutant/mutator/node/generic.rb +4 -3
  63. data/lib/mutant/mutator/node/if.rb +2 -0
  64. data/lib/mutant/mutator/node/literal.rb +2 -0
  65. data/lib/mutant/mutator/node/literal/array.rb +2 -0
  66. data/lib/mutant/mutator/node/literal/boolean.rb +2 -0
  67. data/lib/mutant/mutator/node/literal/dynamic.rb +2 -0
  68. data/lib/mutant/mutator/node/literal/fixnum.rb +3 -1
  69. data/lib/mutant/mutator/node/literal/float.rb +2 -0
  70. data/lib/mutant/mutator/node/literal/hash.rb +2 -0
  71. data/lib/mutant/mutator/node/literal/nil.rb +2 -0
  72. data/lib/mutant/mutator/node/literal/range.rb +2 -1
  73. data/lib/mutant/mutator/node/literal/regex.rb +2 -0
  74. data/lib/mutant/mutator/node/literal/string.rb +2 -0
  75. data/lib/mutant/mutator/node/literal/symbol.rb +5 -1
  76. data/lib/mutant/mutator/node/masgn.rb +2 -0
  77. data/lib/mutant/mutator/node/mlhs.rb +2 -0
  78. data/lib/mutant/mutator/node/named_value/access.rb +2 -0
  79. data/lib/mutant/mutator/node/named_value/constant_assignment.rb +2 -0
  80. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +3 -1
  81. data/lib/mutant/mutator/node/{cbase.rb → noop.rb} +7 -5
  82. data/lib/mutant/mutator/node/return.rb +2 -0
  83. data/lib/mutant/mutator/node/send.rb +2 -0
  84. data/lib/mutant/mutator/node/send/binary.rb +2 -0
  85. data/lib/mutant/mutator/node/splat.rb +2 -0
  86. data/lib/mutant/mutator/node/super.rb +2 -0
  87. data/lib/mutant/mutator/node/when.rb +3 -1
  88. data/lib/mutant/mutator/node/while.rb +2 -0
  89. data/lib/mutant/mutator/node/zsuper.rb +2 -0
  90. data/lib/mutant/mutator/registry.rb +55 -13
  91. data/lib/mutant/mutator/util.rb +2 -0
  92. data/lib/mutant/mutator/util/array.rb +3 -1
  93. data/lib/mutant/mutator/util/symbol.rb +2 -0
  94. data/lib/mutant/node_helpers.rb +10 -4
  95. data/lib/mutant/random.rb +2 -0
  96. data/lib/mutant/reporter.rb +2 -0
  97. data/lib/mutant/reporter/cli.rb +2 -0
  98. data/lib/mutant/reporter/cli/printer.rb +2 -0
  99. data/lib/mutant/reporter/cli/printer/config.rb +5 -2
  100. data/lib/mutant/reporter/cli/printer/killer.rb +2 -0
  101. data/lib/mutant/reporter/cli/printer/mutation.rb +13 -6
  102. data/lib/mutant/reporter/cli/printer/subject.rb +5 -1
  103. data/lib/mutant/reporter/null.rb +2 -0
  104. data/lib/mutant/runner.rb +2 -0
  105. data/lib/mutant/runner/config.rb +2 -0
  106. data/lib/mutant/runner/mutation.rb +2 -0
  107. data/lib/mutant/runner/subject.rb +2 -0
  108. data/lib/mutant/singleton_methods.rb +5 -3
  109. data/lib/mutant/strategy.rb +2 -0
  110. data/lib/mutant/strategy/method_expansion.rb +2 -0
  111. data/lib/mutant/strategy/rspec.rb +2 -0
  112. data/lib/mutant/strategy/rspec/dm2.rb +2 -0
  113. data/lib/mutant/strategy/rspec/dm2/lookup.rb +4 -2
  114. data/lib/mutant/strategy/rspec/dm2/lookup/method.rb +2 -0
  115. data/lib/mutant/strategy/static.rb +2 -0
  116. data/lib/mutant/subject.rb +4 -1
  117. data/lib/mutant/subject/method.rb +2 -0
  118. data/lib/mutant/subject/method/instance.rb +2 -0
  119. data/lib/mutant/subject/method/singleton.rb +2 -0
  120. data/lib/mutant/support/method_object.rb +2 -0
  121. data/lib/mutant/zombifier.rb +10 -6
  122. data/mutant.gemspec +11 -10
  123. data/spec/integration/mutant/rspec_killer_spec.rb +9 -4
  124. data/spec/integration/mutant/test_mutator_handles_types_spec.rb +3 -1
  125. data/spec/integration/mutant/zombie_spec.rb +2 -0
  126. data/spec/shared/method_matcher_behavior.rb +2 -0
  127. data/spec/shared/mutator_behavior.rb +16 -7
  128. data/spec/spec_helper.rb +26 -5
  129. data/spec/support/compress_helper.rb +5 -5
  130. data/spec/support/ice_nine_config.rb +2 -0
  131. data/spec/support/rspec.rb +2 -0
  132. data/spec/support/test_app.rb +2 -0
  133. data/spec/unit/mutant/class_methods/singleton_subclass_instance_spec.rb +2 -0
  134. data/spec/unit/mutant/cli/class_methods/new_spec.rb +17 -8
  135. data/spec/unit/mutant/cli/class_methods/run_spec.rb +10 -2
  136. data/spec/unit/mutant/cli/classifier/class_methods/build_spec.rb +4 -1
  137. data/spec/unit/mutant/cli/classifier/method/each_spec.rb +89 -0
  138. data/spec/unit/mutant/cli/classifier/namespace/flat/each_spec.rb +58 -0
  139. data/spec/unit/mutant/cli/classifier/namespace/recursive/each_spec.rb +58 -0
  140. data/spec/unit/mutant/cli/classifier/scope/each_spec.rb +33 -0
  141. data/spec/unit/mutant/context/root_spec.rb +5 -1
  142. data/spec/unit/mutant/context/scope/root_spec.rb +2 -0
  143. data/spec/unit/mutant/context/scope/unqualified_name_spec.rb +2 -0
  144. data/spec/unit/mutant/differ/class_methods/build_spec.rb +2 -0
  145. data/spec/unit/mutant/differ/class_methods/colorize_line_spec.rb +2 -0
  146. data/spec/unit/mutant/differ/diff_spec.rb +67 -5
  147. data/spec/unit/mutant/killer/rspec/class_methods/new_spec.rb +21 -4
  148. data/spec/unit/mutant/killer/success_predicate_spec.rb +2 -0
  149. data/spec/unit/mutant/loader/eval/class_methods/run_spec.rb +12 -5
  150. data/spec/unit/mutant/matcher/chain/each_spec.rb +2 -0
  151. data/spec/unit/mutant/matcher/chain/matchers_spec.rb +2 -0
  152. data/spec/unit/mutant/matcher/each_spec.rb +8 -1
  153. data/spec/unit/mutant/matcher/method/instance/class_methods/build_spec.rb +4 -2
  154. data/spec/unit/mutant/matcher/method/instance/each_spec.rb +21 -20
  155. data/spec/unit/mutant/matcher/method/singleton/each_spec.rb +22 -19
  156. data/spec/unit/mutant/matcher/methods/instance/each_spec.rb +8 -3
  157. data/spec/unit/mutant/matcher/methods/singleton/each_spec.rb +8 -3
  158. data/spec/unit/mutant/matcher/namespace/each_spec.rb +8 -2
  159. data/spec/unit/mutant/mutator/each_spec.rb +2 -0
  160. data/spec/unit/mutant/mutator/emit_new_spec.rb +10 -3
  161. data/spec/unit/mutant/mutator/emit_spec.rb +4 -2
  162. data/spec/unit/mutant/mutator/node/and_asgn/mutation_spec.rb +26 -0
  163. data/spec/unit/mutant/mutator/node/begin/mutation_spec.rb +2 -0
  164. data/spec/unit/mutant/mutator/node/block/mutation_spec.rb +4 -2
  165. data/spec/unit/mutant/mutator/node/block_pass/mutation_spec.rb +14 -0
  166. data/spec/unit/mutant/mutator/node/break/mutation_spec.rb +15 -0
  167. data/spec/unit/mutant/mutator/node/case/mutation_spec.rb +2 -0
  168. data/spec/unit/mutant/mutator/node/cbase/mutation_spec.rb +3 -6
  169. data/spec/unit/mutant/mutator/node/connective/binary/mutation_spec.rb +2 -0
  170. data/spec/unit/mutant/mutator/node/const/mutation_spec.rb +3 -6
  171. data/spec/unit/mutant/mutator/node/define/mutation_spec.rb +2 -1
  172. data/spec/unit/mutant/mutator/node/defined_predicate/mutation_spec.rb +10 -0
  173. data/spec/unit/mutant/mutator/node/dstr/mutation_spec.rb +21 -0
  174. data/spec/unit/mutant/mutator/node/dsym/mutation_spec.rb +21 -0
  175. data/spec/unit/mutant/mutator/node/ensure/mutation_spec.rb +15 -0
  176. data/spec/unit/mutant/mutator/node/if/mutation_spec.rb +2 -1
  177. data/spec/unit/mutant/mutator/node/literal/array_spec.rb +2 -0
  178. data/spec/unit/mutant/mutator/node/literal/boolean/mutation_spec.rb +2 -0
  179. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +2 -0
  180. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +4 -2
  181. data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +2 -0
  182. data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +4 -5
  183. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +8 -8
  184. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +2 -0
  185. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +2 -0
  186. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +2 -0
  187. data/spec/unit/mutant/mutator/node/masgn/mutation_spec.rb +4 -10
  188. data/spec/unit/mutant/mutator/node/match_current_line/mutation_spec.rb +20 -0
  189. data/spec/unit/mutant/mutator/node/named_value/access/mutation_spec.rb +3 -2
  190. data/spec/unit/mutant/mutator/node/named_value/constant_assignment/mutation_spec.rb +3 -2
  191. data/spec/unit/mutant/mutator/node/named_value/variable_assignment/mutation_spec.rb +3 -2
  192. data/spec/unit/mutant/mutator/node/next/mutation_spec.rb +15 -0
  193. data/spec/unit/mutant/mutator/node/op_assgn/mutation_spec.rb +26 -0
  194. data/spec/unit/mutant/mutator/node/or_asgn/mutation_spec.rb +26 -0
  195. data/spec/unit/mutant/mutator/node/redo/mutation_spec.rb +10 -0
  196. data/spec/unit/mutant/mutator/node/rescue/mutation_spec.rb +24 -0
  197. data/spec/unit/mutant/mutator/node/restarg/mutation_spec.rb +16 -0
  198. data/spec/unit/mutant/mutator/node/return/mutation_spec.rb +2 -0
  199. data/spec/unit/mutant/mutator/node/send/mutation_spec.rb +3 -1
  200. data/spec/unit/mutant/mutator/node/super/mutation_spec.rb +2 -0
  201. data/spec/unit/mutant/mutator/node/while/mutation_spec.rb +3 -1
  202. data/spec/unit/mutant/mutator/node/yield/mutation_spec.rb +15 -0
  203. data/spec/unit/mutant/node_helpers/n_not_spec.rb +2 -0
  204. data/spec/unit/mutant/runner/config/subjects_spec.rb +6 -2
  205. data/spec/unit/mutant/runner/config/success_predicate_spec.rb +15 -6
  206. data/spec/unit/mutant/runner/mutation/killer_spec.rb +3 -1
  207. data/spec/unit/mutant/runner/subject/success_predicate_spec.rb +15 -8
  208. data/spec/unit/mutant/strategy/method_expansion/class_methods/run_spec.rb +2 -0
  209. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/instance/spec_files_spec.rb +32 -11
  210. data/spec/unit/mutant/strategy/rspec/dm2/lookup/method/singleton/spec_files_spec.rb +31 -11
  211. data/spec/unit/mutant/subject/context_spec.rb +2 -0
  212. data/spec/unit/mutant/subject/mutations_spec.rb +2 -0
  213. data/spec/unit/mutant/subject/node_spec.rb +2 -0
  214. data/test_app/lib/test_app.rb +2 -0
  215. data/test_app/lib/test_app/literal.rb +2 -0
  216. data/test_app/spec/shared/method_filter_parse_behavior.rb +5 -1
  217. data/test_app/spec/shared/method_match_behavior.rb +2 -0
  218. data/test_app/spec/spec_helper.rb +3 -1
  219. data/test_app/spec/unit/test_app/literal/command_spec.rb +2 -0
  220. data/test_app/spec/unit/test_app/literal/string_spec.rb +3 -1
  221. metadata +66 -18
  222. data/bin/zombie +0 -18
  223. data/test_app/spec/shared/mutator_behavior.rb +0 -44
@@ -1,16 +1,33 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Killer::Rspec, '.new' do
4
6
 
5
7
  subject { object.new(strategy, mutation) }
6
8
 
7
- let(:strategy) { double('Strategy', :spec_files => ['foo'], :error_stream => $stderr, :output_stream => $stdout) }
8
- let(:context) { double('Context') }
9
- let(:mutation) { double('Mutation', :subject => mutation_subject) }
10
- let(:mutation_subject) { double('Mutation Subject') }
9
+ let(:context) { double('Context') }
10
+ let(:mutation_subject) { double('Mutation Subject') }
11
11
 
12
12
  let(:object) { described_class }
13
13
 
14
+ let(:mutation) do
15
+ double(
16
+ 'Mutation',
17
+ :subject => mutation_subject,
18
+ :should_survive? => false
19
+ )
20
+ end
21
+
22
+ let(:strategy) do
23
+ double(
24
+ 'Strategy',
25
+ :spec_files => ['foo'],
26
+ :error_stream => $stderr,
27
+ :output_stream => $stdout
28
+ )
29
+ end
30
+
14
31
  before do
15
32
  mutation.stub(:insert)
16
33
  mutation.stub(:reset)
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Killer, '#success?' do
@@ -1,13 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Loader::Eval, '.run' do
4
6
 
5
7
  subject { object.run(node, mutation_subject) }
6
8
 
7
- let(:object) { described_class }
8
- let(:mutation_subject) { double('Subject', :source_path => path, :source_line => line) }
9
- let(:path) { 'test.rb' }
10
- let(:line) { 1 }
9
+ let(:object) { described_class }
10
+ let(:path) { __FILE__ }
11
+ let(:line) { 1 }
12
+
13
+ let(:mutation_subject) do
14
+ double('Subject', :source_path => path, :source_line => line)
15
+ end
11
16
 
12
17
  let(:source) do
13
18
  <<-RUBY
@@ -36,6 +41,8 @@ describe Mutant::Loader::Eval, '.run' do
36
41
 
37
42
  it 'should set file and line correctly' do
38
43
  subject
39
- ::SomeNamespace::Bar.instance_method(:some_method).source_location.should eql(['test.rb', 3])
44
+ ::SomeNamespace::Bar
45
+ .instance_method(:some_method)
46
+ .source_location.should eql([__FILE__, 3])
40
47
  end
41
48
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Chain, '#each' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Chain, '#matchers' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  # This spec is only present to ensure 100% test coverage.
@@ -9,6 +11,11 @@ describe Mutant::Matcher, '#each' do
9
11
  let(:object) { described_class.allocate }
10
12
 
11
13
  it 'should raise error' do
12
- expect { subject }.to raise_error(NotImplementedError, 'Mutant::Matcher#each is not implemented')
14
+ expect do
15
+ subject
16
+ end.to raise_error(
17
+ NotImplementedError,
18
+ 'Mutant::Matcher#each is not implemented'
19
+ )
13
20
  end
14
21
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Method::Instance, '.build' do
@@ -28,13 +30,13 @@ describe Mutant::Matcher::Method::Instance, '.build' do
28
30
  context 'with unmemoized method' do
29
31
  let(:method_name) { :bar }
30
32
 
31
- it { should eql(Mutant::Matcher::Method::Instance.new(cache, scope, method)) }
33
+ it { should eql(described_class.new(cache, scope, method)) }
32
34
  end
33
35
 
34
36
  context 'with memoized method' do
35
37
  let(:method_name) { :foo }
36
38
 
37
- it { should eql(Mutant::Matcher::Method::Instance::Memoized.new(cache, scope, method)) }
39
+ it { should eql(described_class::Memoized.new(cache, scope, method)) }
38
40
  end
39
41
  end
40
42
  end
@@ -1,23 +1,19 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Method::Instance, '#each' do
4
- let(:cache) { Fixtures::AST_CACHE }
5
- let(:object) { described_class.new(cache, scope, method) }
6
- let(:method) { scope.instance_method(method_name) }
7
-
8
- let(:yields) { [] }
9
-
10
- let(:namespace) do
11
- klass = self.class
12
- end
13
-
14
- let(:scope) { self.class::Foo }
15
-
16
6
  subject { object.each { |subject| yields << subject } }
17
7
 
18
- let(:type) { :def }
19
- let(:method_name) { :bar }
20
- let(:method_arity) { 0 }
8
+ let(:cache) { Fixtures::AST_CACHE }
9
+ let(:object) { described_class.new(cache, scope, method) }
10
+ let(:method) { scope.instance_method(method_name) }
11
+ let(:yields) { [] }
12
+ let(:namespace) { self.class }
13
+ let(:scope) { self.class::Foo }
14
+ let(:type) { :def }
15
+ let(:method_name) { :bar }
16
+ let(:method_arity) { 0 }
21
17
 
22
18
  def name
23
19
  node.children[0]
@@ -42,11 +38,14 @@ describe Mutant::Matcher::Method::Instance, '#each' do
42
38
  context 'on differend lines' do
43
39
  let(:base) { __LINE__ }
44
40
  class self::Foo
45
- def bar; end
46
- def bar(arg); end
41
+ def bar
42
+ end
43
+
44
+ def bar(arg)
45
+ end
47
46
  end
48
47
 
49
- let(:method_line) { 3 }
48
+ let(:method_line) { 5 }
50
49
  let(:method_arity) { 1 }
51
50
 
52
51
  it_should_behave_like 'a method matcher'
@@ -83,7 +82,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
83
82
  let(:base) { __LINE__ }
84
83
  class self::Foo
85
84
  class Bar
86
- def baz; end
85
+ def baz
86
+ end
87
87
  end
88
88
  end
89
89
 
@@ -98,7 +98,8 @@ describe Mutant::Matcher::Method::Instance, '#each' do
98
98
  let(:base) { __LINE__ }
99
99
  module self::Foo
100
100
  class Bar
101
- def baz; end
101
+ def baz
102
+ end
102
103
  end
103
104
  end
104
105
 
@@ -1,22 +1,18 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Method::Singleton, '#each' do
4
- let(:object) { described_class.new(cache, scope, method) }
5
- let(:method) { scope.method(method_name) }
6
- let(:cache) { Fixtures::AST_CACHE }
7
-
8
- let(:yields) { [] }
9
-
10
- let(:namespace) do
11
- klass = self.class
12
- end
13
-
14
- let(:scope) { self.class::Foo }
15
-
16
6
  subject { object.each { |subject| yields << subject } }
17
7
 
18
- let(:type) { :defs }
19
- let(:method_arity) { 0 }
8
+ let(:object) { described_class.new(cache, scope, method) }
9
+ let(:method) { scope.method(method_name) }
10
+ let(:cache) { Fixtures::AST_CACHE }
11
+ let(:yields) { [] }
12
+ let(:namespace) { self.class }
13
+ let(:scope) { self.class::Foo }
14
+ let(:type) { :defs }
15
+ let(:method_arity) { 0 }
20
16
 
21
17
  def name
22
18
  node.children[1]
@@ -46,7 +42,8 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
46
42
  let(:base) { __LINE__ }
47
43
  module self::Namespace
48
44
  class Foo
49
- def Foo.bar; end
45
+ def Foo.bar
46
+ end
50
47
  end
51
48
  end
52
49
 
@@ -60,12 +57,15 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
60
57
  context 'outside namespace' do
61
58
  let(:base) { __LINE__ }
62
59
  module self::Namespace
63
- class Foo; end;
64
- def Foo.bar; end
60
+ class Foo
61
+ end
62
+
63
+ def Foo.bar
64
+ end
65
65
  end
66
66
 
67
67
  let(:method_name) { :bar }
68
- let(:method_line) { 3 }
68
+ let(:method_line) { 5 }
69
69
  let(:scope) { self.class::Namespace::Foo }
70
70
 
71
71
  it_should_behave_like 'a method matcher'
@@ -78,7 +78,10 @@ describe Mutant::Matcher::Method::Singleton, '#each' do
78
78
  module self::Namespace
79
79
  module Foo; end
80
80
  module Bar
81
- def self.baz; end; def Foo.baz(arg); end
81
+ def self.baz
82
+ end
83
+ def Foo.baz(arg)
84
+ end
82
85
  end
83
86
  end
84
87
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Methods::Instance, '#each' do
@@ -46,9 +48,12 @@ describe Mutant::Matcher::Methods::Instance, '#each' do
46
48
 
47
49
  before do
48
50
  matcher = Mutant::Matcher::Method::Instance
49
- matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_a)).and_return([subject_a])
50
- matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_b)).and_return([subject_b])
51
- matcher.stub(:new).with(cache, Foo, Foo.instance_method(:method_c)).and_return([subject_c])
51
+ matcher.stub(:new)
52
+ .with(cache, Foo, Foo.instance_method(:method_a)).and_return([subject_a])
53
+ matcher.stub(:new)
54
+ .with(cache, Foo, Foo.instance_method(:method_b)).and_return([subject_b])
55
+ matcher.stub(:new)
56
+ .with(cache, Foo, Foo.instance_method(:method_c)).and_return([subject_c])
52
57
  end
53
58
 
54
59
  it 'should yield expected subjects' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Methods::Singleton, '#each' do
@@ -40,9 +42,12 @@ describe Mutant::Matcher::Methods::Singleton, '#each' do
40
42
 
41
43
  before do
42
44
  matcher = Mutant::Matcher::Method::Singleton
43
- matcher.stub(:new).with(cache, Foo, Foo.method(:method_a)).and_return([subject_a])
44
- matcher.stub(:new).with(cache, Foo, Foo.method(:method_b)).and_return([subject_b])
45
- matcher.stub(:new).with(cache, Foo, Foo.method(:method_c)).and_return([subject_c])
45
+ matcher.stub(:new)
46
+ .with(cache, Foo, Foo.method(:method_a)).and_return([subject_a])
47
+ matcher.stub(:new)
48
+ .with(cache, Foo, Foo.method(:method_b)).and_return([subject_b])
49
+ matcher.stub(:new)
50
+ .with(cache, Foo, Foo.method(:method_c)).and_return([subject_c])
46
51
  end
47
52
 
48
53
  it 'should yield expected subjects' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Matcher::Namespace, '#each' do
@@ -14,8 +16,12 @@ describe Mutant::Matcher::Namespace, '#each' do
14
16
  let(:subject_b) { double('SubjectB') }
15
17
 
16
18
  before do
17
- Mutant::Matcher::Methods::Singleton.stub(:each).with(cache, singleton_a).and_yield(subject_a)
18
- Mutant::Matcher::Methods::Instance.stub(:each).with(cache, singleton_a).and_yield(subject_b)
19
+ Mutant::Matcher::Methods::Singleton.stub(:each)
20
+ .with(cache, singleton_a)
21
+ .and_yield(subject_a)
22
+ Mutant::Matcher::Methods::Instance.stub(:each)
23
+ .with(cache, singleton_a)
24
+ .and_yield(subject_b)
19
25
  ObjectSpace.stub(:each_object => [singleton_a, singleton_b])
20
26
  end
21
27
 
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  # This file is the sandbox for new mutations.
2
4
  # Once finished mutation test will be moved to class specfic
3
5
  # file.
@@ -1,10 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, '#emit_new' do
4
6
  subject { object.send(:emit_new) { generated } }
5
7
 
6
8
  class Block
7
- def arguments; @arguments; end
9
+ attr_reader :arguments
8
10
 
9
11
  def called?
10
12
  defined?(@arguments)
@@ -23,7 +25,7 @@ describe Mutant::Mutator, '#emit_new' do
23
25
  let(:class_under_test) do
24
26
  Class.new(described_class) do
25
27
  def dispatch
26
- #noop
28
+ # noop
27
29
  end
28
30
  end
29
31
  end
@@ -46,7 +48,12 @@ describe Mutant::Mutator, '#emit_new' do
46
48
  let(:generated) { input }
47
49
 
48
50
  it 'should raise error' do
49
- expect { subject }.to raise_error(RuntimeError, 'New AST could not be generated after 3 attempts')
51
+ expect do
52
+ subject
53
+ end.to raise_error(
54
+ RuntimeError,
55
+ 'New AST could not be generated after 3 attempts'
56
+ )
50
57
  end
51
58
  end
52
59
  end
@@ -1,10 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, '#emit' do
4
6
  subject { object.send(:emit, generated) }
5
7
 
6
8
  class Block
7
- def arguments; @arguments; end
9
+ attr_reader :arguments
8
10
 
9
11
  def called?
10
12
  defined?(@arguments)
@@ -23,7 +25,7 @@ describe Mutant::Mutator, '#emit' do
23
25
  let(:class_under_test) do
24
26
  Class.new(described_class) do
25
27
  def dispatch
26
- #noop
28
+ # noop
27
29
  end
28
30
  end
29
31
  end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'and_asgn' do
6
+ let(:random_fixnum) { 5 }
7
+ let(:random_string) { 'random' }
8
+
9
+ let(:source) { 'a &&= 1' }
10
+
11
+ let(:mutations) do
12
+ mutations = []
13
+ mutations << 'srandom &&= 1'
14
+ mutations << 'a &&= nil'
15
+ mutations << 'a &&= 0'
16
+ mutations << 'a &&= -1'
17
+ mutations << 'a &&= 2'
18
+ mutations << 'a &&= 5'
19
+ end
20
+
21
+ before do
22
+ Mutant::Random.stub(:fixnum => random_fixnum, :hex_string => random_string)
23
+ end
24
+
25
+ it_should_behave_like 'a mutator'
26
+ end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, 'begin' do