Fix the NOT instruction. Includes test case.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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" );
|
||||
}
|
||||
|
||||
31
src/test/res/boolean.lua
Normal file
31
src/test/res/boolean.lua
Normal file
@@ -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)
|
||||
BIN
src/test/res/boolean.luac
Normal file
BIN
src/test/res/boolean.luac
Normal file
Binary file not shown.
Reference in New Issue
Block a user