add compatibility checks
This commit is contained in:
parent
a98a6d6d1e
commit
ebe95b83fa
2 changed files with 14 additions and 0 deletions
|
@ -12,6 +12,15 @@ module Logic
|
|||
.find { |c| c.name == name }
|
||||
end
|
||||
|
||||
def self.compatible_type?(left, right)
|
||||
case [left.type, right.type]
|
||||
in [a, ^a] # syntax for same type
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def ds_eq(left, right) = Logic::Eq.new(left, right)
|
||||
|
||||
def greater_than(left, right) = Logic::GreaterThan.new(left, right)
|
||||
|
|
|
@ -9,4 +9,9 @@ describe Logic do
|
|||
|
||||
expect(Logic.from_h(greater_than(constant(1), constant(2)).to_h)).to eq(greater_than(constant(1), constant(2)))
|
||||
end
|
||||
|
||||
describe '.compatible_type?' do
|
||||
it { expect(Logic.compatible_type?(constant(true), constant(true))).to be true }
|
||||
it { expect(Logic.compatible_type?(constant(1), constant(true))).to be false }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue