Fix a bug in how comparison instructions are handled: the 'a' intruction field

was ignored.  Includes new test case.
This commit is contained in:
Ian Farmer
2007-07-15 20:33:20 +00:00
parent ba3da1ca2c
commit c65dec54fb
4 changed files with 17 additions and 1 deletions

View File

@@ -223,7 +223,7 @@ public class CallFrame {
rkb = GETARG_RKB(i); rkb = GETARG_RKB(i);
rkc = GETARG_RKC(i); rkc = GETARG_RKC(i);
boolean test = rkc.luaBinCmpUnknown(o, rkb); boolean test = rkc.luaBinCmpUnknown(o, rkb);
if (test) if (test == (a == 0))
pc++; pc++;
continue; continue;
} }

View File

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

12
src/test/res/compare.lua Normal file
View File

@@ -0,0 +1,12 @@
if 2 < 5 then
print("OK!")
else
print("Something is not right")
end
print(2 < 5)
print(2 <= 5)
print(2 == 5)
print(2 ~= 5)
print(2 > 5)
print(2 >= 5)

BIN
src/test/res/compare.luac Normal file

Binary file not shown.