mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-04 23:06:05 +00:00
fix ParserTest
This commit is contained in:
@@ -8,12 +8,15 @@
|
||||
package structure;
|
||||
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.lang.Executable;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.dfsek.terra.addons.terrascript.parser.Parser;
|
||||
import com.dfsek.terra.addons.terrascript.parser.exceptions.ParseException;
|
||||
@@ -29,7 +32,7 @@ import com.dfsek.terra.addons.terrascript.tokenizer.Position;
|
||||
public class ParserTest {
|
||||
@Test
|
||||
public void parse() throws IOException, ParseException {
|
||||
Parser parser = new Parser(IOUtils.toString(getClass().getResourceAsStream("/test.tesf"), Charset.defaultCharset()));
|
||||
Parser parser = new Parser(IOUtils.toString(Objects.requireNonNull(getClass().getResourceAsStream("/test.tesf")), Charset.defaultCharset()));
|
||||
|
||||
parser.registerFunction("test", new FunctionBuilder<Test1>() {
|
||||
@Override
|
||||
@@ -54,13 +57,13 @@ public class ParserTest {
|
||||
});
|
||||
|
||||
long l = System.nanoTime();
|
||||
Block block = parser.parse();
|
||||
Executable block = parser.parse();
|
||||
long t = System.nanoTime() - l;
|
||||
System.out.println("Took " + (double) t / 1000000);
|
||||
|
||||
block.apply(null, new Scope());
|
||||
block.execute(null);
|
||||
|
||||
block.apply(null, new Scope());
|
||||
block.execute(null);
|
||||
}
|
||||
|
||||
private static class Test1 implements Function<Void> {
|
||||
|
||||
Reference in New Issue
Block a user