add n_ary operators
This commit is contained in:
parent
698eff0a50
commit
daaa54b6f0
9 changed files with 146 additions and 2 deletions
|
@ -8,10 +8,21 @@ describe Logic do
|
|||
expect(Logic.from_h(empty.to_h)).to eq(empty)
|
||||
|
||||
expect(Logic.from_h(greater_than(constant(1), constant(2)).to_h)).to eq(greater_than(constant(1), constant(2)))
|
||||
|
||||
expect(Logic.from_h(ds_and([constant(true), constant(true), constant(false)]).to_h))
|
||||
.to eq(ds_and([constant(true), constant(true), constant(false)]))
|
||||
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
|
||||
|
||||
describe 'priority' do
|
||||
# (false && true) || true = true
|
||||
it { expect(ds_or([ds_and([constant(false), constant(true)]), constant(true)]).compute).to be true }
|
||||
|
||||
# false && (true || true) = false
|
||||
it { expect(ds_and([constant(false), ds_or([constant(true), constant(true)])]).compute).to be false }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue