Class: Henitai::Operators::HashLiteral

Inherits:
Henitai::Operator show all
Defined in:
lib/henitai/operators/hash_literal.rb

Overview

Reduces hash literals: empties the whole hash and removes one pair at a time. Symbol-key -> string-key mutation lives in HashKeyType (hard set) because framework key normalization makes it frequently unkillable (ADR-12).

Constant Summary collapse

NODE_TYPES =
[:hash].freeze

Constants inherited from Henitai::Operator

Henitai::Operator::FULL_SET, Henitai::Operator::HARD_SET, Henitai::Operator::LIGHT_SET, Henitai::Operator::SETS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Henitai::Operator

#build_mutant, for_set, #name, #node_location

Class Method Details

.node_typesObject



14
15
16
# File 'lib/henitai/operators/hash_literal.rb', line 14

def self.node_types
  NODE_TYPES
end

Instance Method Details

#mutate(node, subject:) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/henitai/operators/hash_literal.rb', line 18

def mutate(node, subject:)
  return [] if node.children.empty?

  mutants = [empty_hash_mutant(node, subject:)]
  mutants.concat(pair_removal_mutants(node, subject:))
  mutants
end