mutant 0.5.18 → 0.5.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog.md +7 -0
  3. data/README.md +2 -2
  4. data/config/flay.yml +1 -1
  5. data/lib/mutant.rb +4 -1
  6. data/lib/mutant/meta/example/dsl.rb +11 -0
  7. data/lib/mutant/mutator/node.rb +29 -5
  8. data/lib/mutant/mutator/node/and_asgn.rb +34 -0
  9. data/lib/mutant/mutator/node/binary.rb +1 -1
  10. data/lib/mutant/mutator/node/block.rb +1 -1
  11. data/lib/mutant/mutator/node/break.rb +29 -0
  12. data/lib/mutant/mutator/node/case.rb +1 -1
  13. data/lib/mutant/mutator/node/conditional_loop.rb +1 -1
  14. data/lib/mutant/mutator/node/const.rb +1 -1
  15. data/lib/mutant/mutator/node/defined.rb +30 -0
  16. data/lib/mutant/mutator/node/dstr.rb +1 -1
  17. data/lib/mutant/mutator/node/dsym.rb +1 -1
  18. data/lib/mutant/mutator/node/generic.rb +1 -1
  19. data/lib/mutant/mutator/node/if.rb +4 -2
  20. data/lib/mutant/mutator/node/kwbegin.rb +1 -1
  21. data/lib/mutant/mutator/node/literal/array.rb +1 -1
  22. data/lib/mutant/mutator/node/literal/fixnum.rb +1 -1
  23. data/lib/mutant/mutator/node/literal/float.rb +1 -1
  24. data/lib/mutant/mutator/node/literal/hash.rb +1 -1
  25. data/lib/mutant/mutator/node/literal/range.rb +1 -1
  26. data/lib/mutant/mutator/node/literal/regex.rb +1 -1
  27. data/lib/mutant/mutator/node/literal/string.rb +1 -1
  28. data/lib/mutant/mutator/node/literal/symbol.rb +1 -1
  29. data/lib/mutant/mutator/node/masgn.rb +1 -1
  30. data/lib/mutant/mutator/node/match_current_line.rb +1 -1
  31. data/lib/mutant/mutator/node/named_value/access.rb +1 -1
  32. data/lib/mutant/mutator/node/named_value/variable_assignment.rb +1 -1
  33. data/lib/mutant/mutator/node/{loop_control.rb → next.rb} +5 -9
  34. data/lib/mutant/mutator/node/op_asgn.rb +9 -4
  35. data/lib/mutant/mutator/node/or_asgn.rb +6 -2
  36. data/lib/mutant/mutator/node/resbody.rb +2 -2
  37. data/lib/mutant/mutator/node/return.rb +1 -1
  38. data/lib/mutant/mutator/node/send.rb +1 -1
  39. data/lib/mutant/mutator/node/splat.rb +1 -1
  40. data/lib/mutant/mutator/node/super.rb +1 -1
  41. data/lib/mutant/mutator/node/yield.rb +1 -1
  42. data/lib/mutant/mutator/node/zsuper.rb +1 -1
  43. data/lib/mutant/node_helpers.rb +6 -5
  44. data/lib/mutant/version.rb +1 -1
  45. data/meta/and.rb +1 -1
  46. data/meta/and_asgn.rb +3 -1
  47. data/meta/array.rb +2 -2
  48. data/meta/block.rb +6 -4
  49. data/meta/block_pass.rb +1 -1
  50. data/meta/blockarg.rb +1 -1
  51. data/meta/break.rb +1 -2
  52. data/meta/case.rb +104 -183
  53. data/meta/cbase.rb +1 -1
  54. data/meta/const.rb +1 -1
  55. data/meta/cvar.rb +1 -1
  56. data/meta/cvasgn.rb +1 -1
  57. data/meta/{define.rb → def.rb} +2 -1
  58. data/meta/dstr.rb +4 -1
  59. data/meta/dsym.rb +4 -2
  60. data/meta/ensure.rb +1 -1
  61. data/meta/false.rb +8 -0
  62. data/meta/float.rb +3 -4
  63. data/meta/gvar.rb +1 -1
  64. data/meta/gvasgn.rb +1 -1
  65. data/meta/hash.rb +1 -2
  66. data/meta/if.rb +25 -27
  67. data/meta/{fixnum.rb → int.rb} +1 -2
  68. data/meta/ivasgn.rb +1 -1
  69. data/meta/kwbegin.rb +1 -1
  70. data/meta/lvar.rb +2 -0
  71. data/meta/lvasgn.rb +1 -1
  72. data/meta/masgn.rb +1 -1
  73. data/meta/match_current_line.rb +1 -1
  74. data/meta/next.rb +1 -1
  75. data/meta/op_assgn.rb +3 -1
  76. data/meta/{binary.rb → or.rb} +1 -1
  77. data/meta/or_asgn.rb +4 -2
  78. data/meta/range.rb +6 -2
  79. data/meta/regex.rb +4 -2
  80. data/meta/rescue.rb +7 -6
  81. data/meta/restarg.rb +3 -1
  82. data/meta/return.rb +3 -2
  83. data/meta/send.rb +48 -51
  84. data/meta/{string.rb → str.rb} +1 -1
  85. data/meta/super.rb +6 -3
  86. data/meta/symbol.rb +1 -1
  87. data/meta/true.rb +8 -0
  88. data/meta/until.rb +17 -0
  89. data/meta/while.rb +4 -2
  90. data/meta/yield.rb +1 -1
  91. data/spec/spec_helper.rb +1 -1
  92. metadata +13 -8
  93. data/meta/unless.rb +0 -15
data/meta/cbase.rb CHANGED
@@ -3,6 +3,6 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '::A'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation 'A'
8
8
  end
data/meta/const.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'A::B::C'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation 'B::C'
8
8
  mutation 'C'
9
9
  end
data/meta/cvar.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '@@a'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
data/meta/cvasgn.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '@@a = true'
5
5
 
6
+ singleton_mutations
6
7
  mutation '@@a__mutant__ = true'
7
8
  mutation '@@a = false'
8
9
  mutation '@@a = nil'
9
- mutation 'nil'
10
10
  end
@@ -7,10 +7,11 @@ Mutant::Meta::Example.add do
7
7
  end
8
8
 
9
9
  Mutant::Meta::Example.add do
10
- source "def foo\nfoo\nrescue\nend"
10
+ source 'def foo; foo; rescue; end'
11
11
 
12
12
  mutation 'def foo; raise; end'
13
13
  mutation 'def foo; nil; rescue; end'
14
+ mutation 'def foo; self; rescue; end'
14
15
  mutation 'def foo; end'
15
16
  end
16
17
 
data/meta/dstr.rb CHANGED
@@ -3,8 +3,11 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '"foo#{bar}baz"'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation '"#{nil}#{bar}baz"'
8
+ mutation '"#{self}#{bar}baz"'
8
9
  mutation '"foo#{bar}#{nil}"'
10
+ mutation '"foo#{bar}#{self}"'
9
11
  mutation '"foo#{nil}baz"'
12
+ mutation '"foo#{self}baz"'
10
13
  end
data/meta/dsym.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  Mutant::Meta::Example.add do
4
-
5
4
  source ':"foo#{bar}baz"'
6
5
 
6
+ singleton_mutations
7
7
  mutation ':"#{nil}#{bar}baz"'
8
+ mutation ':"#{self}#{bar}baz"'
8
9
  mutation ':"foo#{bar}#{nil}"'
10
+ mutation ':"foo#{bar}#{self}"'
9
11
  mutation ':"foo#{nil}baz"'
10
- mutation 'nil'
12
+ mutation ':"foo#{self}baz"'
11
13
  end
data/meta/ensure.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'begin; rescue; ensure; true; end'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'begin; rescue; ensure; false; end'
7
8
  mutation 'begin; rescue; ensure; nil; end'
8
- mutation 'nil'
9
9
  end
data/meta/false.rb ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ Mutant::Meta::Example.add do
4
+ source 'false'
5
+
6
+ mutation 'nil'
7
+ mutation 'true'
8
+ end
data/meta/float.rb CHANGED
@@ -3,8 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '10.0'
5
5
 
6
- # generic
7
- mutation 'nil'
6
+ singleton_mutations
8
7
 
9
8
  # edge cases
10
9
  mutation '0.0'
@@ -20,7 +19,7 @@ end
20
19
  Mutant::Meta::Example.add do
21
20
  source '0.0'
22
21
 
23
- mutation 'nil'
22
+ singleton_mutations
24
23
  mutation '1.0'
25
24
  mutation '(0.0 / 0.0)'
26
25
  mutation '(1.0 / 0.0)'
@@ -30,7 +29,7 @@ end
30
29
  Mutant::Meta::Example.add do
31
30
  source '-0.0'
32
31
 
33
- mutation 'nil'
32
+ singleton_mutations
34
33
  mutation '1.0'
35
34
  mutation '(0.0 / 0.0)'
36
35
  mutation '(1.0 / 0.0)'
data/meta/gvar.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '$a'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
data/meta/gvasgn.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '$a = true'
5
5
 
6
+ singleton_mutations
6
7
  mutation '$a__mutant__ = true'
7
8
  mutation '$a = false'
8
9
  mutation '$a = nil'
9
- mutation 'nil'
10
10
  end
data/meta/hash.rb CHANGED
@@ -3,8 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '{true => true, false => false}'
5
5
 
6
- # Literal replaced with nil
7
- mutation 'nil'
6
+ singleton_mutations
8
7
 
9
8
  # Mutation of each key and value in hash
10
9
  mutation '{ false => true , false => false }'
data/meta/if.rb CHANGED
@@ -1,57 +1,55 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  Mutant::Meta::Example.add do
4
- source 'if :condition; true; else false; end'
4
+ source 'if condition; true; else false; end'
5
+
6
+ singleton_mutations
5
7
 
6
8
  # mutation of condition
7
- mutation 'if :condition__mutant__; true; else false; end'
8
- mutation 'if !:condition; true; else false; end'
9
- mutation 'if nil; true; else false; end'
10
- mutation 'if true; true; else false; end'
11
- mutation 'if false; true; else false; end'
9
+ mutation 'if !condition; true; else false; end'
10
+ mutation 'if nil; true; else false; end'
11
+ mutation 'if true; true; else false; end'
12
+ mutation 'if false; true; else false; end'
12
13
 
13
14
  # Deleted else branch
14
- mutation 'if :condition; true end'
15
+ mutation 'if condition; true end'
15
16
 
16
17
  # Deleted if branch resuting in unless rendering
17
- mutation 'unless :condition; false; end'
18
+ mutation 'unless condition; false; end'
18
19
 
19
20
  # Deleted if branch with promoting else branch to if branch
20
- mutation 'if :condition; false end'
21
+ mutation 'if condition; false end'
21
22
 
22
23
  # mutation of if body
23
- mutation 'if :condition; false; else false; end'
24
- mutation 'if :condition; nil; else false; end'
24
+ mutation 'if condition; false; else false; end'
25
+ mutation 'if condition; nil; else false; end'
25
26
 
26
27
  # mutation of else body
27
- mutation 'if :condition; true; else true; end'
28
- mutation 'if :condition; true; else nil; end'
29
-
30
- mutation 'nil'
28
+ mutation 'if condition; true; else true; end'
29
+ mutation 'if condition; true; else nil; end'
31
30
  end
32
31
 
33
32
  Mutant::Meta::Example.add do
34
33
  source 'if condition; true; end'
35
34
 
35
+ singleton_mutations
36
36
  mutation 'if !condition; true; end'
37
37
  mutation 'if condition; false; end'
38
38
  mutation 'if condition; nil; end'
39
39
  mutation 'if true; true; end'
40
40
  mutation 'if false; true; end'
41
41
  mutation 'if nil; true; end'
42
- mutation 'nil'
43
42
  end
44
43
 
45
44
  Mutant::Meta::Example.add do
46
- source 'unless :condition; true; end'
47
-
48
- mutation 'unless !:condition; true; end'
49
- mutation 'unless :condition__mutant__; true; end'
50
- mutation 'unless nil; true; end'
51
- mutation 'unless :condition; false; end'
52
- mutation 'unless :condition; nil; end'
53
- mutation 'unless true; true; end'
54
- mutation 'unless false; true; end'
55
- mutation 'if :condition; true; end'
56
- mutation 'nil'
45
+ source 'unless condition; true; end'
46
+
47
+ singleton_mutations
48
+ mutation 'unless !condition; true; end'
49
+ mutation 'unless nil; true; end'
50
+ mutation 'unless true; true; end'
51
+ mutation 'unless false; true; end'
52
+ mutation 'unless condition; false; end'
53
+ mutation 'unless condition; nil; end'
54
+ mutation 'if condition; true; end'
57
55
  end
@@ -3,8 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '10'
5
5
 
6
- # generic
7
- mutation 'nil'
6
+ singleton_mutations
8
7
 
9
8
  # edge cases
10
9
  mutation '0'
data/meta/ivasgn.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '@a = true'
5
5
 
6
+ singleton_mutations
6
7
  mutation '@a__mutant__ = true'
7
8
  mutation '@a = false'
8
9
  mutation '@a = nil'
9
- mutation 'nil'
10
10
  end
data/meta/kwbegin.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'begin; true; end'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'begin; false; end'
7
8
  mutation 'begin; nil; end'
8
- mutation 'nil'
9
9
  end
data/meta/lvar.rb CHANGED
@@ -4,11 +4,13 @@ Mutant::Meta::Example.add do
4
4
  source 'a = nil; a'
5
5
 
6
6
  mutation 'a = nil; nil'
7
+ mutation 'a = nil; self'
7
8
  mutation 'a = nil'
8
9
  # TODO: fix invalid AST
9
10
  # These ASTs are not valid and should NOT be emitted
10
11
  # Mutations of lvarasgn need to be special cased to avoid this.
11
12
  mutation s(:begin, s(:lvasgn, :a__mutant__, s(:nil)), s(:lvar, :a))
12
13
  mutation s(:begin, s(:nil), s(:lvar, :a))
14
+ mutation s(:begin, s(:self), s(:lvar, :a))
13
15
  mutation s(:lvar, :a)
14
16
  end
data/meta/lvasgn.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'a = true'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'a__mutant__ = true'
7
8
  mutation 'a = false'
8
9
  mutation 'a = nil'
9
- mutation 'nil'
10
10
  end
data/meta/masgn.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'a, b = c, d'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  end
@@ -3,6 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'true if /foo/'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'false if /foo/'
7
8
  mutation 'true if //'
8
9
  mutation 'nil if /foo/'
@@ -10,5 +11,4 @@ Mutant::Meta::Example.add do
10
11
  mutation 'true if false'
11
12
  mutation 'true if nil'
12
13
  mutation 'true if /a\A/'
13
- mutation 'nil'
14
14
  end
data/meta/next.rb CHANGED
@@ -3,9 +3,9 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'next true'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'next false'
7
8
  mutation 'next nil'
8
9
  mutation 'next'
9
- mutation 'nil'
10
10
  mutation 'break true'
11
11
  end
data/meta/op_assgn.rb CHANGED
@@ -3,12 +3,14 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '@a.b += 1'
5
5
 
6
+ singleton_mutations
6
7
  mutation '@a.b += -1'
7
8
  mutation '@a.b += 2'
8
9
  mutation '@a.b += 0'
9
10
  mutation '@a.b += nil'
11
+ mutation '@a.b += self'
10
12
  mutation 'nil.b += 1'
11
- mutation 'nil'
13
+ mutation 'self.b += 1'
12
14
  # TODO: fix invalid AST
13
15
  # This should not get emitted as invalid AST with valid unparsed source
14
16
  mutation s(:op_asgn, s(:ivar, :@a), :+, s(:int, 1))
@@ -3,7 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'true or false'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation 'true'
8
8
  mutation 'false'
9
9
  mutation 'true and false'
data/meta/or_asgn.rb CHANGED
@@ -3,20 +3,22 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source 'a ||= 1'
5
5
 
6
+ singleton_mutations
6
7
  mutation 'a__mutant__ ||= 1'
7
8
  mutation 'a ||= nil'
9
+ mutation 'a ||= self'
8
10
  mutation 'a ||= 0'
9
11
  mutation 'a ||= -1'
10
12
  mutation 'a ||= 2'
11
- mutation 'nil'
12
13
  end
13
14
 
14
15
  Mutant::Meta::Example.add do
15
16
  source '@a ||= 1'
16
17
 
18
+ singleton_mutations
17
19
  mutation '@a ||= nil'
20
+ mutation '@a ||= self'
18
21
  mutation '@a ||= 0'
19
22
  mutation '@a ||= -1'
20
23
  mutation '@a ||= 2'
21
- mutation 'nil'
22
24
  end
data/meta/range.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '1..100'
5
5
 
6
- mutation 'nil'
6
+ singleton_mutations
7
7
  mutation '1...100'
8
8
  mutation '(0.0 / 0.0)..100'
9
9
  mutation '1..(1.0 / 0.0)'
@@ -12,7 +12,9 @@ Mutant::Meta::Example.add do
12
12
  mutation '0..100'
13
13
  mutation '2..100'
14
14
  mutation 'nil..100'
15
+ mutation 'self..100'
15
16
  mutation '1..nil'
17
+ mutation '1..self'
16
18
  mutation '1..0'
17
19
  mutation '1..1'
18
20
  mutation '1..99'
@@ -23,7 +25,7 @@ end
23
25
  Mutant::Meta::Example.add do
24
26
  source '1...100'
25
27
 
26
- mutation 'nil'
28
+ singleton_mutations
27
29
  mutation '1..100'
28
30
  mutation '(0.0 / 0.0)...100'
29
31
  mutation '1...(1.0 / 0.0)'
@@ -32,7 +34,9 @@ Mutant::Meta::Example.add do
32
34
  mutation '0...100'
33
35
  mutation '2...100'
34
36
  mutation 'nil...100'
37
+ mutation 'self...100'
35
38
  mutation '1...nil'
39
+ mutation '1...self'
36
40
  mutation '1...0'
37
41
  mutation '1...1'
38
42
  mutation '1...99'
data/meta/regex.rb CHANGED
@@ -3,18 +3,20 @@
3
3
  Mutant::Meta::Example.add do
4
4
  source '/foo/'
5
5
 
6
+ singleton_mutations
6
7
  mutation '//' # match all
7
8
  mutation '/a\A/' # match nothing
8
- mutation 'nil'
9
9
  end
10
10
 
11
11
  Mutant::Meta::Example.add do
12
12
  source '/#{foo.bar}n/'
13
13
 
14
+ singleton_mutations
14
15
  mutation '//' # match all
15
16
  mutation '/#{foo}n/'
16
17
  mutation '/a\A/' # match nothing
17
18
  mutation '/#{nil.bar}n/'
19
+ mutation '/#{self.bar}n/'
18
20
  mutation '/#{nil}n/'
19
- mutation 'nil'
21
+ mutation '/#{self}n/'
20
22
  end