Add unit tests for varargs

This commit is contained in:
James Roseborough
2012-09-18 03:55:51 +00:00
parent 8f3f4dfb2a
commit ef94aa3abb
4 changed files with 109 additions and 84 deletions

View File

@@ -170,10 +170,10 @@ public class LuaClosure extends LuaFunction {
}
public final Varargs invoke(Varargs varargs) {
return onInvoke( varargs ).eval();
return onInvoke(varargs).eval();
}
public Varargs onInvoke(Varargs varargs) {
public final Varargs onInvoke(Varargs varargs) {
LuaValue[] stack = new LuaValue[p.maxstacksize];
for ( int i=0; i<p.numparams; i++ )
stack[i] = varargs.arg(i+1);

View File

@@ -3506,7 +3506,7 @@ public class LuaValue extends Varargs {
* <p>
* This may return a {@link TailcallVarargs} to be evaluated by the client.
* <p>
* This should not be called directly, instead use on of the call invocation functions.
* This should not be called directly, instead use one of the call invocation functions.
*
* @param args the arguments to the call invocation.
* @return Varargs the return values, possible a TailcallVarargs.

View File

@@ -623,12 +623,8 @@ public abstract class Varargs {
if (start == 1)
return this;
if (start > v.length)
return LuaValue.NONE;
if (start == v.length)
return v[v.length - 1];
if (start == v.length - 1)
return new PairVarargs(v[v.length - 2], v[v.length - 1]);
return new ArrayPartVarargs(v, start - 1, v.length - (start - 1));
return r.subargs(start - v.length);
return LuaValue.varargsOf(v, start - 1, v.length - (start - 1), r);
}
}
@@ -686,12 +682,8 @@ public abstract class Varargs {
if (start == 1)
return this;
if (start > length)
return LuaValue.NONE;
if (start == length)
return v[offset + length - 1];
if (start == length - 1)
return new PairVarargs(v[offset + length - 2], v[offset + length - 1]);
return new ArrayPartVarargs(v, offset + start - 1, length - (start - 1));
return more.subargs(start - length);
return LuaValue.varargsOf(v, offset + start - 1, length - (start - 1), more);
}
}
}