mutant 0.5.17 → 0.5.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +6 -0
  3. data/Rakefile +13 -0
  4. data/config/flay.yml +1 -1
  5. data/config/reek.yml +8 -1
  6. data/lib/mutant.rb +18 -3
  7. data/lib/mutant/cli.rb +6 -3
  8. data/lib/mutant/constants.rb +3 -0
  9. data/lib/mutant/expression.rb +110 -0
  10. data/lib/mutant/expression/method.rb +92 -0
  11. data/lib/mutant/expression/namespace.rb +90 -0
  12. data/lib/mutant/matcher/namespace.rb +3 -4
  13. data/lib/mutant/meta.rb +31 -0
  14. data/lib/mutant/meta/example.rb +152 -0
  15. data/lib/mutant/meta/example/dsl.rb +105 -0
  16. data/lib/mutant/mutator/node.rb +6 -6
  17. data/lib/mutant/mutator/node/arguments.rb +1 -1
  18. data/lib/mutant/mutator/node/begin.rb +1 -1
  19. data/lib/mutant/mutator/node/const.rb +1 -1
  20. data/lib/mutant/mutator/node/if.rb +6 -6
  21. data/lib/mutant/mutator/node/literal/array.rb +2 -2
  22. data/lib/mutant/mutator/node/literal/hash.rb +2 -2
  23. data/lib/mutant/mutator/node/literal/range.rb +3 -3
  24. data/lib/mutant/mutator/node/literal/regex.rb +2 -2
  25. data/lib/mutant/mutator/node/literal/symbol.rb +1 -1
  26. data/lib/mutant/mutator/node/op_asgn.rb +1 -3
  27. data/lib/mutant/mutator/node/or_asgn.rb +31 -0
  28. data/lib/mutant/mutator/node/send.rb +1 -1
  29. data/lib/mutant/mutator/node/send/attribute_assignment.rb +1 -1
  30. data/lib/mutant/reporter/cli/report/mutation.rb +11 -1
  31. data/lib/mutant/strategy.rb +1 -1
  32. data/lib/mutant/version.rb +1 -1
  33. data/meta/and.rb +12 -0
  34. data/meta/and_asgn.rb +12 -0
  35. data/meta/array.rb +30 -0
  36. data/meta/begin.rb +15 -0
  37. data/meta/binary.rb +12 -0
  38. data/meta/block.rb +55 -0
  39. data/meta/block_pass.rb +8 -0
  40. data/meta/blockarg.rb +10 -0
  41. data/meta/boolean.rb +15 -0
  42. data/meta/break.rb +11 -0
  43. data/meta/case.rb +303 -0
  44. data/meta/casgn.rb +9 -0
  45. data/meta/cbase.rb +8 -0
  46. data/meta/const.rb +9 -0
  47. data/meta/cvar.rb +7 -0
  48. data/meta/cvasgn.rb +10 -0
  49. data/meta/define.rb +118 -0
  50. data/meta/defined.rb +7 -0
  51. data/meta/dstr.rb +10 -0
  52. data/meta/dsym.rb +11 -0
  53. data/meta/ensure.rb +9 -0
  54. data/meta/fixnum.rb +19 -0
  55. data/meta/float.rb +38 -0
  56. data/meta/gvar.rb +7 -0
  57. data/meta/gvasgn.rb +10 -0
  58. data/meta/hash.rb +25 -0
  59. data/meta/if.rb +57 -0
  60. data/meta/ivasgn.rb +10 -0
  61. data/meta/kwbegin.rb +9 -0
  62. data/meta/lvar.rb +14 -0
  63. data/meta/lvasgn.rb +10 -0
  64. data/meta/masgn.rb +7 -0
  65. data/meta/match_current_line.rb +14 -0
  66. data/meta/next.rb +11 -0
  67. data/meta/nil.rb +5 -0
  68. data/meta/nthref.rb +14 -0
  69. data/meta/op_assgn.rb +15 -0
  70. data/meta/or_asgn.rb +22 -0
  71. data/meta/range.rb +41 -0
  72. data/meta/redo.rb +5 -0
  73. data/meta/regex.rb +20 -0
  74. data/meta/rescue.rb +38 -0
  75. data/meta/restarg.rb +11 -0
  76. data/meta/return.rb +15 -0
  77. data/meta/self.rb +7 -0
  78. data/meta/send.rb +240 -0
  79. data/meta/string.rb +7 -0
  80. data/meta/super.rb +26 -0
  81. data/meta/symbol.rb +8 -0
  82. data/meta/unless.rb +15 -0
  83. data/meta/while.rb +24 -0
  84. data/meta/yield.rb +10 -0
  85. data/mutant.gemspec +1 -0
  86. data/spec/integration/mutant/corpus_spec.rb +29 -25
  87. data/spec/spec_helper.rb +2 -0
  88. data/spec/support/mutation_verifier.rb +1 -0
  89. data/spec/unit/mutant/cli_new_spec.rb +6 -6
  90. data/spec/unit/mutant/expression/method_spec.rb +50 -0
  91. data/spec/unit/mutant/expression/namespace/flat_spec.rb +32 -0
  92. data/spec/unit/mutant/expression/namespace/recursive_spec.rb +37 -0
  93. data/spec/unit/mutant/matcher/namespace_spec.rb +2 -2
  94. data/spec/unit/mutant/mutation_spec.rb +1 -1
  95. data/spec/unit/mutant/mutator/node_spec.rb +14 -0
  96. metadata +123 -139
  97. data/lib/mutant/cli/classifier.rb +0 -139
  98. data/lib/mutant/cli/classifier/method.rb +0 -105
  99. data/lib/mutant/cli/classifier/namespace.rb +0 -49
  100. data/spec/unit/mutant/cli/classifier/method_spec.rb +0 -77
  101. data/spec/unit/mutant/cli/classifier/namespace/flat_spec.rb +0 -58
  102. data/spec/unit/mutant/cli/classifier/namespace/recursive_spec.rb +0 -58
  103. data/spec/unit/mutant/cli/classifier_spec.rb +0 -59
  104. data/spec/unit/mutant/mutator/node/and_asgn_spec.rb +0 -19
  105. data/spec/unit/mutant/mutator/node/begin_spec.rb +0 -32
  106. data/spec/unit/mutant/mutator/node/binary_spec.rb +0 -41
  107. data/spec/unit/mutant/mutator/node/block_pass_spec.rb +0 -15
  108. data/spec/unit/mutant/mutator/node/block_spec.rb +0 -83
  109. data/spec/unit/mutant/mutator/node/blockarg_spec.rb +0 -17
  110. data/spec/unit/mutant/mutator/node/case_spec.rb +0 -329
  111. data/spec/unit/mutant/mutator/node/cbase_spec.rb +0 -15
  112. data/spec/unit/mutant/mutator/node/conditional_loop_spec.rb +0 -58
  113. data/spec/unit/mutant/mutator/node/const_spec.rb +0 -16
  114. data/spec/unit/mutant/mutator/node/define_spec.rb +0 -171
  115. data/spec/unit/mutant/mutator/node/defined_spec.rb +0 -14
  116. data/spec/unit/mutant/mutator/node/dstr_spec.rb +0 -17
  117. data/spec/unit/mutant/mutator/node/dsym_spec.rb +0 -18
  118. data/spec/unit/mutant/mutator/node/ensure_spec.rb +0 -16
  119. data/spec/unit/mutant/mutator/node/if_spec.rb +0 -77
  120. data/spec/unit/mutant/mutator/node/kwbegin_spec.rb +0 -16
  121. data/spec/unit/mutant/mutator/node/literal/array_spec.rb +0 -47
  122. data/spec/unit/mutant/mutator/node/literal/boolean_spec.rb +0 -25
  123. data/spec/unit/mutant/mutator/node/literal/fixnum_spec.rb +0 -13
  124. data/spec/unit/mutant/mutator/node/literal/float_spec.rb +0 -53
  125. data/spec/unit/mutant/mutator/node/literal/hash_spec.rb +0 -33
  126. data/spec/unit/mutant/mutator/node/literal/nil_spec.rb +0 -10
  127. data/spec/unit/mutant/mutator/node/literal/range_spec.rb +0 -56
  128. data/spec/unit/mutant/mutator/node/literal/regex_spec.rb +0 -36
  129. data/spec/unit/mutant/mutator/node/literal/string_spec.rb +0 -15
  130. data/spec/unit/mutant/mutator/node/literal/symbol_spec.rb +0 -15
  131. data/spec/unit/mutant/mutator/node/loop_ctrl_spec.rb +0 -37
  132. data/spec/unit/mutant/mutator/node/masgn_spec.rb +0 -14
  133. data/spec/unit/mutant/mutator/node/match_current_line_spec.rb +0 -21
  134. data/spec/unit/mutant/mutator/node/named_value/access_spec.rb +0 -78
  135. data/spec/unit/mutant/mutator/node/named_value/constant_assignment_spec.rb +0 -16
  136. data/spec/unit/mutant/mutator/node/named_value/variable_assignment_spec.rb +0 -61
  137. data/spec/unit/mutant/mutator/node/nthref_spec.rb +0 -19
  138. data/spec/unit/mutant/mutator/node/op_assgn_spec.rb +0 -22
  139. data/spec/unit/mutant/mutator/node/or_asgn_spec.rb +0 -19
  140. data/spec/unit/mutant/mutator/node/redo_spec.rb +0 -10
  141. data/spec/unit/mutant/mutator/node/rescue_spec.rb +0 -63
  142. data/spec/unit/mutant/mutator/node/restarg_spec.rb +0 -18
  143. data/spec/unit/mutant/mutator/node/return_spec.rb +0 -31
  144. data/spec/unit/mutant/mutator/node/send_spec.rb +0 -382
  145. data/spec/unit/mutant/mutator/node/super_spec.rb +0 -46
  146. data/spec/unit/mutant/mutator/node/yield_spec.rb +0 -17
@@ -1,25 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'boolean' do
6
- context 'true literal' do
7
- let(:source) { 'true' }
8
-
9
- let(:mutations) do
10
- %w[nil false]
11
- end
12
-
13
- it_should_behave_like 'a mutator'
14
- end
15
-
16
- context 'false literal' do
17
- let(:source) { 'false' }
18
-
19
- let(:mutations) do
20
- %w[nil true]
21
- end
22
-
23
- it_should_behave_like 'a mutator'
24
- end
25
- end
@@ -1,13 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'fixnum' do
6
- let(:source) { '10' }
7
-
8
- let(:mutations) do
9
- %w[nil 0 1 -10 9 11]
10
- end
11
-
12
- it_should_behave_like 'a mutator'
13
- end
@@ -1,53 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'float' do
6
-
7
- context 'positive number' do
8
- let(:source) { '10.0' }
9
-
10
- let(:mutations) do
11
- mutations = []
12
- mutations << 'nil'
13
- mutations << '0.0'
14
- mutations << '1.0'
15
- mutations << '(0.0 / 0.0)'
16
- mutations << '(1.0 / 0.0)'
17
- mutations << '(-1.0 / 0.0)'
18
- mutations << '-10.0'
19
- end
20
-
21
- it_should_behave_like 'a mutator'
22
- end
23
-
24
- context '0.0' do
25
- let(:source) { '0.0' }
26
-
27
- let(:mutations) do
28
- mutations = []
29
- mutations << 'nil'
30
- mutations << '1.0'
31
- mutations << '(0.0 / 0.0)'
32
- mutations << '(1.0 / 0.0)'
33
- mutations << '(-1.0 / 0.0)'
34
- end
35
-
36
- it_should_behave_like 'a mutator'
37
- end
38
-
39
- context '-0.0' do
40
- let(:source) { '-0.0' }
41
-
42
- let(:mutations) do
43
- mutations = []
44
- mutations << 'nil'
45
- mutations << '1.0'
46
- mutations << '(0.0 / 0.0)'
47
- mutations << '(1.0 / 0.0)'
48
- mutations << '(-1.0 / 0.0)'
49
- end
50
-
51
- it_should_behave_like 'a mutator'
52
- end
53
- end
@@ -1,33 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'hash' do
6
- let(:source) { '{true => true, false => false}' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
-
11
- # Literal replaced with nil
12
- mutations << 'nil'
13
-
14
- # Mutation of each key and value in hash
15
- mutations << '{ false => true , false => false }'
16
- mutations << '{ nil => true , false => false }'
17
- mutations << '{ true => false , false => false }'
18
- mutations << '{ true => nil , false => false }'
19
- mutations << '{ true => true , true => false }'
20
- mutations << '{ true => true , nil => false }'
21
- mutations << '{ true => true , false => true }'
22
- mutations << '{ true => true , false => nil }'
23
-
24
- # Remove each key once
25
- mutations << '{ true => true }'
26
- mutations << '{ false => false }'
27
-
28
- # Empty hash
29
- mutations << '{}'
30
- end
31
-
32
- it_should_behave_like 'a mutator'
33
- end
@@ -1,10 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'nil' do
6
- let(:source) { 'nil' }
7
- let(:mutations) { [] }
8
-
9
- it_should_behave_like 'a mutator'
10
- end
@@ -1,56 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'range' do
6
-
7
- context 'inclusive range literal' do
8
- let(:source) { '1..100' }
9
-
10
- let(:mutations) do
11
- mutations = []
12
- mutations << 'nil'
13
- mutations << '1...100'
14
- mutations << '(0.0 / 0.0)..100'
15
- mutations << '1..(1.0 / 0.0)'
16
- mutations << '1..(0.0 / 0.0)'
17
- mutations << '-1..100'
18
- mutations << '0..100'
19
- mutations << '2..100'
20
- mutations << 'nil..100'
21
- mutations << '1..nil'
22
- mutations << '1..0'
23
- mutations << '1..1'
24
- mutations << '1..99'
25
- mutations << '1..101'
26
- mutations << '1..-100'
27
- end
28
-
29
- it_should_behave_like 'a mutator'
30
- end
31
-
32
- context 'exclusive range literal' do
33
- let(:source) { '1...100' }
34
-
35
- let(:mutations) do
36
- mutations = []
37
- mutations << 'nil'
38
- mutations << '1..100'
39
- mutations << '(0.0 / 0.0)...100'
40
- mutations << '1...(1.0 / 0.0)'
41
- mutations << '1...(0.0 / 0.0)'
42
- mutations << '-1...100'
43
- mutations << '0...100'
44
- mutations << '2...100'
45
- mutations << 'nil...100'
46
- mutations << '1...nil'
47
- mutations << '1...0'
48
- mutations << '1...1'
49
- mutations << '1...99'
50
- mutations << '1...101'
51
- mutations << '1...-100'
52
- end
53
-
54
- it_should_behave_like 'a mutator'
55
- end
56
- end
@@ -1,36 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'regex' do
6
-
7
- context 'literal' do
8
- let(:source) { '/foo/' }
9
-
10
- let(:mutations) do
11
- mutations = []
12
- mutations << '//' # match all
13
- mutations << '/a\A/' # match nothing
14
- mutations << 'nil'
15
- end
16
-
17
- it_should_behave_like 'a mutator'
18
- end
19
-
20
- context 'interpolated' do
21
- let(:source) { '/#{foo.bar}n/' }
22
-
23
- let(:mutations) do
24
- mutations = []
25
- mutations << '//' # match all
26
- mutations << '/#{foo}n/' # match all
27
- mutations << '/a\A/' # match nothing
28
- mutations << '/#{nil.bar}n/'
29
- mutations << '/#{nil}n/'
30
- mutations << 'nil'
31
- end
32
-
33
- it_should_behave_like 'a mutator'
34
- end
35
-
36
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::Literal, 'string' do
6
- let(:random_string) { 'bar' }
7
-
8
- let(:source) { '"foo"' }
9
-
10
- let(:mutations) do
11
- %w[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::Literal, 'symbol' do
6
- let(:random_string) { 'bar' }
7
-
8
- let(:source) { ':foo' }
9
-
10
- let(:mutations) do
11
- %w[nil :foo__mutant__]
12
- end
13
-
14
- it_should_behave_like 'a mutator'
15
- end
@@ -1,37 +0,0 @@
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
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator, 'masgn' do
6
- let(:source) { 'a, b = c, d' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'nil'
11
- end
12
-
13
- it_should_behave_like 'a mutator'
14
- end
@@ -1,21 +0,0 @@
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 /foo/' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'false if /foo/'
11
- mutations << 'true if //'
12
- mutations << 'nil if /foo/'
13
- mutations << 'true if true'
14
- mutations << 'true if false'
15
- mutations << 'true if nil'
16
- mutations << 'true if /a\A/'
17
- mutations << 'nil'
18
- end
19
-
20
- it_should_behave_like 'a mutator'
21
- end
@@ -1,78 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::NamedValue::Access, 'mutations' do
6
-
7
- context 'global variable' do
8
- let(:source) { '$a = nil; $a' }
9
-
10
- let(:mutations) do
11
- mutants = []
12
- mutants << '$a = nil; nil'
13
- mutants << '$a = nil'
14
- mutants << '$a'
15
- mutants << '$a__mutant__ = nil; $a'
16
- mutants << 'nil; $a'
17
- end
18
-
19
- it_should_behave_like 'a mutator'
20
- end
21
-
22
- context 'class variable' do
23
- let(:source) { '@@a = nil; @@a' }
24
-
25
- let(:mutations) do
26
- mutants = []
27
- mutants << '@@a = nil; nil'
28
- mutants << '@@a = nil'
29
- mutants << '@@a'
30
- mutants << '@@a__mutant__ = nil; @@a'
31
- mutants << 'nil; @@a'
32
- end
33
- end
34
-
35
- context 'instance variable' do
36
- let(:source) { '@a = nil; @a' }
37
-
38
- let(:mutations) do
39
- mutants = []
40
- mutants << '@a = nil; nil'
41
- mutants << '@a = nil'
42
- mutants << '@a'
43
- mutants << '@a__mutant__ = nil; @a'
44
- mutants << 'nil; @a'
45
- end
46
-
47
- it_should_behave_like 'a mutator'
48
- end
49
-
50
- context 'local variable' do
51
- let(:source) { 'a = nil; a' }
52
-
53
- let(:mutations) do
54
- mutants = []
55
- mutants << 'a = nil; nil'
56
- mutants << 'a = nil'
57
- # TODO: fix invalid AST
58
- # These ASTs are not valid and should NOT be emitted
59
- # Mutations of lvarasgn need to be special cased to avoid this.
60
- mutants << s(:begin, s(:lvasgn, :a__mutant__, s(:nil)), s(:lvar, :a))
61
- mutants << s(:begin, s(:nil), s(:lvar, :a))
62
- mutants << s(:lvar, :a)
63
- end
64
-
65
- it_should_behave_like 'a mutator'
66
- end
67
-
68
- context 'self' do
69
- let(:source) { 'self' }
70
-
71
- let(:mutations) do
72
- mutants = []
73
- mutants << 'nil'
74
- end
75
-
76
- it_should_behave_like 'a mutator'
77
- end
78
- end
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe Mutant::Mutator::Node::NamedValue::VariableAssignment, 'mutations' do
6
- let(:source) { 'A = true' }
7
-
8
- let(:mutations) do
9
- mutations = []
10
- mutations << 'A__MUTANT__ = true'
11
- mutations << 'A = false'
12
- mutations << 'A = nil'
13
- end
14
-
15
- it_should_behave_like 'a mutator'
16
- end