Search in sources :

Example 86 with CallTarget

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

the class CachedTest method testBoundCacheOverflowContains.

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

Example 87 with CallTarget

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

the class CachedTest method testUnboundCache.

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

Example 88 with CallTarget

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

the class ExecuteEvaluatedTest method testDoubleEvaluated2.

@Test
public void testDoubleEvaluated2() {
    ArgumentNode arg0 = new ArgumentNode(0);
    ArgumentNode arg1 = new ArgumentNode(1);
    CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluated2NodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null)));
    Assert.assertEquals(42, callTarget.call(new Object[] { 1, 43 }));
    Assert.assertEquals(1, arg0.getInvocationCount());
    Assert.assertEquals(1, arg1.getInvocationCount());
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) ArgumentNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode) Test(org.junit.Test)

Example 89 with CallTarget

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

the class ExecuteEvaluatedTest method testDoubleEvaluated1.

@Test
public void testDoubleEvaluated1() {
    ArgumentNode arg0 = new ArgumentNode(0);
    ArgumentNode arg1 = new ArgumentNode(1);
    CallTarget callTarget = TestHelper.createCallTarget(UseDoubleEvaluated1NodeFactory.create(arg0, arg1, DoubleEvaluatedNodeFactory.create(null, null)));
    Assert.assertEquals(42, callTarget.call(new Object[] { 43, 1 }));
    Assert.assertEquals(1, arg0.getInvocationCount());
    Assert.assertEquals(1, arg1.getInvocationCount());
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) ArgumentNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ArgumentNode) Test(org.junit.Test)

Example 90 with CallTarget

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

the class IntegerLiteralGuardsTest method testOctalLiteral.

@Test
public void testOctalLiteral() {
    CallTarget root = createCallTarget(OctalLiteralTestFactory.getInstance());
    assertEquals("do1", root.call(12));
}
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