Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Ticxo
MoLang
Commits
4aea70ce
Commit
4aea70ce
authored
2 years ago
by
Ticxo
Browse files
Options
Download
Email Patches
Plain Diff
Removed test
parent
48e81e97
master
No related merge requests found
Pipeline
#7753
failed with stages
in 1 minute and 48 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
0 additions
and
190 deletions
+0
-190
src/main/java/com/ticxo/test/Main.java
src/main/java/com/ticxo/test/Main.java
+0
-25
src/test/java/com/bedrockk/molang/EvaluatorTest.java
src/test/java/com/bedrockk/molang/EvaluatorTest.java
+0
-33
src/test/java/com/bedrockk/molang/ExprTraverseTest.java
src/test/java/com/bedrockk/molang/ExprTraverseTest.java
+0
-36
src/test/java/com/bedrockk/molang/GenericTest.java
src/test/java/com/bedrockk/molang/GenericTest.java
+0
-21
src/test/java/com/bedrockk/molang/ParseTest.java
src/test/java/com/bedrockk/molang/ParseTest.java
+0
-35
src/test/resources/expr1.txt
src/test/resources/expr1.txt
+0
-22
src/test/resources/expr2.txt
src/test/resources/expr2.txt
+0
-2
src/test/resources/expr3.txt
src/test/resources/expr3.txt
+0
-1
src/test/resources/expr4.txt
src/test/resources/expr4.txt
+0
-15
No files found.
src/main/java/com/ticxo/test/Main.java
deleted
100644 → 0
View file @
48e81e97
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
();
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/com/bedrockk/molang/EvaluatorTest.java
deleted
100644 → 0
View file @
48e81e97
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
);
}
}
This diff is collapsed.
Click to expand it.
src/test/java/com/bedrockk/molang/ExprTraverseTest.java
deleted
100644 → 0
View file @
48e81e97
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
());
}
}
This diff is collapsed.
Click to expand it.
src/test/java/com/bedrockk/molang/GenericTest.java
deleted
100644 → 0
View file @
48e81e97
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
));
}
}
This diff is collapsed.
Click to expand it.
src/test/java/com/bedrockk/molang/ParseTest.java
deleted
100644 → 0
View file @
48e81e97
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"
)));
}
}
This diff is collapsed.
Click to expand it.
src/test/resources/expr1.txt
deleted
100644 → 0
View file @
48e81e97
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
This diff is collapsed.
Click to expand it.
src/test/resources/expr2.txt
deleted
100644 → 0
View file @
48e81e97
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
This diff is collapsed.
Click to expand it.
src/test/resources/expr3.txt
deleted
100644 → 0
View file @
48e81e97
v.a = 213 + 2 / 0.5 + 5 + 2 * 3;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/test/resources/expr4.txt
deleted
100644 → 0
View file @
48e81e97
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
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment