blob: c3803093f14a9d5bafda8faee890d20290678561 [file] [log] [blame]
Damien Martin-Guillerezf88f4d82015-09-25 13:56:55 +00001// Copyright 2015 The Bazel Authors. All rights reserved.
Ulf Adams89f012d2015-02-26 13:39:28 +00002//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14package com.google.devtools.build.lib.syntax;
15
jcater02681a42019-04-26 15:52:48 -070016import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows;
Ulf Adams89f012d2015-02-26 13:39:28 +000017
brandjone2ffd5d2017-06-27 18:14:54 +020018import java.io.IOException;
Ulf Adams89f012d2015-02-26 13:39:28 +000019import org.junit.Before;
20import org.junit.Test;
21import org.junit.runner.RunWith;
22import org.junit.runners.JUnit4;
23
24/**
25 * Tests {@link ASTNode}.
26 */
27@RunWith(JUnit4.class)
28public class ASTNodeTest {
29
30 private ASTNode node;
31
32 @Before
Florian Weikert5956bae2015-12-01 10:22:44 +000033 public final void createNode() throws Exception {
Ulf Adams89f012d2015-02-26 13:39:28 +000034 node = new ASTNode() {
35 @Override
brandjone2ffd5d2017-06-27 18:14:54 +020036 public void prettyPrint(Appendable buffer, int indentLevel) throws IOException {}
37 @Override
Ulf Adams89f012d2015-02-26 13:39:28 +000038 public String toString() {
39 return null;
40 }
41 @Override
42 public void accept(SyntaxTreeVisitor visitor) {
43 }
44 };
45 }
46
47 @Test
48 public void testHashCodeNotSupported() {
jcater02681a42019-04-26 15:52:48 -070049 assertThrows(UnsupportedOperationException.class, () -> node.hashCode());
Ulf Adams89f012d2015-02-26 13:39:28 +000050 }
51
52 @Test
53 public void testEqualsNotSupported() {
jcater02681a42019-04-26 15:52:48 -070054 assertThrows(UnsupportedOperationException.class, () -> node.equals(null));
Ulf Adams89f012d2015-02-26 13:39:28 +000055 }
56
57}