diff --git a/src/main/java/lua/CallFrame.java b/src/main/java/lua/CallFrame.java index 413d0387..90b3ace9 100644 --- a/src/main/java/lua/CallFrame.java +++ b/src/main/java/lua/CallFrame.java @@ -194,7 +194,7 @@ public class CallFrame { } case StackState.OP_NOT: { rkb = GETARG_RKB(i); - this.stack[base + a] = (rkb.luaAsBoolean() ? LBoolean.TRUE + this.stack[base + a] = (!rkb.luaAsBoolean() ? LBoolean.TRUE : LBoolean.FALSE); continue; } diff --git a/src/test/java/lua/LuaJTest.java b/src/test/java/lua/LuaJTest.java index f7740235..1f0c08dc 100644 --- a/src/test/java/lua/LuaJTest.java +++ b/src/test/java/lua/LuaJTest.java @@ -43,6 +43,10 @@ public class LuaJTest extends TestCase { runTest( "test7" ); } + public void testBoolean() throws IOException, InterruptedException { + runTest( "boolean" ); + } + public void testCompare() throws IOException, InterruptedException { runTest( "compare" ); } diff --git a/src/test/res/boolean.lua b/src/test/res/boolean.lua new file mode 100644 index 00000000..5209a69d --- /dev/null +++ b/src/test/res/boolean.lua @@ -0,0 +1,31 @@ +t = true +f = false +n = nil +s = "Hello" +z = 0 +one = 1 + +print(t) +print(f) + +print(not t) +print(not f) +print(not n) +print(not z) +print(not s) +print(not(not(t))) +print(not(not(z))) +print(not(not(n))) + +print(t and f) +print(t or f) +print(f and t) +print(f or t) + +print(f or one) +print(f or z) +print(f or n) + +print(t and one) +print(t and z) +print(t and n) diff --git a/src/test/res/boolean.luac b/src/test/res/boolean.luac new file mode 100644 index 00000000..ac742c2c Binary files /dev/null and b/src/test/res/boolean.luac differ