-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9fba601
commit 82a1ed2
Showing
8 changed files
with
97 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
## [Unreleased] | ||
|
||
## [0.1.0] - 2024-03-23 | ||
## [0.1.0] - 2024-03-XX | ||
- Initial release |
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
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,13 @@ | ||
require 'delegate' | ||
|
||
module Expressive | ||
class Evaluator < SimpleDelegator | ||
def and(other) | ||
__getobj__ && other.__getobj__ | ||
end | ||
|
||
def or(other) | ||
__getobj__ || other.__getobj__ | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class TestLogicalMethods < Minitest::Test | ||
def setup | ||
@env = Expressive::Environment.new( | ||
"variable_true" => true, | ||
"variable_false" => false | ||
) | ||
end | ||
|
||
def test_logical_and | ||
expression = Expressive::Expression.new( | ||
:and, | ||
Expressive::Variable.new("variable_true"), | ||
Expressive::Variable.new("variable_false") | ||
) | ||
|
||
assert_equal(false, @env.evaluate(expression)) | ||
end | ||
|
||
def test_logical_or | ||
expression = Expressive::Expression.new( | ||
:or, | ||
Expressive::Variable.new("variable_true"), | ||
Expressive::Variable.new("variable_false") | ||
) | ||
|
||
assert(@env.evaluate(expression)) | ||
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