mutant 0.3.0.beta21 → 0.3.0.beta22

Sign up to get free protection for your applications and to get access to all the features.
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,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, 'block' do
@@ -21,7 +23,7 @@ describe Mutant::Mutator, 'block' do
21
23
  let(:source) { 'foo { |a, b| }' }
22
24
 
23
25
  before do
24
- Mutant::Random.stub(:hex_string => :random)
26
+ Mutant::Random.stub(:hex_string => 'random')
25
27
  end
26
28
 
27
29
  let(:mutations) do
@@ -41,7 +43,7 @@ describe Mutant::Mutator, 'block' do
41
43
  context 'with block pattern args' do
42
44
 
43
45
  before do
44
- Mutant::Random.stub(:hex_string => :random)
46
+ Mutant::Random.stub(:hex_string => 'random')
45
47
  end
46
48
 
47
49
  let(:source) { 'foo { |(a, b), c| }' }
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::NamedValue::Access, 'block_pass' do
6
+ let(:source) { 'foo(&bar)' }
7
+
8
+ let(:mutations) do
9
+ mutants = []
10
+ mutants << 'foo'
11
+ end
12
+
13
+ it_should_behave_like 'a mutator'
14
+ end
@@ -0,0 +1,15 @@
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,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Case do
@@ -1,11 +1,8 @@
1
- require 'spec_helper'
2
-
3
- describe Mutant::Mutator::Node::NamedValue::Access, 'cbase' do
1
+ # encoding: utf-8
4
2
 
5
- before do
6
- Mutant::Random.stub(:hex_string => :random)
7
- end
3
+ require 'spec_helper'
8
4
 
5
+ describe Mutant::Mutator::Node::Noop, 'cbase' do
9
6
  let(:source) { '::A' }
10
7
 
11
8
  let(:mutations) do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Connective::Binary, 'mutations' do
@@ -1,11 +1,8 @@
1
- require 'spec_helper'
2
-
3
- describe Mutant::Mutator::Node::NamedValue::Access, 'const' do
1
+ # encoding: utf-8
4
2
 
5
- before do
6
- Mutant::Random.stub(:hex_string => :random)
7
- end
3
+ require 'spec_helper'
8
4
 
5
+ describe Mutant::Mutator::Node::Const, 'const' do
9
6
  let(:source) { 'A::B' }
10
7
 
11
8
  let(:mutations) do
@@ -1,7 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, 'def' do
4
-
5
6
  context 'empty' do
6
7
  let(:source) { 'def foo; end' }
7
8
 
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'defined?' do
6
+ let(:source) { 'defined?(foo)' }
7
+ let(:mutations) { [] }
8
+
9
+ it_should_behave_like 'a mutator'
10
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'dstr' do
6
+ before do
7
+ Mutant::Random.stub(:hex_string => 'random')
8
+ end
9
+
10
+ let(:source) { '"foo#{bar}baz"' }
11
+
12
+ let(:mutations) do
13
+ mutations = []
14
+ mutations << '"random#{bar}baz"'
15
+ mutations << '"#{nil}#{bar}baz"'
16
+ mutations << '"foo#{bar}random"'
17
+ mutations << '"foo#{bar}#{nil}"'
18
+ end
19
+
20
+ it_should_behave_like 'a mutator'
21
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'dsum' do
6
+ before do
7
+ Mutant::Random.stub(:hex_string => 'random')
8
+ end
9
+
10
+ let(:source) { ':"foo#{bar}baz"' }
11
+
12
+ let(:mutations) do
13
+ mutations = []
14
+ mutations << ':"random#{bar}baz"'
15
+ mutations << ':"#{nil}#{bar}baz"'
16
+ mutations << ':"foo#{bar}random"'
17
+ mutations << ':"foo#{bar}#{nil}"'
18
+ end
19
+
20
+ it_should_behave_like 'a mutator'
21
+ end
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'ensure' do
6
+ let(:source) { 'begin; rescue; ensure; true; end' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'begin; rescue; ensure; false; end'
11
+ mutations << 'begin; rescue; ensure; nil; end'
12
+ end
13
+
14
+ it_should_behave_like 'a mutator'
15
+ end
@@ -1,7 +1,8 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, 'if' do
4
-
5
6
  before do
6
7
  Mutant::Random.stub(:hex_string => 'random')
7
8
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'array' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'boolean' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'fixnum' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'float' do
@@ -9,8 +11,8 @@ describe Mutant::Mutator::Node::Literal, 'float' do
9
11
  mutations << '0.0'
10
12
  mutations << '1.0'
11
13
  mutations << random_float.to_s
12
- mutations << '0.0/0.0'
13
- mutations << '1.0/0.0'
14
+ mutations << '(0.0 / 0.0)'
15
+ mutations << '(1.0 / 0.0)'
14
16
  mutations << '(-1.0 / 0.0)'
15
17
  mutations << '-10.0'
16
18
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'hash' do
@@ -1,11 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'nil' do
4
- let(:source) { 'nil' }
5
-
6
- let(:mutations) do
7
- [ '::Object.new' ]
8
- end
6
+ let(:source) { 'nil' }
7
+ let(:mutations) { ['::Object.new'] }
9
8
 
10
9
  it_should_behave_like 'a mutator'
11
10
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'range' do
@@ -8,10 +10,9 @@ describe Mutant::Mutator::Node::Literal, 'range' do
8
10
  mutations = []
9
11
  mutations << 'nil'
10
12
  mutations << '1...100'
11
- mutations << '(0.0/0.0)..100'
12
- #mutations << [:dot2, [:negate, [:call, [:lit, 1.0], :/, [:arglist, [:lit, 0.0]]]], [:lit, 100]]
13
- mutations << '1..(1.0/0.0)'
14
- mutations << '1..(0.0/0.0)'
13
+ mutations << '(0.0 / 0.0)..100'
14
+ mutations << '1..(1.0 / 0.0)'
15
+ mutations << '1..(0.0 / 0.0)'
15
16
  end
16
17
 
17
18
  it_should_behave_like 'a mutator'
@@ -24,10 +25,9 @@ describe Mutant::Mutator::Node::Literal, 'range' do
24
25
  mutations = []
25
26
  mutations << 'nil'
26
27
  mutations << '1..100'
27
- mutations << '(0.0/0.0)...100'
28
- #mutations << [:dot3, [:negate, [:call, [:lit, 1.0], :/, [:arglist, [:lit, 0.0]]]], [:lit, 100]]
29
- mutations << '1...(1.0/0.0)'
30
- mutations << '1...(0.0/0.0)'
28
+ mutations << '(0.0 / 0.0)...100'
29
+ mutations << '1...(1.0 / 0.0)'
30
+ mutations << '1...(0.0 / 0.0)'
31
31
  end
32
32
 
33
33
  it_should_behave_like 'a mutator'
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'regex' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'string' do
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::Literal, 'symbol' do
@@ -1,16 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator, 'masgn' do
4
-
5
- before do
6
- Mutant::Random.stub(:hex_string => 'random')
7
- end
8
-
9
- let(:source) { 'a, b = c, d' }
10
-
11
- let(:mutations) do
12
- mutants = []
13
- end
6
+ let(:source) { 'a, b = c, d' }
7
+ let(:mutations) { [] }
14
8
 
15
9
  it_should_behave_like 'a mutator'
16
10
  end
@@ -0,0 +1,20 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'match_current_line' do
6
+ let(:source) { 'true if //' }
7
+
8
+ let(:mutations) do
9
+ mutations = []
10
+ mutations << 'false if //'
11
+ mutations << 'nil if //'
12
+ mutations << 'true if true'
13
+ mutations << 'true if false'
14
+ mutations << 'true if nil'
15
+ mutations << 'true if !//'
16
+ mutations << 'true if /a\A/'
17
+ end
18
+
19
+ it_should_behave_like 'a mutator'
20
+ end
@@ -1,9 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
4
-
5
6
  before do
6
- Mutant::Random.stub(:hex_string => :random)
7
+ Mutant::Random.stub(:hex_string => 'random')
7
8
  end
8
9
 
9
10
  context 'global variable' do
@@ -1,9 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
4
-
5
6
  before do
6
- Mutant::Random.stub(:hex_string => :random)
7
+ Mutant::Random.stub(:hex_string => 'random')
7
8
  end
8
9
 
9
10
  let(:source) { 'A = true' }
@@ -1,9 +1,10 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
4
-
5
6
  before do
6
- Mutant::Random.stub(:hex_string => :random)
7
+ Mutant::Random.stub(:hex_string => 'random')
7
8
  end
8
9
 
9
10
  context 'global variable' do
@@ -0,0 +1,15 @@
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
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Mutant::Mutator::Node::Generic, 'op_asgn' do
6
+ let(:random_fixnum) { 5 }
7
+
8
+ let(:source) { '@a.b += 1' }
9
+
10
+ let(:mutations) do
11
+ mutations = []
12
+ mutations << '@a.b += -1'
13
+ mutations << '@a.b += 2'
14
+ mutations << '@a.b += 0'
15
+ mutations << '@a.b += nil'
16
+ mutations << '@a += 1'
17
+ mutations << '@a.b += 5'
18
+ mutations << 'nil.b += 1'
19
+ end
20
+
21
+ before do
22
+ Mutant::Random.stub(:fixnum => random_fixnum)
23
+ end
24
+
25
+ it_should_behave_like 'a mutator'
26
+ end