diff options
| author | Marc Vertes <mvertes@free.fr> | 2023-11-04 13:22:31 +0100 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2023-11-04 13:22:31 +0100 |
| commit | 401ab3ffeb322e4c2f9a4513c9422c6b062ddc66 (patch) | |
| tree | a711b8f83c578b588f4ca5f8037f8cc5fd81914c | |
| parent | 6e2349e875e77d8af8b7d6f00f718db6813b40c1 (diff) | |
parser: add tests for logical operatators
| -rw-r--r-- | parser/interpreter_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/parser/interpreter_test.go b/parser/interpreter_test.go index a49eb96..9794337 100644 --- a/parser/interpreter_test.go +++ b/parser/interpreter_test.go @@ -62,6 +62,21 @@ func TestExpr(t *testing.T) { }) } +func TestLogical(t *testing.T) { + run(t, []etest{ + {src: "true && false", res: "false"}, + {src: "true && true", res: "true"}, + {src: "true && true && false", res: "false"}, + {src: "false || true && true", res: "true"}, + {src: "2 < 3 && 1 > 2 || 3 == 3", res: "true"}, + {src: "2 > 3 && 1 > 2 || 3 == 3", res: "true"}, + {src: "2 > 3 || 2 == 1+1 && 3>0", res: "true"}, + {src: "2 > 3 || 2 == 1+1 && 3>4 || 1<2", res: "true"}, + {src: "a := 1+1 < 3 && 4 == 2+2; a", res: "true"}, + {src: "a := 1+1 < 3 || 3 == 2+2; a", res: "true"}, + }) +} + func TestFunc(t *testing.T) { run(t, []etest{ {src: "func f() int {return 2}; a := f(); a", res: "2"}, |
