mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-15 02:44:47 +01:00
Add a test with enabled GC
This commit is contained in:
parent
6ea1955886
commit
c029c48be5
@ -27,6 +27,7 @@ public enum ScriptEngine {
|
||||
NodeWat,
|
||||
SpiderMonkeyWat,
|
||||
Wat2Wasm,
|
||||
SpiderMonkeyGC,
|
||||
;
|
||||
|
||||
public static ScriptEngine[] testEngines() {
|
||||
|
@ -68,6 +68,8 @@ public class WasmRule extends TemporaryFolder {
|
||||
|
||||
private File spiderMonkeyScript;
|
||||
|
||||
private File spiderMonkeyScriptGC;
|
||||
|
||||
private File nodeWatScript;
|
||||
|
||||
private File spiderMonkeyWatScript;
|
||||
@ -130,7 +132,7 @@ public class WasmRule extends TemporaryFolder {
|
||||
*/
|
||||
private void writeJsonTestData( Map<String, Object[]> data ) throws IOException {
|
||||
// a character we need to convert an integer
|
||||
HashMap<String, Object[]> copy = new HashMap( data );
|
||||
HashMap<String, Object[]> copy = new HashMap<>( data );
|
||||
for( Entry<String, Object[]> entry : copy.entrySet() ) {
|
||||
Object[] params = entry.getValue();
|
||||
for( int i = 0; i < params.length; i++ ) {
|
||||
@ -395,10 +397,13 @@ public class WasmRule extends TemporaryFolder {
|
||||
|
||||
switch( script ) {
|
||||
case SpiderMonkey:
|
||||
processBuilder = spiderMonkeyCommand( true );
|
||||
processBuilder = spiderMonkeyCommand( true, false );
|
||||
break;
|
||||
case SpiderMonkeyWat:
|
||||
processBuilder = spiderMonkeyCommand( false );
|
||||
processBuilder = spiderMonkeyCommand( false, false );
|
||||
break;
|
||||
case SpiderMonkeyGC:
|
||||
processBuilder = spiderMonkeyCommand( true, true );
|
||||
break;
|
||||
case NodeJS:
|
||||
processBuilder = nodeJsCommand( nodeScript );
|
||||
@ -455,15 +460,25 @@ public class WasmRule extends TemporaryFolder {
|
||||
* Create a ProcessBuilder for spider monkey script shell.
|
||||
*
|
||||
* @param binary true, if the WASM format should be test; false, if the WAT format should be tested.
|
||||
* @param gc true, if with gc should be test
|
||||
* @return the value from the script
|
||||
* @throws IOException
|
||||
* if the download failed
|
||||
*/
|
||||
private ProcessBuilder spiderMonkeyCommand( boolean binary ) throws IOException {
|
||||
private ProcessBuilder spiderMonkeyCommand( boolean binary, boolean gc ) throws IOException {
|
||||
File script;
|
||||
try {
|
||||
System.setProperty( "SpiderMonkey", "true" );
|
||||
if( binary ) {
|
||||
if( gc ) {
|
||||
if( spiderMonkeyScriptGC == null ) {
|
||||
File file = newFile( "spiderMonkeyGC.wasm" );
|
||||
compiler.setProperty( JWebAssembly.WASM_USE_GC, "true" );
|
||||
compiler.compileToBinary( file );
|
||||
spiderMonkeyScriptGC = createScript( "SpiderMonkeyTest.js", "{test.wasm}", file.getName() );
|
||||
}
|
||||
script = spiderMonkeyScriptGC;
|
||||
|
||||
} else if( binary ) {
|
||||
if( spiderMonkeyScript == null ) {
|
||||
File file = newFile( "spiderMonkey.wasm" );
|
||||
compiler.compileToBinary( file );
|
||||
@ -479,9 +494,10 @@ public class WasmRule extends TemporaryFolder {
|
||||
script = spiderMonkeyWatScript;
|
||||
}
|
||||
} finally {
|
||||
compiler.setProperty( JWebAssembly.WASM_USE_GC, null );
|
||||
System.clearProperty( "SpiderMonkey" );
|
||||
}
|
||||
return new ProcessBuilder( spiderMonkey.getCommand(), "--wasm-gc", script.getAbsolutePath() );
|
||||
return new ProcessBuilder( spiderMonkey.getCommand(), "--wasm-gc", /*"--wasm-bigint",*/ script.getAbsolutePath() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
package de.inetsoftware.jwebassembly.runtime;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Assume;
|
||||
@ -28,19 +29,23 @@ import de.inetsoftware.jwebassembly.ScriptEngine;
|
||||
import de.inetsoftware.jwebassembly.WasmRule;
|
||||
import de.inetsoftware.jwebassembly.api.annotation.Export;
|
||||
|
||||
public class Arrays extends AbstractBaseTest {
|
||||
public class ArrayOperations extends AbstractBaseTest {
|
||||
|
||||
@ClassRule
|
||||
public static WasmRule rule = new WasmRule( TestClass.class );
|
||||
|
||||
public Arrays( ScriptEngine script, String method, Object[] params ) {
|
||||
public ArrayOperations( ScriptEngine script, String method, Object[] params ) {
|
||||
super( rule, script, method, params );
|
||||
}
|
||||
|
||||
@Parameters( name = "{0}-{1}" )
|
||||
public static Collection<Object[]> data() {
|
||||
ArrayList<Object[]> list = new ArrayList<>();
|
||||
for( ScriptEngine script : ScriptEngine.testEngines() ) {
|
||||
|
||||
ScriptEngine[] engines = ScriptEngine.testEngines();
|
||||
engines = Arrays.copyOf( engines, engines.length + 1 );
|
||||
engines[engines.length - 1] = ScriptEngine.SpiderMonkeyGC;
|
||||
for( ScriptEngine script : engines ) {
|
||||
addParam( list, script, "length" );
|
||||
addParam( list, script, "loopByte" );
|
||||
addParam( list, script, "loopShort" );
|
||||
@ -58,7 +63,7 @@ public class Arrays extends AbstractBaseTest {
|
||||
@Test
|
||||
@Override
|
||||
public void test() {
|
||||
Assume.assumeFalse( (getScriptEngine() == ScriptEngine.SpiderMonkeyWat || getScriptEngine() == ScriptEngine.SpiderMonkey)
|
||||
Assume.assumeFalse( (getScriptEngine().name().startsWith( "SpiderMonkey" ) )
|
||||
&& "loopLong".equals( getMethod() ) ); // TODO SpiderMonkey https://bugzilla.mozilla.org/show_bug.cgi?id=1511958
|
||||
super.test();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user