mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 15:37:52 +01:00
use AbstractBaseTest
This commit is contained in:
parent
b795215b9b
commit
39ca8a383c
@ -0,0 +1,41 @@
|
|||||||
|
package de.inetsoftware.jwebassembly.runtime;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
|
import de.inetsoftware.jwebassembly.ScriptEngine;
|
||||||
|
import de.inetsoftware.jwebassembly.WasmRule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Volker Berlin
|
||||||
|
*/
|
||||||
|
@RunWith( Parameterized.class )
|
||||||
|
public abstract class AbstractBaseTest {
|
||||||
|
|
||||||
|
private final WasmRule wasm;
|
||||||
|
|
||||||
|
private final ScriptEngine script;
|
||||||
|
|
||||||
|
private final String method;
|
||||||
|
|
||||||
|
private final Object[] params;
|
||||||
|
|
||||||
|
protected AbstractBaseTest( WasmRule wasm, ScriptEngine script, String method, Object[] params ) {
|
||||||
|
this.wasm = wasm;
|
||||||
|
this.script = script;
|
||||||
|
this.method = method;
|
||||||
|
this.params = params;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void addParam( ArrayList<Object[]> list, ScriptEngine script, String method, Object ...params ) {
|
||||||
|
list.add( new Object[]{script, method, params} );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
wasm.test( script, method, params );
|
||||||
|
}
|
||||||
|
}
|
@ -32,19 +32,13 @@ import de.inetsoftware.jwebassembly.WasmRule;
|
|||||||
* @author Volker Berlin
|
* @author Volker Berlin
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class CallFunctions {
|
public class CallFunctions extends AbstractBaseTest {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static WasmRule rule = new WasmRule( TestClass.class );
|
public static WasmRule rule = new WasmRule( TestClass.class );
|
||||||
|
|
||||||
private final ScriptEngine script;
|
|
||||||
private final String method;
|
|
||||||
private final Object[] params;
|
|
||||||
|
|
||||||
public CallFunctions( ScriptEngine script, String method, Object[] params ) {
|
public CallFunctions( ScriptEngine script, String method, Object[] params ) {
|
||||||
this.script = script;
|
super( rule, script, method, params );
|
||||||
this.method = method;
|
|
||||||
this.params = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name="{0}-{1}")
|
@Parameters(name="{0}-{1}")
|
||||||
@ -57,15 +51,6 @@ public class CallFunctions {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addParam( ArrayList<Object[]> list, ScriptEngine script, String method, Object ...params ) {
|
|
||||||
list.add( new Object[]{script, method, params} );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
rule.test( script, method, params );
|
|
||||||
}
|
|
||||||
|
|
||||||
static class TestClass {
|
static class TestClass {
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
|
@ -19,7 +19,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.junit.ClassRule;
|
import org.junit.ClassRule;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
import org.junit.runners.Parameterized.Parameters;
|
import org.junit.runners.Parameterized.Parameters;
|
||||||
@ -32,19 +31,13 @@ import de.inetsoftware.jwebassembly.WasmRule;
|
|||||||
* @author Volker Berlin
|
* @author Volker Berlin
|
||||||
*/
|
*/
|
||||||
@RunWith(Parameterized.class)
|
@RunWith(Parameterized.class)
|
||||||
public class MathOperations {
|
public class MathOperations extends AbstractBaseTest {
|
||||||
|
|
||||||
@ClassRule
|
@ClassRule
|
||||||
public static WasmRule rule = new WasmRule( TestClass.class );
|
public static WasmRule rule = new WasmRule( TestClass.class );
|
||||||
|
|
||||||
private final ScriptEngine script;
|
|
||||||
private final String method;
|
|
||||||
private final Object[] params;
|
|
||||||
|
|
||||||
public MathOperations( ScriptEngine script, String method, Object[] params ) {
|
public MathOperations( ScriptEngine script, String method, Object[] params ) {
|
||||||
this.script = script;
|
super( rule, script, method, params );
|
||||||
this.method = method;
|
|
||||||
this.params = params;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Parameters(name="{0}-{1}")
|
@Parameters(name="{0}-{1}")
|
||||||
@ -73,15 +66,6 @@ public class MathOperations {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addParam( ArrayList<Object[]> list, ScriptEngine script, String method, Object ...params ) {
|
|
||||||
list.add( new Object[]{script, method, params} );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
rule.test( script, method, params );
|
|
||||||
}
|
|
||||||
|
|
||||||
static class TestClass {
|
static class TestClass {
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
|
Loading…
x
Reference in New Issue
Block a user