Search in sources :

Example 6 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class AssumptionsTest method testMultipleAssumptionArrays.

@Test
public void testMultipleAssumptionArrays() {
    CallTarget root = createCallTarget(MultipleAssumptionArraysTestFactory.getInstance());
    MultipleAssumptionArraysTest node = getNode(root);
    Assumption a1 = Truffle.getRuntime().createAssumption();
    Assumption a2 = Truffle.getRuntime().createAssumption();
    node.assumptions1 = new Assumption[] { a1 };
    node.assumptions2 = new Assumption[] { a2 };
    assertEquals("do1", root.call(42));
    a2.invalidate();
    assertEquals("do2", root.call(42));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Assumption(com.oracle.truffle.api.Assumption) Test(org.junit.Test)

Example 7 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class AssumptionsTest method testField.

@Test
public void testField() {
    CallTarget root = createCallTarget(FieldTestFactory.getInstance());
    FieldTest node = getNode(root);
    assertEquals(42, root.call(42));
    assertEquals(42, root.call(42));
    node.field.invalidate();
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Example 8 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class CachedTest method testCachesOrder2.

@Test
public void testCachesOrder2() {
    CallTarget root = createCallTarget(TestCachesOrder2Factory.getInstance());
    assertEquals(42, root.call(21));
    assertEquals(44, root.call(22));
    assertEquals(46, root.call(23));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 9 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class CachedTest method testCacheField.

@Test
public void testCacheField() {
    CallTarget root = createCallTarget(TestCacheFieldFactory.getInstance());
    assertEquals(3, root.call(42));
    assertEquals(3, root.call(43));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 10 with CallTarget

use of com.oracle.truffle.api.CallTarget in project graal by oracle.

the class CachedTest method testBoundCache.

@Test
public void testBoundCache() {
    CallTarget root = createCallTarget(BoundCacheFactory.getInstance());
    assertEquals(42, root.call(42));
    assertEquals(43, root.call(43));
    assertEquals(44, root.call(44));
    try {
        root.call(45);
        fail();
    } catch (UnsupportedSpecializationException e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) UnsupportedSpecializationException(com.oracle.truffle.api.dsl.UnsupportedSpecializationException) Test(org.junit.Test)

Aggregations

CallTarget (com.oracle.truffle.api.CallTarget)128 Test (org.junit.Test)102 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)50 RootCallTarget (com.oracle.truffle.api.RootCallTarget)26 RootNode (com.oracle.truffle.api.nodes.RootNode)17 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)15 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)10 UnsupportedSpecializationException (com.oracle.truffle.api.dsl.UnsupportedSpecializationException)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 Node (com.oracle.truffle.api.nodes.Node)9 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)9 TruffleContext (com.oracle.truffle.api.TruffleContext)6 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)6 Context (org.graalvm.polyglot.Context)6 Theory (org.junit.experimental.theories.Theory)6 TruffleException (com.oracle.truffle.api.TruffleException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)5 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)5 Source (com.oracle.truffle.api.source.Source)5