Sha256: d61125df219a1432b92d9fa9b830aa8b16880a4bcdb360a34d3c01f28b30ae49

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 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
      expect(sexp(:self).format_to_ruby).to eq('self')
    end
  end

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-3.4.0 spec/reek/ast/node_spec.rb
reek-3.3.1 spec/reek/ast/node_spec.rb