Damien Martin-Guillerez | f88f4d8 | 2015-09-25 13:56:55 +0000 | [diff] [blame] | 1 | // Copyright 2015 The Bazel Authors. All rights reserved. |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 2 | // |
| 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. |
| 14 | package com.google.devtools.build.lib.syntax; |
| 15 | |
jcater | 02681a4 | 2019-04-26 15:52:48 -0700 | [diff] [blame] | 16 | import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 17 | |
brandjon | e2ffd5d | 2017-06-27 18:14:54 +0200 | [diff] [blame] | 18 | import java.io.IOException; |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 19 | import org.junit.Before; |
| 20 | import org.junit.Test; |
| 21 | import org.junit.runner.RunWith; |
| 22 | import org.junit.runners.JUnit4; |
| 23 | |
| 24 | /** |
| 25 | * Tests {@link ASTNode}. |
| 26 | */ |
| 27 | @RunWith(JUnit4.class) |
| 28 | public class ASTNodeTest { |
| 29 | |
| 30 | private ASTNode node; |
| 31 | |
| 32 | @Before |
Florian Weikert | 5956bae | 2015-12-01 10:22:44 +0000 | [diff] [blame] | 33 | public final void createNode() throws Exception { |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 34 | node = new ASTNode() { |
| 35 | @Override |
brandjon | e2ffd5d | 2017-06-27 18:14:54 +0200 | [diff] [blame] | 36 | public void prettyPrint(Appendable buffer, int indentLevel) throws IOException {} |
| 37 | @Override |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 38 | 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() { |
jcater | 02681a4 | 2019-04-26 15:52:48 -0700 | [diff] [blame] | 49 | assertThrows(UnsupportedOperationException.class, () -> node.hashCode()); |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | @Test |
| 53 | public void testEqualsNotSupported() { |
jcater | 02681a4 | 2019-04-26 15:52:48 -0700 | [diff] [blame] | 54 | assertThrows(UnsupportedOperationException.class, () -> node.equals(null)); |
Ulf Adams | 89f012d | 2015-02-26 13:39:28 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } |