Skip to content

Commit

Permalink
Add more binary operators that are emitted without dot syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Schirp committed Nov 21, 2012
1 parent 8607a69 commit e3d4f14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/to_source/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ def return(node)
# @api private
#
def process_binary_operator(node)
operators = %w(+ - * / & | <<).map(&:to_sym)
operators = %w(+ - * / & | << == != =~ !~ > < ** ^).map(&:to_sym)
return false unless operators.include?(node.name)
return false if node.arguments.array.length != 1

Expand Down
8 changes: 6 additions & 2 deletions spec/unit/to_source/visitor/class_methods/run_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -508,10 +508,14 @@ def foo
end

context 'binary operators' do
%w(+ - * / & | && || <<).each do |operator|
context "operator: #{operator}" do
%w(+ - * / & | && || << == != < > =~ !~ ^ **).each do |operator|
context "operator on literals #{operator}" do
assert_source "1 #{operator} 2"
end

# context "operator on calls #{operator}" do
# assert_source "a #{operator} b"
# end
end
end

Expand Down

0 comments on commit e3d4f14

Please sign in to comment.