use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testEmpty.
@Test
public void testEmpty() {
Source sampleSource = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 23));
Node unavailable = createNode(sampleSource.createUnavailableSection());
SourceSectionFilter filter = SourceSectionFilter.ANY;
Node sampleSection = createNode(sampleSource.createSection(2));
Assert.assertTrue(isInstrumentedNode(filter, source()));
Assert.assertTrue(isInstrumentedNode(filter, unavailable));
Assert.assertTrue(isInstrumentedNode(filter, sampleSection));
Assert.assertTrue(isInstrumentedRoot(filter, null));
Assert.assertTrue(isInstrumentedRoot(filter, unavailable));
Assert.assertTrue(isInstrumentedRoot(filter, sampleSection));
Assert.assertTrue(isInstrumented(filter, root, source()));
Assert.assertTrue(isInstrumented(filter, root, unavailable));
Assert.assertTrue(isInstrumented(filter, root, sampleSection));
Class<?> prevTag = null;
for (Class<?> tag : InstrumentationTestLanguage.TAGS) {
Assert.assertTrue(isInstrumented(filter, root, source(tag)));
Assert.assertTrue(isInstrumented(filter, root, unavailable));
Assert.assertTrue(isInstrumented(filter, root, createNode(sampleSource.createSection(0, 4), tag)));
if (prevTag != null) {
Assert.assertTrue(isInstrumented(filter, root, source(tag)));
Assert.assertTrue(isInstrumented(filter, root, unavailable));
Assert.assertTrue(isInstrumented(filter, root, createNode(sampleSource.createSection(0, 4), tag, prevTag)));
}
prevTag = tag;
}
Assert.assertNotNull(filter.toString());
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testLineIn.
@Test
public void testLineIn() {
Source sampleSource = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 23));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 1).build(), root, createNode(sampleSource.createSection(6, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(1, 2).build(), root, createNode(sampleSource.createSection(2, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(1, 1).build(), root, createNode(sampleSource.createSection(6, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(3 * LINE_LENGTH, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(3 * LINE_LENGTH - 1, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(3 * LINE_LENGTH - 2, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(0, LINE_LENGTH), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(0, LINE_LENGTH + 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(1 * LINE_LENGTH - 2, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(1 * LINE_LENGTH, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(2, 2).build(), root, createNode(sampleSource.createSection(1 * LINE_LENGTH - 2, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(1, 1).build(), root, createNode(sampleSource.createUnavailableSection())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIs(1).build(), root, createNode(sampleSource.createSection(0, LINE_LENGTH), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(IndexRange.byLength(1, 1)).build(), root, createNode(sampleSource.createSection(LINE_LENGTH, LINE_LENGTH), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineIn(IndexRange.byLength(1, 1), IndexRange.between(2, 3), IndexRange.byLength(3, 1)).build(), root, createNode(sampleSource.createSection(LINE_LENGTH, LINE_LENGTH), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineIn(IndexRange.byLength(1, 1), IndexRange.byLength(3, 1)).build(), root, createNode(sampleSource.createSection(LINE_LENGTH, LINE_LENGTH), tags())));
Assert.assertNotNull(SourceSectionFilter.newBuilder().lineIn(2, 2).build().toString());
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testLineEndsIn.
@Test
public void testLineEndsIn() {
Source sampleSource = Source.newBuilder("line1\nline2\nline3\nline4").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 23));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(6, 6))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(0, 6))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 6))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(0, 6))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(6, 6))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().lineEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(12, 6))));
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testColumnNotIn.
@Test
public void testColumnNotIn() {
Source sampleSource = Source.newBuilder("123456789\n123456789").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 19));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(1, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(0, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1)).build(), root, createNode(sampleSource.createSection(1, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(3, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(2, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(2, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 2), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 5), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(1, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(1, 5), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1)).build(), root, createNode(sampleSource.createUnavailableSection())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1)).build(), root, createNode(sampleSource.createSection(0, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1)).build(), root, createNode(sampleSource.createSection(1, 1), tags())));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1), IndexRange.between(2, 3), IndexRange.byLength(3, 1)).build(), root, createNode(sampleSource.createSection(1, 1), tags())));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnNotIn(IndexRange.byLength(1, 1), IndexRange.byLength(3, 1)).build(), root, createNode(sampleSource.createSection(1, 1), tags())));
Assert.assertNotNull(SourceSectionFilter.newBuilder().columnIn(2, 2).build().toString());
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SourceSectionFilterTest method testColumnEndsIn.
@Test
public void testColumnEndsIn() {
Source sampleSource = Source.newBuilder("123456789\n123456789").name("unknown").mimeType(InstrumentationTestLanguage.MIME_TYPE).build();
Node root = createNode(sampleSource.createSection(0, 19));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(1, 1))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(2, 1)).build(), root, createNode(sampleSource.createSection(0, 1))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(2, 2)).build(), root, createNode(sampleSource.createSection(0, 1))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(0, 1))));
Assert.assertTrue(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(1, 1))));
Assert.assertFalse(isInstrumented(SourceSectionFilter.newBuilder().columnEndsIn(IndexRange.byLength(1, 2)).build(), root, createNode(sampleSource.createSection(2, 1))));
}
Aggregations