0N/A/*
2362N/A * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 6341023
0N/A * @summary Tree API: Tree.Kind should have mapping to interface
0N/A */
0N/A
0N/Aimport com.sun.source.tree.*;
0N/A
0N/Apublic class TreeKindTest{
0N/A public static void main(String... args) {
0N/A boolean ok = true;
0N/A
0N/A for (Tree.Kind k: Tree.Kind.values()) {
0N/A //System.err.println(k + " " + k.asInterface());
0N/A Class<? extends Tree> i = k.asInterface();
0N/A switch (k) {
0N/A case POSTFIX_INCREMENT:
0N/A case POSTFIX_DECREMENT:
0N/A case PREFIX_INCREMENT:
0N/A case PREFIX_DECREMENT:
0N/A case UNARY_PLUS:
0N/A case UNARY_MINUS:
0N/A case BITWISE_COMPLEMENT:
0N/A case LOGICAL_COMPLEMENT:
0N/A ok = ok & verify(k, i, i == UnaryTree.class);
0N/A break;
0N/A
0N/A case MULTIPLY:
0N/A case DIVIDE:
0N/A case REMAINDER:
0N/A case PLUS:
0N/A case MINUS:
0N/A case LEFT_SHIFT:
0N/A case RIGHT_SHIFT:
0N/A case UNSIGNED_RIGHT_SHIFT:
0N/A case LESS_THAN:
0N/A case GREATER_THAN:
0N/A case LESS_THAN_EQUAL:
0N/A case GREATER_THAN_EQUAL:
0N/A case EQUAL_TO:
0N/A case NOT_EQUAL_TO:
0N/A case AND:
0N/A case XOR:
0N/A case OR:
0N/A case CONDITIONAL_AND:
0N/A case CONDITIONAL_OR:
0N/A ok = ok & verify(k, i, i == BinaryTree.class);
0N/A break;
0N/A
0N/A case MULTIPLY_ASSIGNMENT:
0N/A case DIVIDE_ASSIGNMENT:
0N/A case REMAINDER_ASSIGNMENT:
0N/A case PLUS_ASSIGNMENT:
0N/A case MINUS_ASSIGNMENT:
0N/A case LEFT_SHIFT_ASSIGNMENT:
0N/A case RIGHT_SHIFT_ASSIGNMENT:
0N/A case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
0N/A case AND_ASSIGNMENT:
0N/A case XOR_ASSIGNMENT:
0N/A case OR_ASSIGNMENT:
0N/A ok = ok & verify(k, i, i == CompoundAssignmentTree.class);
0N/A break;
0N/A
0N/A case INT_LITERAL:
0N/A case LONG_LITERAL:
0N/A case FLOAT_LITERAL:
0N/A case DOUBLE_LITERAL:
0N/A case BOOLEAN_LITERAL:
0N/A case CHAR_LITERAL:
0N/A case STRING_LITERAL:
0N/A case NULL_LITERAL:
0N/A ok = ok & verify(k, i, i == LiteralTree.class);
0N/A break;
0N/A
0N/A case UNBOUNDED_WILDCARD:
0N/A case EXTENDS_WILDCARD:
0N/A case SUPER_WILDCARD:
0N/A ok = ok & verify(k, i, i == WildcardTree.class);
0N/A break;
0N/A
0N/A case INTERFACE:
0N/A case ANNOTATION_TYPE:
0N/A case ENUM:
0N/A case CLASS:
0N/A ok = ok & verify(k, i, i == ClassTree.class);
0N/A break;
0N/A
0N/A case OTHER:
0N/A ok = ok & verify(k, i, i == null);
0N/A break;
0N/A
0N/A default:
0N/A String ks = k.toString().replace("_", "") + "tree";
0N/A String iName = i.getName();
0N/A String is = iName.substring(iName.lastIndexOf(".") + 1);
0N/A ok = ok & verify(k, i, ks.equalsIgnoreCase(is));
0N/A }
0N/A }
0N/A
0N/A if (!ok)
0N/A throw new AssertionError("test failed");
0N/A }
0N/A
0N/A static boolean verify(Tree.Kind k, Class<?> c, boolean b) {
0N/A if (!b)
0N/A System.err.println("error: " + k + " " + c);
0N/A return b;
0N/A }
0N/A}
0N/A