Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
module Wongi::Engine | ||
class LessThanOrEqualTest < FilterTest | ||
attr_reader :x, :y | ||
|
||
def initialize(x, y) | ||
@x = x | ||
@y = y | ||
end | ||
|
||
def passes?(token) | ||
x = if Template.variable? @x | ||
token[@x] | ||
else | ||
@x | ||
end | ||
|
||
y = if Template.variable? @y | ||
token[@y] | ||
else | ||
@y | ||
end | ||
|
||
return false if x == :_ || y == :_ | ||
x <= y | ||
end | ||
|
||
def ==(other) | ||
super && x == other.x && y == other.y | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Less Than Or Equal test' do | ||
before :each do | ||
@engine = Wongi::Engine.create | ||
end | ||
|
||
attr_reader :engine | ||
|
||
attr_reader :production | ||
|
||
def test_rule(&block) | ||
@production = (engine << rule('test-rule', &block)) | ||
end | ||
|
||
it 'should interact with optional node correctly' do | ||
# before the fix, filters would try to piggy-back on optional templates | ||
|
||
test_rule do | ||
forall do | ||
has :Number, :assign_check, :_ | ||
lte :Number, 6 | ||
end | ||
end | ||
|
||
engine << [5, :assign_check, nil] | ||
engine << [6, :assign_check, nil] | ||
engine << [7, :assign_check, nil] #should not pass | ||
expect(@production.size).to eq(2) | ||
end | ||
end |