forked from seart-group/java-tree-sitter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaptureTest.java
38 lines (34 loc) · 1.34 KB
/
CaptureTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package ch.usi.si.seart.treesitter;
import org.junit.jupiter.api.Assertions;
import java.util.List;
class CaptureTest extends AbstractQueryTest {
@Override
protected void assertions(Node node, Query query) {
List<Capture> captures = query.getCaptures();
Capture additional = captures.get(0);
Assertions.assertTrue(additional.isEnabled());
additional.disable();
Assertions.assertFalse(additional.isEnabled());
try (QueryCursor cursor = node.walk(query)) {
for (QueryMatch match: cursor) {
Assertions.assertEquals(1, match.getNodes().size());
Assertions.assertEquals(0, match.getNodes(additional).size());
}
}
Assertions.assertFalse(additional.isEnabled());
additional.disable();
Assertions.assertFalse(additional.isEnabled());
Capture target = captures.get(1);
Assertions.assertTrue(target.isEnabled());
target.disable();
Assertions.assertFalse(target.isEnabled());
try (QueryCursor cursor = node.walk(query)) {
for (QueryMatch match: cursor) {
Assertions.assertEquals(0, match.getNodes().size());
}
}
Assertions.assertFalse(target.isEnabled());
target.disable();
Assertions.assertFalse(target.isEnabled());
}
}