blob: b8b961342a83e2f1201dee9ae425ad184521cbf1 [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
16import static org.junit.Assert.fail;
17
18import org.junit.Before;
19import org.junit.Test;
20import org.junit.runner.RunWith;
21import org.junit.runners.JUnit4;
22
23/**
24 * Tests {@link ASTNode}.
25 */
26@RunWith(JUnit4.class)
27public class ASTNodeTest {
28
29 private ASTNode node;
30
31 @Before
Florian Weikert5956bae2015-12-01 10:22:44 +000032 public final void createNode() throws Exception {
Ulf Adams89f012d2015-02-26 13:39:28 +000033 node = new ASTNode() {
34 @Override
35 public String toString() {
36 return null;
37 }
38 @Override
39 public void accept(SyntaxTreeVisitor visitor) {
40 }
41 };
42 }
43
44 @Test
45 public void testHashCodeNotSupported() {
46 try {
47 node.hashCode();
48 fail();
49 } catch (UnsupportedOperationException e) {
50 // yes!
51 }
52 }
53
54 @Test
55 public void testEqualsNotSupported() {
56 try {
57 node.equals(this);
58 fail();
59 } catch (UnsupportedOperationException e) {
60 // yes!
61 }
62 }
63
64}