From c65dec54fbb52738df0742bfd6195fc3be374f40 Mon Sep 17 00:00:00 2001 From: Ian Farmer Date: Sun, 15 Jul 2007 20:33:20 +0000 Subject: [PATCH] Fix a bug in how comparison instructions are handled: the 'a' intruction field was ignored. Includes new test case. --- src/main/java/lua/CallFrame.java | 2 +- src/test/java/lua/LuaJTest.java | 4 ++++ src/test/res/compare.lua | 12 ++++++++++++ src/test/res/compare.luac | Bin 0 -> 499 bytes 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/test/res/compare.lua create mode 100644 src/test/res/compare.luac diff --git a/src/main/java/lua/CallFrame.java b/src/main/java/lua/CallFrame.java index 8e6ad251..fee223e7 100644 --- a/src/main/java/lua/CallFrame.java +++ b/src/main/java/lua/CallFrame.java @@ -223,7 +223,7 @@ public class CallFrame { rkb = GETARG_RKB(i); rkc = GETARG_RKC(i); boolean test = rkc.luaBinCmpUnknown(o, rkb); - if (test) + if (test == (a == 0)) pc++; continue; } diff --git a/src/test/java/lua/LuaJTest.java b/src/test/java/lua/LuaJTest.java index dd15cc1b..c7c64529 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 testCompare() throws IOException, InterruptedException { + runTest( "compare" ); + } + public void testUpvalues() throws IOException, InterruptedException { runTest( "upvalues" ); } diff --git a/src/test/res/compare.lua b/src/test/res/compare.lua new file mode 100644 index 00000000..6840009b --- /dev/null +++ b/src/test/res/compare.lua @@ -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) diff --git a/src/test/res/compare.luac b/src/test/res/compare.luac new file mode 100644 index 0000000000000000000000000000000000000000..a4acc295fb39d1d7ebf654be7652b2190d12ced3 GIT binary patch literal 499 zcmZ{g%L;-(6o!9oEW7POgCgt&e1^$wK}3seDIq$L7fko_Xg*qJM5D!c;A8&to#713 z?$Sgz7>qF+YXJOJWMx#v{=12&9m+I)id)X5(?VJjIJLl@!*FEZ!{~Z73)MY91{??= zfBre*A0yr!@gZ9MevLoS`xbx+p^Eom!`YPDvJ!a>#wcFTM=+Pdy~yG^6?x)`kCzv< qSBWI8X#l8SFnUZn|4};zW|Vc<sXN2u_Ui!MSct#b@c_L+cXXU literal 0 HcmV?d00001