Skip to content

Commit

Permalink
Add more string tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FxMorin committed Dec 18, 2023
1 parent 5bd22ba commit 7fa7a95
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/java/com/eliotlash/molang/FunctionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ void testMiscFunctions() throws Exception {
assertEquals(1.0, evaluate("string.equals('minecraft:cow', 'minecraft:cow')"));
assertEquals(0.0, evaluate("string.equals('COW', 'cow')"));
assertEquals(1.0, evaluate("string.equalsIgnoreCase('COW', 'cow')"));

assertEquals(13, evaluate("string.length('minecraft:cow')"));
assertEquals(0.0, evaluate("string.length('')"));
assertEquals(10.0, evaluate("'I am nothing' + 10"));

assertEquals(1.0, evaluate("system.print('\"1+1-1/1*1->([{9+1}]);\"')"));
assertEquals(1.0, evaluate("system.print('test')"));
assertEquals(1.0, evaluate("system.print('oh no' + 'math is hard')"));
}

private double evaluate(String expression) throws Exception {
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/eliotlash/molang/ast/EvaluatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,5 +271,6 @@ void stringEqualityTest() {
assertEquals(1.0, eval.evaluate(parseE("'minecraft:pig' != 'minecraft:cow'")));
assertEquals(0.0, eval.evaluate(parseE("'minecraft:pig' == 'minecraft:cow'")));
assertEquals(1.0, eval.evaluate(parseE("'minecraft:pig' != ''")));
assertEquals(1.0, eval.evaluate(parseE("'' == ''")));
}
}

0 comments on commit 7fa7a95

Please sign in to comment.