mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-18 01:46:11 +00:00
Register a platform for expression tests
This commit is contained in:
parent
bb923aeb59
commit
21db86f26b
@ -127,12 +127,15 @@ public class Expression {
|
|||||||
((Variable) invokable).value = values[i];
|
((Variable) invokable).value = values[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
pushInstance();
|
|
||||||
try {
|
|
||||||
Future<Double> result = evalThread.submit(new Callable<Double>() {
|
Future<Double> result = evalThread.submit(new Callable<Double>() {
|
||||||
@Override
|
@Override
|
||||||
public Double call() throws Exception {
|
public Double call() throws Exception {
|
||||||
|
pushInstance();
|
||||||
|
try {
|
||||||
return root.getValue();
|
return root.getValue();
|
||||||
|
} finally {
|
||||||
|
popInstance();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
@ -153,9 +156,6 @@ public class Expression {
|
|||||||
result.cancel(true);
|
result.cancel(true);
|
||||||
throw new EvaluationException(-1, "Calculations exceeded time limit.");
|
throw new EvaluationException(-1, "Calculations exceeded time limit.");
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
popInstance();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void optimize() throws EvaluationException {
|
public void optimize() throws EvaluationException {
|
||||||
|
@ -24,13 +24,23 @@ import static java.lang.Math.sin;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||||
import com.sk89q.worldedit.internal.expression.lexer.LexerException;
|
import com.sk89q.worldedit.internal.expression.lexer.LexerException;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class ExpressionTest {
|
public class ExpressionTest {
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
WorldEdit.getInstance().getPlatformManager().register(new ExpressionPlatform());
|
||||||
|
WorldEdit.getInstance().getPlatformManager().handlePlatformReady(new PlatformReadyEvent());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEvaluate() throws ExpressionException {
|
public void testEvaluate() throws ExpressionException {
|
||||||
// check
|
// check
|
||||||
|
Loading…
Reference in New Issue
Block a user