Fix the NOT instruction. Includes test case.

This commit is contained in:
Ian Farmer
2007-07-21 04:08:28 +00:00
parent c0f054549b
commit b4ac032fd7
4 changed files with 36 additions and 1 deletions

View File

@@ -194,7 +194,7 @@ public class CallFrame {
} }
case StackState.OP_NOT: { case StackState.OP_NOT: {
rkb = GETARG_RKB(i); rkb = GETARG_RKB(i);
this.stack[base + a] = (rkb.luaAsBoolean() ? LBoolean.TRUE this.stack[base + a] = (!rkb.luaAsBoolean() ? LBoolean.TRUE
: LBoolean.FALSE); : LBoolean.FALSE);
continue; continue;
} }

View File

@@ -43,6 +43,10 @@ public class LuaJTest extends TestCase {
runTest( "test7" ); runTest( "test7" );
} }
public void testBoolean() throws IOException, InterruptedException {
runTest( "boolean" );
}
public void testCompare() throws IOException, InterruptedException { public void testCompare() throws IOException, InterruptedException {
runTest( "compare" ); runTest( "compare" );
} }

31
src/test/res/boolean.lua Normal file
View 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

Binary file not shown.