Fix bytecode generation for return values that are upvalues.
This commit is contained in:
@@ -37,12 +37,13 @@ public class TestLuaJC {
|
||||
// create the script
|
||||
public static String name = "script";
|
||||
public static String script =
|
||||
"for i = 1,2 do\n" +
|
||||
" i = i + 5\n"+
|
||||
" return (function()\n"+
|
||||
" return i\n"+
|
||||
" end)()\n"+
|
||||
"end\n";
|
||||
"local a = 1\n"+
|
||||
"local b\n"+
|
||||
"function c()\n"+
|
||||
" b=5\n" +
|
||||
" return a\n"+
|
||||
"end\n"+
|
||||
"return c(),b\n";
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
System.out.println(script);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
******************************************************************************/
|
||||
package org.luaj.vm2;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.luaj.vm2.lua2java.Lua2Java;
|
||||
@@ -33,7 +32,7 @@ import org.luaj.vm2.luajc.LuaJC;
|
||||
* Results are compared for exact match with
|
||||
* the installed C-based lua environment.
|
||||
*/
|
||||
public class CompatibiltyTest {
|
||||
public class CompatibiltyTest extends TestSuite {
|
||||
|
||||
private static final String dir = "test/lua";
|
||||
|
||||
|
||||
@@ -387,5 +387,16 @@ public class FragmentsTest extends TestSuite {
|
||||
" return a()\n"+
|
||||
"end\n");
|
||||
}
|
||||
|
||||
public void testReturnUpvalue() {
|
||||
runFragment( LuaValue.varargsOf(new LuaValue[] { LuaValue.ONE, LuaValue.valueOf(5), }),
|
||||
"local a = 1\n"+
|
||||
"local b\n"+
|
||||
"function c()\n"+
|
||||
" b=5\n" +
|
||||
" return a\n"+
|
||||
"end\n"+
|
||||
"return c(),b\n" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user