Fix not operator

(cherry picked from commit 00c7d3a157d8d859ede501d71282e82fba40e37b)
This commit is contained in:
Octavia Togami 2020-02-25 16:22:55 -08:00 committed by MattBDev
parent e20765beef
commit a464bde43b
2 changed files with 10 additions and 1 deletions

View File

@ -237,7 +237,7 @@ class ExpressionHandles {
}
private static boolean doubleToBool(double bool) {
return bool > 0;
return bool != 0;
}
static double boolToDouble(boolean bool) {

View File

@ -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