TruffleRunner.ParametersFactory
public static final class TruffleRunner.ParametersFactory implements ParametersRunnerFactory- Inheritance
ObjectParametersFactory
- Implements
ParametersRunnerFactory
- Enclosing type
TruffleRunner
ParametersRunnerFactory for testing Truffle AST interpreters using Parameterized unit tests. To use the parameters for constructing the test AST, the test RootNode constructor may take the test class as single argument, or alternatively the test RootNode can be a non-static inner class of the test class.
@RunWith(Parameterized.class)
@UseParametersRunnerFactory(TruffleRunner.ParametersFactory.class)
public static class ParameterizedTest {
@Parameters(name = "{0}, {1}")
public static Collection<Object[]> data() {
ArrayList<Object[]> ret = new ArrayList<>();
ret.add(new Object[]{5, "test"});
ret.add(new Object[]{-3, "asdf"});
return ret;
}
@Parameter(0) int intParam;
@Parameter(1) String stringParam;
public class TestConstArgNode extends RootNode {
private final int iArg;
private final String sArg;
@Child InteropLibrary interop;
public TestConstArgNode() {
super(null);
this.iArg = intParam;
this.sArg = stringParam;
}
@Override
public Object execute(VirtualFrame frame) {
TruffleObject obj = (TruffleObject) frame.getArguments()[0];
try {
return interop.execute(obj, iArg, sArg);
} catch (InteropException ex) {
CompilerDirectives.transferToInterpreter();
Assert.fail(ex.getMessage());
return null;
}
}
}
@Test
public void constArg(@Inject(TestConstArgNode.class) CallTarget target) {
TruffleObject arg = prepareArgumentValue();
Object ret = target.call(arg);
Assert.assertEquals(expectedRetValue(), ret);
}
}See also
Constructors1
ParametersFactory()
ParametersFactory
since 0.25public ParametersFactory()Should not be called directly. To use this class, annotate your test class with @Parameterized.UseParametersRunnerFactory(TruffleRunner.ParametersFactory.class).
See also
Methods1
Runner createRunnerForTestWithParameters(TestWithParameters)
createRunnerForTestWithParameters
since 0.25public Runner createRunnerForTestWithParameters(TestWithParameters test) throws InitializationErrorInternal method used by the JUnit framework. Do not call directly.
Parameters
testTestWithParameters- No description.
Returns
Runner- No description.
Throws
InitializationError- No description.
Overrides createRunnerForTestWithParameters(org.junit.runners.parameterized.TestWithParameters).