Skip to content

Instantly share code, notes, and snippets.

@uphy
Created January 21, 2012 02:32
Show Gist options
  • Save uphy/1650852 to your computer and use it in GitHub Desktop.
Save uphy/1650852 to your computer and use it in GitHub Desktop.
Example of prms and jmatx combination.
/**
* 関数を注入するテストを行います。
*
* @throws Exception テスト失敗
*/
@SuppressWarnings("boxing")
@Test
public void testInvocableWithInitialValue() throws Exception {
class A {
@ParameterMember
@Scriptable(initialValue = "Func void sum(Integer a,Integer b){return a+b;}")
Invocable invocable;
}
A a = new A();
final Parameterizer p = new DefaultParameterizer(new DefaultParameterFactory(new JMatxScriptEngine()));
p.parameterize(a);
final Invocable sum = a.invocable;
assertEquals(2, sum.invoke(null, 1, 1));
assertEquals(3, sum.invoke(null, 1, 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment