Search in sources :

Example 96 with CallTarget

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

the class MethodGuardsTest method testComplexGuard.

@Test
public void testComplexGuard() {
    CallTarget root = createCallTarget(GuardComplexTestFactory.getInstance());
    assertEquals("do1", root.call(1));
    assertEquals("do1", root.call(2));
    assertEquals("do2", root.call(3));
    assertEquals("do1", root.call(0));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 97 with CallTarget

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

the class MethodGuardsTest method testGuardStaticField.

@Test
public void testGuardStaticField() {
    CallTarget root = createCallTarget(GuardStaticFieldTestFactory.getInstance());
    GuardStaticFieldTest.field = true;
    assertEquals("do1", root.call(1));
    assertEquals("do1", root.call(2));
    GuardStaticFieldTest.field = false;
    try {
        root.call(2);
        fail("expected Assertion failed");
    } catch (AssertionError e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 98 with CallTarget

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

the class MethodGuardsTest method testGuardMethod.

@Test
public void testGuardMethod() {
    CallTarget root = createCallTarget(GuardMethodTestFactory.getInstance());
    assertEquals("do1", root.call(1));
    assertEquals("do2", root.call(2));
    assertEquals("do1", root.call(1));
    assertEquals("do2", root.call(0));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 99 with CallTarget

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

the class MethodGuardsTest method testMultipleGuardOrMethod.

@Test
public void testMultipleGuardOrMethod() {
    CallTarget root = createCallTarget(GuardMultipleOrMethodTestFactory.getInstance());
    assertEquals("do1", root.call(1));
    assertEquals("do1", root.call(2));
    assertEquals("do2", root.call(3));
    assertEquals("do2", root.call(0));
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) Test(org.junit.Test)

Example 100 with CallTarget

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

the class MethodGuardsTest method testGuardUnboundMethodField.

@Test
public void testGuardUnboundMethodField() {
    CallTarget root = createCallTarget(GuardUnboundMethodTestFactory.getInstance());
    GuardUnboundMethodTest node = getNode(root);
    node.hiddenValue = true;
    assertEquals("do1", root.call(1));
    assertEquals("do1", root.call(2));
    node.hiddenValue = false;
    try {
        root.call(2);
        fail("expected Assertion failed");
    } catch (AssertionError e) {
    }
}
Also used : TestHelper.createCallTarget(com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget) CallTarget(com.oracle.truffle.api.CallTarget) 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