Sha256: 82b925976b05abda71aa9e87b9f5597e590b1838f074d43f31884376a216a752
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
Contents
require 'spec_helper' module Alf module Algebra describe Operator, "hash and ==" do let(:foo){ Operand::Named.new(:foo) } let(:bar){ Operand::Named.new(:bar) } let(:op1){ a_lispy.restrict(foo, x: 12) } context '==' do it 'recognizes same operands' do op1.should eq(op1) op1.should eq(a_lispy.restrict(foo, x: 12)) end it 'distinguises other operands' do op1.should_not eq(nil) op1.should_not eq(a_lispy.restrict(bar, x: 12)) op1.should_not eq(a_lispy.restrict(foo, x: 13)) end end context 'hash' do it 'it the same on same operands' do op1.hash.should eq(a_lispy.restrict(foo, x: 12).hash) end end context 'using named operands as hash keys' do let(:h){ { op1 => 1, a_lispy.restrict(bar, x: 12) => 2 } } it 'should lead to expected hash' do h.size.should eq(2) end it 'should behave as expected' do h[op1].should eq(1) h[a_lispy.restrict(bar, x: 12)].should eq(2) h[a_lispy.restrict(foo, x: 12)].should eq(1) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
alf-core-0.15.0 | spec/unit/alf-algebra/operator/test_hash_and_equal.rb |