Sha256: a6d618c388ca6890cec72ad56ffdd68cfda72cd790c75147e5b7c6c4c1ef2a6d

Contents?: true

Size: 821 Bytes

Versions: 8

Compression:

Stored size: 821 Bytes

Contents

require_relative '../../spec_helper'
require_relative '../../../lib/reek/ast/node'

RSpec.describe Reek::AST::Node do
  context 'format' do
    it 'formats self' do
      @node = s(:self)
      expect(@node.format_to_ruby).to eq('self')
    end
  end

  context 'hash' do
    it 'hashes equal for equal sexps' do
      node1 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      node2 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      expect(node1.hash).to eq(node2.hash)
    end

    it 'hashes diferent for diferent sexps' do
      node1 = s(:def, :jim, s(:args), s(:send, s(:int, 4), :+, s(:send, nil, :fred)))
      node2 = s(:def, :jim, s(:args), s(:send, s(:int, 3), :+, s(:send, nil, :fred)))
      expect(node1.hash).not_to eq(node2.hash)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
reek-3.2.1 spec/reek/ast/node_spec.rb
reek-3.2 spec/reek/ast/node_spec.rb
reek-3.1 spec/reek/ast/node_spec.rb
reek-3.0.4 spec/reek/ast/node_spec.rb
reek-3.0.3 spec/reek/ast/node_spec.rb
reek-3.0.2 spec/reek/ast/node_spec.rb
reek-3.0.1 spec/reek/ast/node_spec.rb
reek-3.0.0 spec/reek/ast/node_spec.rb