mutant 0.3.0.rc4 → 0.3.0.rc5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87d33982459e4caf9811b385e18475535904176c
4
- data.tar.gz: 3c92be157bed88329abe5dcd26969aa6f8d0b112
3
+ metadata.gz: 93fb22e9e2e3e14dc8a4801c5bb1258307f2a45d
4
+ data.tar.gz: e3777ec7be30e6e2ba7623ba884962d79f2ed3f8
5
5
  SHA512:
6
- metadata.gz: eefc160831c193a9c6cc08b76b1272421dde563bd4a0d6702c5030c0939a007b8b3661a390bad70183ec950bfb97d0b0605b01ee6669cabbdccbb4c993c120af
7
- data.tar.gz: 65fb0f377537f48b934cd5be1838f9ef657cba877f34180ba28033d7f2a702ffaf27caf53cb1238ba704193268c722e363b21353613d592cf61620b8451f443f
6
+ metadata.gz: 7ac0e6884996342e298c117bded83b14949bf4eb68b8dcf58ee436dafee7dcd44ef76c916d7a551b3ea92ae75105ee79909cd6a4a1d1a94775a4f6093912f1bb
7
+ data.tar.gz: 8e819ec82cf6305e3bf5124bae1b9f7363d06e1ca6d3c05bb7dacef7c044f69ea557ffe48c767c5b9550730f3501d30ee487aa0e4490dfc7ae1506ab92dc909b
@@ -2,18 +2,12 @@
2
2
 
3
3
  module Mutant
4
4
 
5
- METHOD_POSTFIX_EXPANSIONS = {
6
- '?' => '_predicate',
7
- '=' => '_writer',
8
- '!' => '_bang'
9
- }.freeze
10
-
11
- # Set of not assignable nodes
5
+ # Set of nodes that cannot be on the LHS of an assignment
12
6
  NOT_ASSIGNABLE = [
13
7
  :int, :float, :str, :dstr, :class, :module, :self
14
8
  ].to_set.freeze
15
9
 
16
- # Set of op assign types
10
+ # Set of op-assign types
17
11
  OP_ASSIGN = [
18
12
  :or_asgn, :and_asgn, :op_asgn
19
13
  ].to_set.freeze
@@ -21,50 +15,30 @@ module Mutant
21
15
  # Set of node types that are not valid when emitted standalone
22
16
  NOT_STANDALONE = [:splat, :restarg, :block_pass].to_set.freeze
23
17
 
24
- OPERATOR_EXPANSIONS = {
25
- :<=> => :spaceship_operator,
26
- :=== => :case_equality_operator,
27
- :[]= => :element_writer,
28
- :[] => :element_reader,
29
- :<= => :less_than_or_equal_to_operator,
30
- :>= => :greater_than_or_equal_to_operator,
31
- :== => :equality_operator,
32
- :'!~' => :nomatch_operator,
33
- :'!=' => :inequality_operator,
34
- :=~ => :match_operator,
35
- :<< => :left_shift_operator,
36
- :>> => :right_shift_operator,
37
- :** => :exponentation_operator,
38
- :* => :multiplication_operator,
39
- :% => :modulo_operator,
40
- :/ => :division_operator,
41
- :| => :bitwise_or_operator,
42
- :^ => :bitwise_xor_operator,
43
- :& => :bitwise_and_operator,
44
- :< => :less_than_operator,
45
- :> => :greater_than_operator,
46
- :+ => :addition_operator,
47
- :- => :substraction_operator,
48
- :~@ => :unary_match_operator,
49
- :+@ => :unary_addition_operator,
50
- :-@ => :unary_substraction_operator,
51
- :'!' => :negation_operator
52
- }.freeze
18
+ # Operators ruby implementeds as methods
19
+ METHOD_OPERATORS = %w(
20
+ <=> === []= [] <= >= == !~ != =~ <<
21
+ >> ** * % / | ^ & < > + - ~@ +@ -@ !
22
+ ).map(&:to_sym).to_set.freeze
53
23
 
54
- INDEX_OPERATORS = [:[], :[]=].freeze
24
+ INDEX_OPERATORS = [:[], :[]=].to_set.freeze
55
25
 
56
- UNARY_METHOD_OPERATORS = [
57
- :~@, :+@, :-@, :'!'
58
- ].freeze
26
+ UNARY_METHOD_OPERATORS = %w(
27
+ ~@ +@ -@ !
28
+ ).map(&:to_sym).to_set.freeze
59
29
 
60
30
  BINARY_METHOD_OPERATORS = (
61
- OPERATOR_EXPANSIONS.keys - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
31
+ METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS)
62
32
  ).to_set.freeze
63
33
 
64
- OPERATOR_METHODS =
65
- OPERATOR_EXPANSIONS.keys + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
34
+ OPERATOR_METHODS = (
35
+ METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS
36
+ ).to_set.freeze
66
37
 
67
- # Hopefully all types parser does generate
38
+ # Hopefully all node types parser does generate.
39
+ #
40
+ # FIXME: Maintain this list only in unparser / parser!
41
+ #
68
42
  NODE_TYPES = [
69
43
  :lvasgn, :ivasgn, :cvasgn, :gvasgn,
70
44
  :casgn, :masgn, :mlhs, :break, :rescue,
@@ -19,7 +19,7 @@ module Mutant
19
19
  def dispatch
20
20
  children.each_index do |index|
21
21
  mutate_child(index)
22
- delete_child(index)
22
+ delete_child(index) unless children.one?
23
23
  end
24
24
  end
25
25
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mutant
4
4
  # The current mutant version
5
- VERSION = '0.3.0.rc4'.freeze
5
+ VERSION = '0.3.0.rc5'.freeze
6
6
  end # Mutant
@@ -70,4 +70,26 @@ describe Mutant::Mutator, 'block' do
70
70
 
71
71
  it_should_behave_like 'a mutator'
72
72
  end
73
+
74
+ context 'with mini block pattern arg' do
75
+
76
+ before do
77
+ Mutant::Random.stub(hex_string: 'random')
78
+ end
79
+
80
+ let(:source) { 'foo { |(a)| }' }
81
+
82
+ let(:mutations) do
83
+ mutations = []
84
+ mutations << 'foo { || }'
85
+ mutations << 'foo { |a| }'
86
+ mutations << 'foo { |(a)| raise }'
87
+ mutations << 'foo { |(srandom)| }'
88
+ mutations << 'foo'
89
+ mutations << 'nil'
90
+ end
91
+
92
+ it_should_behave_like 'a mutator'
93
+
94
+ end
73
95
  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.rc4
4
+ version: 0.3.0.rc5
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-12-04 00:00:00.000000000 Z
11
+ date: 2013-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser