Package org.apache.commons.jexl2

Examples of org.apache.commons.jexl2.MethodTest$VarArgs


        final int testCount        = tests.get("count").toint();
        final LuaValue provideFunc = tests.get("provide");
        final LuaValue runFunc     = tests.get("run");

        for (int i=1; i<testCount+1; i++) {
            final Varargs provideValue = provideFunc.invoke(valueOf(i));
            final LuaValue name = provideValue.arg(2);
            final String expected = provideValue.arg(3).checkjstring();

            Description testDescription = Description.createTestDescription(getClass(), name.toString());

            if (isIgnored(testDescription)) {
                notifier.fireTestIgnored(testDescription);
View Full Code Here


      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           list.append(v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {list});
    }
View Full Code Here

      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           map.put(k, v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {map});
    }
View Full Code Here

      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           list.append(v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {list});
    }
View Full Code Here

      if (args.istable(2)) {
        LuaTable table = args.checktable(2);
        LuaValue k = LuaValue.NIL;
       
        while (true) {
           Varargs n = table.next(k);
          
           if ((k = n.arg1()).isnil())
             break;

           LuaValue v = n.arg(2);
           map.put(k, v);
         }
      }       
      return LuaValue.varargsOf(new LuaValue[] {map});
    }
View Full Code Here

  }
 
  public void testExceptionMessage() {
    String script = "local c = luajava.bindClass( \""+SomeClass.class.getName()+"\" )\n" +
        "return pcall( c.someMethod, c )";
    Varargs vresult = _G.get("loadstring").call(LuaValue.valueOf(script)).invoke(LuaValue.NONE);
    LuaValue status = vresult.arg1();
    LuaValue message = vresult.arg(2);
    assertEquals( LuaValue.FALSE, status );   
    int index = message.toString().indexOf( "this is some message" );
    assertTrue( "bad message: "+message, index>=0 );   
  }
View Full Code Here

      "      ..'-'..tostring(array[1])\n" +
      "      ..'-'..tostring(array[2])\n" +
      "      ) or '-nil')\n" +
      "  end,\n" +
      "} )\n";
    Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    if ( ! chunk.arg1().toboolean() )
      fail( chunk.arg(2).toString() );
    LuaValue result = chunk.arg1().call();
    Object u = result.touserdata();
    VarArgsInterface v = (VarArgsInterface) u;
    assertEquals( "foo", v.varargsMethod("foo") );
    assertEquals( "foo-bar", v.varargsMethod("foo", "bar") );
    assertEquals( "foo-bar-etc", v.varargsMethod("foo", "bar", "etc") );
View Full Code Here

 
      // call with arguments
      LuaValue[] vargs = new LuaValue[args.length];
      for ( int i=0; i<args.length; i++ )
        vargs[i] = LuaValue.valueOf(args[i]);
      Varargs cargs = LuaValue.varargsOf(vargs);
      Varargs v = chunk.invoke(cargs);
     
      // print the result
      for ( int i=1; i<=v.narg(); i++ )
        System.out.println("result["+i+"]: "+v.arg(i));
    } catch ( Throwable e ) {
      e.printStackTrace();
      saveClasses();
    }
  }
View Full Code Here

      "bigNumC = bigNumA:multiply(bigNumB);\n" +
      //"print(bigNumA:toString())\n" +
      //"print(bigNumB:toString())\n" +
      //"print(bigNumC:toString())\n" +
      "return bigNumA:toString(), bigNumB:toString(), bigNumC:toString()";
    Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    if ( ! chunk.arg1().toboolean() )
      fail( chunk.arg(2).toString() );
    Varargs results = chunk.arg1().invoke();
    int nresults = results.narg();
    String sa = results.tojstring(1);
    String sb = results.tojstring(2);
    String sc = results.tojstring(3);
    assertEquals( 3, nresults );
    assertEquals( "12345678901234567890", sa );
    assertEquals( "12345678901234567890", sb );
    assertEquals( "152415787532388367501905199875019052100", sc );
  }
View Full Code Here

    String script =
      "local a = luajava.newInstance('"+B.class.getName()+"');\n" +
      "local b = a:set(a:get"+typename+"())\n" +
      "local c = a:setr(a:get"+typename+"())\n" +
      "return b,c";
    Varargs chunk = _G.get("loadstring").call(LuaValue.valueOf(script));
    if ( ! chunk.arg1().toboolean() )
      fail( chunk.arg(2).toString() );
    Varargs results = chunk.arg1().invoke();
    int nresults = results.narg();
    assertEquals( 2, nresults );
    LuaValue b = results.arg(1);
    LuaValue c = results.arg(2);
    String sb = b.tojstring();
    String sc = c.tojstring();
    assertEquals( "set("+typename+") "+value, sb );
    assertEquals( "setr("+typename+") "+value, sc );
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.jexl2.MethodTest$VarArgs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.