Commit 4aea70ce authored by Ticxo's avatar Ticxo
Browse files

Removed test

parent 48e81e97
No related merge requests found
Pipeline #7753 failed with stages
in 1 minute and 48 seconds
package com.ticxo.test;
import com.bedrockk.molang.MoLang;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
var scanner = new Scanner(System.in);
var runtime = MoLang.createRuntime();
while(true) {
try {
String code = scanner.nextLine();
if("***".equals(code))
break;
var value = runtime.execute(MoLang.parse(code));
System.out.println(">> " + value.asString());
}catch (Throwable t) {
t.printStackTrace();
}
}
}
}
package com.bedrockk.molang;
import com.bedrockk.molang.parser.MoLangParser;
import com.bedrockk.molang.runtime.MoLangRuntime;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
@DisplayName("Evaluator Test")
public class EvaluatorTest {
private void eval(String file, double expected) throws IOException {
var parsed = MoLang.parse(getClass().getClassLoader().getResourceAsStream(file));
var runtime = MoLang.createRuntime();
var actual = runtime.execute(parsed).asDouble();
Assertions.assertEquals(Math.round(expected), Math.round(actual));
}
@Test
public void testEval3() throws IOException {
eval("expr3.txt", (213 + 2 / 0.5 + 5 + 2 * 3));
}
@Test
public void testEval4() throws IOException {
eval("expr4.txt", (213 + 2 / 0.5 + 5 + 2 * 3) + 310.5 + (10 * Math.cos(270)) + 100);
}
}
package com.bedrockk.molang;
import com.bedrockk.molang.ast.ArrayAccessExpression;
import com.bedrockk.molang.parser.MoLangParser;
import com.bedrockk.molang.ast.FuncCallExpression;
import com.bedrockk.molang.utils.FileUtils;
import com.google.gson.GsonBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@DisplayName("Expr Find Tests")
public class ExprTraverseTest {
@Test
@DisplayName("Find 1")
public void testFind() throws IOException {
var parsed = MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr2.txt"));
var found = ExprFinder.find(parsed, expression -> expression instanceof FuncCallExpression);
Assertions.assertEquals(4, found.size());
}
@Test
@DisplayName("Find 2")
public void testFind2() throws IOException {
var parsed = MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr2.txt"));
var found = ExprFinder.find(parsed, expression -> expression instanceof ArrayAccessExpression);
Assertions.assertEquals(1, found.size());
}
}
package com.bedrockk.molang;
import com.bedrockk.molang.runtime.MoParams;
import com.bedrockk.molang.runtime.value.StringValue;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.List;
@DisplayName("Generic Tests")
public class GenericTest {
@Test
@DisplayName("MoParams Test")
public void testMoParams() {
var value = new StringValue("AAAAAAAAA");
var params = new MoParams(List.of(value));
Assertions.assertEquals(value.asString(), params.getString(0));
}
}
package com.bedrockk.molang;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.*;
@DisplayName("Parse Tests")
public class ParseTest {
@Test
@DisplayName("Parse File 1")
public void parse1() throws IOException {
Assertions.assertDoesNotThrow(() -> MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr1.txt")));
}
@Test
@DisplayName("Parse File ")
public void parse2() throws IOException {
Assertions.assertDoesNotThrow(() -> MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr2.txt")));
}
@Test
@DisplayName("Parse File 3")
public void parse3() throws IOException {
Assertions.assertDoesNotThrow(() -> MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr3.txt")));
}
@Test
@DisplayName("Parse File 4")
public void parse4() throws IOException {
Assertions.assertDoesNotThrow(() -> MoLang.parse(getClass().getClassLoader().getResourceAsStream("expr4.txt")));
}
}
v.x = 1;
v.y = 1;
loop(10, {
t.x = v.x + v.y;
v.x = v.y;
v.y = t.x;
});
(v.moo > 0) ? {
v.x = math.sin(q.life_time * 45);
v.x = v.x * v.x + 17.3;
t.sin_x = math.sin(v.x);
v.x = t.sin_x * t.sin_x + v.x * v.x;
v.x = math.sqrt(v.x) * v.x * math.pi;
};
v.x = 0;
for_each(v.pig, query.get_nearby_entities(4, 'minecraft:pig'), {
v.a = v.x->v.z;
v.x = v.x + v.pig->query.get_relative_block_state(0, 1, 0, 'flammable');
});
\ No newline at end of file
v.a = query.is_sleeping ? geometry.my_sleeping_geo : array.my_geos[math.cos(query.anim_time * 12.3 + 41.9) * 10 + 0.6];
v.b = query.someffunction(v.a);
\ No newline at end of file
v.a = 213 + 2 / 0.5 + 5 + 2 * 3;
\ No newline at end of file
t.a = 213 + 2 / 0.5 + 5 + 2 * 3;
array.test.0 = 100;
array.test[1] = 200;
array.test[2] = 10.5;
for_each(v.r, array.test, {
t.a = t.a + v.r;
});
loop(10, {
t.a = this->t.a + math.cos(270);
});
return t.a + 100;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment