Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
tests: fix test for Kotlin grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
itsaky committed Dec 29, 2023
1 parent e09c012 commit 000f9ce
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 15 deletions.
256 changes: 255 additions & 1 deletion .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package com.itsaky.androidide.treesitter;

import static com.google.common.truth.Truth.assertThat;
import static com.itsaky.androidide.treesitter.TestUtils.readString;
import static com.itsaky.androidide.treesitter.ResourceUtils.readResource;

import android.text.TextUtils;
import com.itsaky.androidide.treesitter.aidl.TSLanguageAidl;
Expand All @@ -29,7 +29,6 @@
import com.itsaky.androidide.treesitter.python.TSLanguagePython;
import com.itsaky.androidide.treesitter.string.UTF16StringFactory;
import java.io.UnsupportedEncodingException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -46,7 +45,6 @@
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import static com.itsaky.androidide.treesitter.ResourceUtils.readResource;

@RunWith(RobolectricTestRunner.class)
public class ParserTest extends TreeSitterTest {
Expand Down Expand Up @@ -74,7 +72,7 @@ public void releaseMocks() {
}

@Test
public void testParse() {
public void testParse() {
try (TSParser parser = TSParser.create()) {
parser.setLanguage(TSLanguagePython.getInstance());
try (TSTree tree = parser.parseString("print(\"hi\")")) {
Expand Down Expand Up @@ -181,7 +179,7 @@ public void testKotlinGrammar() {
assertThat(rootNode).isNotNull();
assertThat(rootNode.getChildCount()).isGreaterThan(0);
assertThat(rootNode.getNodeString()).isEqualTo(
"(source_file (class_declaration name: (type_identifier) body: (class_body (function_declaration name: (simple_identifier) parameters: (function_value_parameters) body: (function_body (statements (call_expression (simple_identifier) (call_suffix (value_arguments (value_argument (string_literal)))))))))))");
"(source_file (class_declaration (type_identifier) (class_body (function_declaration (simple_identifier) (function_value_parameters) (function_body (statements (call_expression (simple_identifier) (call_suffix (value_arguments (value_argument (string_literal)))))))))))");
}
}
}
Expand Down Expand Up @@ -449,10 +447,7 @@ public void testParserParseCallShouldSucceedIfAnotherParseIsInProgressAndCancell

@Test
public void testParserParseCallShouldNotFailIfWhenMultipleParsersAreParsing() {
try (final var parser1 = TSParser.create();
final var parser2 = TSParser.create();
final var mainParseContent = UTF16StringFactory.newString()
) {
try (final var parser1 = TSParser.create(); final var parser2 = TSParser.create(); final var mainParseContent = UTF16StringFactory.newString()) {
parser1.setLanguage(TSLanguageJava.getInstance());
parser2.setLanguage(TSLanguageJava.getInstance());

Expand Down Expand Up @@ -579,7 +574,8 @@ public void testAwaitedCancellation() {
// request parse cancellation and wait till the parse returns
final var start = System.currentTimeMillis();
parser.requestCancellationAndWait();
System.err.println("cancelAndWait() waited for " + (System.currentTimeMillis() - start) + "ms");
System.err.println(
"cancelAndWait() waited for " + (System.currentTimeMillis() - start) + "ms");

// request another parse
try (var tree = parser.parseString(fileContent)) {
Expand Down

0 comments on commit 000f9ce

Please sign in to comment.