diff options
| author | Bobby <[email protected]> | 2024-03-01 20:13:21 +0000 |
|---|---|---|
| committer | Bobby <[email protected]> | 2024-03-01 20:15:56 +0000 |
| commit | 4a930511b3aad05682aae69cbfbf7e7273e20264 (patch) | |
| tree | 9c9d8462de4d4f36a2f7cef74b901dd1d3d1ca86 /evaluator/evaluator_test.go | |
| parent | 6022da9a279b9a95bb839de765cf5e27a4c9138b (diff) | |
| download | mana-4a930511b3aad05682aae69cbfbf7e7273e20264.tar.xz mana-4a930511b3aad05682aae69cbfbf7e7273e20264.zip | |
Infix Operator Evaluation for Boolean Comparisons
Diffstat (limited to 'evaluator/evaluator_test.go')
| -rw-r--r-- | evaluator/evaluator_test.go | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/evaluator/evaluator_test.go b/evaluator/evaluator_test.go index f0a5180..e5bc66c 100644 --- a/evaluator/evaluator_test.go +++ b/evaluator/evaluator_test.go @@ -10,7 +10,7 @@ import ( func TestEvalIntegerExpression(t *testing.T) { tests := []struct { - input string + input string expected int64 }{ {"5", 5}, @@ -38,11 +38,28 @@ func TestEvalIntegerExpression(t *testing.T) { func TestEvalBooleanExpression(t *testing.T) { tests := []struct { - input string + input string expected bool }{ {"true", true}, {"false", false}, + {"1 < 2", true}, + {"1 > 2", false}, + {"1 < 1", false}, + {"1 > 1", false}, + {"1 == 1", true}, + {"1 != 1", false}, + {"1 == 2", false}, + {"1 != 2", true}, + {"true == true", true}, + {"false == false", true}, + {"true == false", false}, + {"true != false", true}, + {"false != true", true}, + {"(1 < 2) == true", true}, + {"(1 < 2) == false", false}, + {"(1 > 2) == true", false}, + {"(1 > 2) == false", true}, } for _, tt := range tests { @@ -53,7 +70,7 @@ func TestEvalBooleanExpression(t *testing.T) { func TestBangOperator(t *testing.T) { tests := []struct { - input string + input string expected bool }{ {"!true", false}, |
