Mercurial > hg > graal-compiler
view graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/SimplePartialEvaluationTest.java @ 11188:ae6b8ec920e2
Truffle-DSL: Added a hack to get around eclipse bug 300408. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=300408)
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 31 Jul 2013 15:04:13 +0200 |
parents | b42db1748ff2 |
children | ac5b0f31f7a2 |
line wrap: on
line source
/* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package com.oracle.graal.truffle.test; import org.junit.*; import com.oracle.graal.truffle.test.nodes.*; import com.oracle.truffle.api.frame.*; @Ignore("Currently ignored due to problems with code coverage tools.") public class SimplePartialEvaluationTest extends PartialEvaluationTest { public static Object constant42() { return 42; } @Test public void constantValue() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new ConstantTestNode(42); assertPartialEvalEquals("constant42", new RootTestNode("constantValue", result), fd); } @Test public void addConstants() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new AddTestNode(new ConstantTestNode(40), new ConstantTestNode(2)); assertPartialEvalEquals("constant42", new RootTestNode("addConstants", result), fd); } @Test public void sequenceConstants() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new BlockTestNode(new AbstractTestNode[]{new ConstantTestNode(40), new ConstantTestNode(42)}); assertPartialEvalEquals("constant42", new RootTestNode("sequenceConstants", result), fd); } @Test public void localVariable() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new BlockTestNode(new AbstractTestNode[]{new StoreLocalTestNode("x", fd, new ConstantTestNode(42)), new LoadLocalTestNode("x", fd)}); assertPartialEvalEquals("constant42", new RootTestNode("localVariable", result), fd); } @Test public void longSequenceConstants() { FrameDescriptor fd = new FrameDescriptor(); int length = 40; AbstractTestNode[] children = new AbstractTestNode[length]; for (int i = 0; i < children.length; ++i) { children[i] = new ConstantTestNode(42); } AbstractTestNode result = new BlockTestNode(children); assertPartialEvalEquals("constant42", new RootTestNode("longSequenceConstants", result), fd); } @Test public void longAddConstants() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new ConstantTestNode(2); for (int i = 0; i < 20; ++i) { result = new AddTestNode(result, new ConstantTestNode(2)); } assertPartialEvalEquals("constant42", new RootTestNode("longAddConstants", result), fd); } @Test public void mixLocalAndAdd() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new BlockTestNode(new AbstractTestNode[]{new StoreLocalTestNode("x", fd, new ConstantTestNode(40)), new StoreLocalTestNode("x", fd, new AddTestNode(new LoadLocalTestNode("x", fd), new ConstantTestNode(2))), new LoadLocalTestNode("x", fd)}); assertPartialEvalEquals("constant42", new RootTestNode("mixLocalAndAdd", result), fd); } @Test public void loop() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new BlockTestNode(new AbstractTestNode[]{new StoreLocalTestNode("x", fd, new ConstantTestNode(0)), new LoopTestNode(21, new StoreLocalTestNode("x", fd, new AddTestNode(new LoadLocalTestNode("x", fd), new ConstantTestNode(2))))}); assertPartialEvalEquals("constant42", new RootTestNode("loop", result), fd); } @Test public void longLoop() { FrameDescriptor fd = new FrameDescriptor(); AbstractTestNode result = new BlockTestNode(new AbstractTestNode[]{new StoreLocalTestNode("x", fd, new ConstantTestNode(0)), new LoopTestNode(42, new StoreLocalTestNode("x", fd, new AddTestNode(new LoadLocalTestNode("x", fd), new ConstantTestNode(1))))}); assertPartialEvalNoInvokes(new RootTestNode("loop", result), fd); } }