comparison graal/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/FibonacciTest.java @ 13455:69d2e4baa215

Truffle: new infrastructure related to instrumentation, and in particular debugging: support for managing Source objects; framework for generalized "instrumentation proxy nodes" (to be inserted into ASTs with no runtime cost when inactive), and "probes" (which can be attached to proxy nodes to receive event notification); a rudimentary interface and abstract implementation for a "debug manager" (mostly a placeholder at this point); and the beginning of a language-agnostic ExecutionContext interface.
author Michael Van De Vanter <michael.van.de.vanter@oracle.com>
date Tue, 17 Dec 2013 20:22:45 -0800
parents 71991b7a0f14
children
comparison
equal deleted inserted replaced
13306:dfb780080923 13455:69d2e4baa215
1 /* 1 /*
2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
24 24
25 import javax.script.*; 25 import javax.script.*;
26 26
27 import org.junit.*; 27 import org.junit.*;
28 28
29 import com.oracle.truffle.api.*;
29 import com.oracle.truffle.sl.*; 30 import com.oracle.truffle.sl.*;
30 import com.oracle.truffle.sl.runtime.*; 31 import com.oracle.truffle.sl.runtime.*;
31 32
32 // @formatter:off 33 // @formatter:off
33 public class FibonacciTest extends AbstractTest{ 34 public class FibonacciTest extends AbstractTest{
73 public void test() throws ScriptException { 74 public void test() throws ScriptException {
74 StringBuilder s = new StringBuilder(); 75 StringBuilder s = new StringBuilder();
75 for (String line : INPUT) { 76 for (String line : INPUT) {
76 s.append(line).append("\n"); 77 s.append(line).append("\n");
77 } 78 }
78 SLScript script = SLScript.create(new SLContext(System.out), s.toString()); 79 final SLContext context = new SLContext(System.out);
80 final Source source = context.getSourceManager().get("(fib test)", s.toString());
81 SLScript script = SLScript.create(context, source);
79 Integer reference = test(TEST_VALUE); 82 Integer reference = test(TEST_VALUE);
80 for (int i = 0; i < ITERATIONS; i++) { 83 for (int i = 0; i < ITERATIONS; i++) {
81 if (!reference.equals(script.run(TEST_VALUE))) { 84 if (!reference.equals(script.run(TEST_VALUE))) {
82 throw new AssertionError(); 85 throw new AssertionError();
83 } 86 }