annotate truffle/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/NegatedGuardsTest.java @ 22548:6b76a24fffbd default tip

Use all variables: a, b, u,v and x, y
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 14 Jan 2016 14:20:57 +0100
parents 5309cc9668e3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11190
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
1 /*
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
4 *
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
8 *
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
13 * accompanied this code).
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
14 *
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
18 *
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
21 * questions.
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
22 */
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
23 package com.oracle.truffle.api.dsl.test;
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
24
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
25 import static com.oracle.truffle.api.dsl.test.TestHelper.createRoot;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
26 import static com.oracle.truffle.api.dsl.test.TestHelper.executeWith;
22241
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
27
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
28 import org.junit.Assert;
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
29 import org.junit.Test;
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
30
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
31 import com.oracle.truffle.api.dsl.Specialization;
14e6dfb1ef05 Truffle/Testing: massive rework of tests to accommodate recent instrumentation change with respect to "applyInstrumentation"
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents: 22157
diff changeset
32 import com.oracle.truffle.api.dsl.test.NegatedGuardsTestFactory.NegatedGuardNodeFactory;
11190
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
33 import com.oracle.truffle.api.dsl.test.TypeSystemTest.TestRootNode;
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
34 import com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode;
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
35
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
36 public class NegatedGuardsTest {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
37
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
38 @Test
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
39 public void testGuardGlobal() {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
40 TestRootNode<NegatedGuardNode> root = createRoot(NegatedGuardNodeFactory.getInstance());
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
41 Assert.assertEquals(42, executeWith(root));
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
42 }
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
43
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
44 abstract static class NegatedGuardNode extends ValueNode {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
45
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
46 static boolean guard() {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
47 return true;
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
48 }
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
49
19283
08aa0372dad4 Truffle-DSL: implement new guard expression syntax.
Christian Humer <christian.humer@gmail.com>
parents: 16866
diff changeset
50 @Specialization(guards = "!guard()")
11190
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
51 int do1() {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
52 throw new AssertionError();
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
53 }
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
54
16866
d834f85ac8a1 small cleanup
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16756
diff changeset
55 @Specialization
11190
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
56 int do2() {
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
57 return 42; // the generic answer to all questions
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
58 }
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
59 }
4eb23800c907 Truffle-DSL: Implemented support for negated guards (GRAAL-371 #resolve)
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
60 }