diff --git a/programs/tests/fixtures/operators/booleans.rock b/programs/tests/fixtures/operators/booleans.rock index c0bd9d1..791a97f 100644 --- a/programs/tests/fixtures/operators/booleans.rock +++ b/programs/tests/fixtures/operators/booleans.rock @@ -7,15 +7,22 @@ say not X (false) say not X and not Y (false) say not X or not Y (true) say not X and not Y and not X or not Y (true) - - +shout "-----------" shout 0 or 42 shout 0 or 0 -shout 16 and 42 -shout 16 and 0 shout 16 or 42 shout 16 or 0 shout 0 and 42 shout 0 and 0 - +shout 16 and 42 +shout 16 and 0 +shout "-----------" +shout true and true +shout true and false +shout false and true +shout false and false +shout true or true +shout true or false +shout false or true +shout false or false diff --git a/programs/tests/fixtures/operators/booleans.rock.out b/programs/tests/fixtures/operators/booleans.rock.out index 059da03..378f5eb 100644 --- a/programs/tests/fixtures/operators/booleans.rock.out +++ b/programs/tests/fixtures/operators/booleans.rock.out @@ -5,11 +5,21 @@ false false true true +----------- +42 0 -0 -16 -16 16 16 0 0 +42 +0 +----------- +true +false +false +false +true +true +true +false diff --git a/rocky.jar b/rocky.jar index e8f96d9..44f610f 100644 Binary files a/rocky.jar and b/rocky.jar differ diff --git a/src/rockstar/expression/LogicalExpression.java b/src/rockstar/expression/LogicalExpression.java index c730f1c..db2355d 100644 --- a/src/rockstar/expression/LogicalExpression.java +++ b/src/rockstar/expression/LogicalExpression.java @@ -55,14 +55,15 @@ public Value evaluate(BlockContext ctx) { // short circuit: do not evaluate expr2 if not needed switch (type) { case AND: - if (v1.isBoolean() && v1.asBoolean().equals(Value.BOOLEAN_TRUE)) { - return ctx.afterExpression(this, v1.and(expr2.evaluate(ctx))); + if (/*v1.isBoolean() &&*/ v1.asBoolean().equals(Value.BOOLEAN_TRUE)) { +// return ctx.afterExpression(this, v1.and(expr2.evaluate(ctx))); + return ctx.afterExpression(this, expr2.evaluate(ctx)); } return ctx.afterExpression(this, v1); case OR: - if (v1.isBoolean() && v1.asBoolean().equals(Value.BOOLEAN_FALSE)) { - return ctx.afterExpression(this, v1.or(expr2.evaluate(ctx))); - } + if (/*v1.isBoolean() &&*/ v1.asBoolean().equals(Value.BOOLEAN_FALSE)) { +// return ctx.afterExpression(this, v1.or(expr2.evaluate(ctx))); + return ctx.afterExpression(this, expr2.evaluate(ctx)); } return ctx.afterExpression(this, v1); case NOR: if (v1.isBoolean() && v1.asBoolean().equals(Value.BOOLEAN_FALSE)) {