From 722d4371a5fbfcb5f40eaf7d48b46908d234e324 Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Sun, 8 Jun 2014 18:03:11 +0000 Subject: [PATCH] Move constants to correct file --- lib/mutant.rb | 41 ++++++++++++++++++++++++++++++++++++- lib/mutant/constants.rb | 45 ----------------------------------------- 2 files changed, 40 insertions(+), 46 deletions(-) delete mode 100644 lib/mutant/constants.rb diff --git a/lib/mutant.rb b/lib/mutant.rb index ad46d436..f451495b 100644 --- a/lib/mutant.rb +++ b/lib/mutant.rb @@ -26,6 +26,46 @@ module Mutant # The frozen empty array used within mutant EMPTY_ARRAY = [].freeze + symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze } + + SCOPE_OPERATOR = '::'.freeze + CBASE_PATTERN = /\A#{SCOPE_OPERATOR}/.freeze + + # Set of nodes that cannot be on the LHS of an assignment + NOT_ASSIGNABLE = symbolset.(%w[int float str dstr class module self nil]) + # Set of op-assign types + OP_ASSIGN = symbolset.call(%w[or_asgn and_asgn op_asgn]) + # Set of node types that are not valid when emitted standalone + NOT_STANDALONE = symbolset.(%w[splat restarg block_pass]) + INDEX_OPERATORS = symbolset.(%w[[] []=]) + UNARY_METHOD_OPERATORS = symbolset.(%w[~@ +@ -@ !]) + + # Operators ruby implementeds as methods + METHOD_OPERATORS = symbolset.(%w[ + <=> === []= [] <= >= == !~ != =~ << + >> ** * % / | ^ & < > + - ~@ +@ -@ ! + ]) + + BINARY_METHOD_OPERATORS = ( + METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS) + ).to_set.freeze + + OPERATOR_METHODS = ( + METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS + ).to_set.freeze + + # Nodes that are NOT handled by mutant. + # + # not - 1.8 only, mutant does not support 1.8 + # + NODE_BLACKLIST = symbolset.(%w[not]) + + # Nodes that are NOT generated by parser but used by mutant / unparser. + NODE_EXTRA = symbolset.(%w[empty]) + + # All node types mutant handles + NODE_TYPES = ((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze + # Lookup constant for location # # @param [String] location @@ -83,7 +123,6 @@ require 'mutant/delegator' require 'mutant/node_helpers' require 'mutant/warning_filter' require 'mutant/warning_expectation' -require 'mutant/constants' require 'mutant/walker' require 'mutant/require_highjack' require 'mutant/isolation' diff --git a/lib/mutant/constants.rb b/lib/mutant/constants.rb deleted file mode 100644 index 626245b4..00000000 --- a/lib/mutant/constants.rb +++ /dev/null @@ -1,45 +0,0 @@ -# encoding: utf-8 - -module Mutant - - symbolset = ->(strings) { strings.map(&:to_sym).to_set.freeze } - - SCOPE_OPERATOR = '::'.freeze - CBASE_PATTERN = /\A#{SCOPE_OPERATOR}/.freeze - - # Set of nodes that cannot be on the LHS of an assignment - NOT_ASSIGNABLE = symbolset.(%w[int float str dstr class module self]) - - # Set of op-assign types - OP_ASSIGN = symbolset.call(%w[or_asgn and_asgn op_asgn]) - # Set of node types that are not valid when emitted standalone - NOT_STANDALONE = symbolset.(%w[ splat restarg block_pass]) - INDEX_OPERATORS = symbolset.(%w[[] []=]) - UNARY_METHOD_OPERATORS = symbolset.(%w[~@ +@ -@ !]) - - # Operators ruby implementeds as methods - METHOD_OPERATORS = symbolset.(%w[ - <=> === []= [] <= >= == !~ != =~ << - >> ** * % / | ^ & < > + - ~@ +@ -@ ! - ]) - - BINARY_METHOD_OPERATORS = ( - METHOD_OPERATORS - (INDEX_OPERATORS + UNARY_METHOD_OPERATORS) - ).to_set.freeze - - OPERATOR_METHODS = ( - METHOD_OPERATORS + INDEX_OPERATORS + UNARY_METHOD_OPERATORS - ).to_set.freeze - - # Nodes that are NOT handled by mutant. - # - # not - 1.8 only, mutant does not support 1.8 - # - NODE_BLACKLIST = symbolset.(%w[not]) - - # Nodes that are NOT generated by parser but used by mutant / unparser. - NODE_EXTRA = symbolset.(%w[empty]) - - NODE_TYPES = ((Parser::Meta::NODE_TYPES + NODE_EXTRA) - NODE_BLACKLIST).to_set.freeze - -end # Mutant