From a464bde43b50fbaa78505967cebefdb537a3131f Mon Sep 17 00:00:00 2001 From: Octavia Togami Date: Tue, 25 Feb 2020 16:22:55 -0800 Subject: [PATCH] Fix not operator (cherry picked from commit 00c7d3a157d8d859ede501d71282e82fba40e37b) --- .../internal/expression/invoke/ExpressionHandles.java | 2 +- .../worldedit/internal/expression/ExpressionTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java index 372ef1645..892fca4fd 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/internal/expression/invoke/ExpressionHandles.java @@ -237,7 +237,7 @@ class ExpressionHandles { } private static boolean doubleToBool(double bool) { - return bool > 0; + return bool != 0; } static double boolToDouble(boolean bool) { diff --git a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java index 985d06c20..9d915ebe7 100644 --- a/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java +++ b/worldedit-core/src/test/java/com/sk89q/worldedit/internal/expression/ExpressionTest.java @@ -92,6 +92,15 @@ class ExpressionTest extends BaseExpressionTest { checkTestCase("a=0; b=--a; a+b", -2); } + @Test + void testNot() { + checkTestCase("!0", 1); + checkTestCase("!1", 0); + checkTestCase("!2", 0); + checkTestCase("!-1", 0); + checkTestCase("!-2", 0); + } + @Test public void testErrors() { // test lexer errors