Search in sources :

Example 1 with TckInstrument

use of com.oracle.truffle.tck.impl.TckInstrument in project graal by oracle.

the class TruffleTCK method testValueWithSource.

/**
 * @since 0.22
 */
@Test
public void testValueWithSource() throws Exception {
    String id = valueWithSource();
    if (id == null) {
        return;
    }
    PolyglotEngine.Value valueFunction = findGlobalSymbol(id);
    SourceSection sourceLocation;
    PolyglotRuntime.Instrument instr = vm().getRuntime().getInstruments().get(TckInstrument.ID);
    instr.setEnabled(true);
    try {
        PolyglotEngine.Value value = valueFunction.execute();
        TckInstrument tckInstrument = instr.lookup(TckInstrument.class);
        assertNotNull(tckInstrument);
        TruffleInstrument.Env env = tckInstrument.getEnvironment();
        assertNotNull(env);
        sourceLocation = value.getSourceLocation();
        assertNotNull(sourceLocation);
        List<SourceSection> lss = env.getInstrumenter().querySourceSections(SourceSectionFilter.ANY);
        assertTrue("Source section not among loaded sections", lss.contains(sourceLocation));
    } finally {
        instr.setEnabled(false);
    }
}
Also used : TruffleInstrument(com.oracle.truffle.api.instrumentation.TruffleInstrument) TckInstrument(com.oracle.truffle.tck.impl.TckInstrument) SourceSection(com.oracle.truffle.api.source.SourceSection) Test(org.junit.Test)

Aggregations

TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)1 SourceSection (com.oracle.truffle.api.source.SourceSection)1 TckInstrument (com.oracle.truffle.tck.impl.TckInstrument)1 Test (org.junit.Test)1