|
| 1 | +/* |
| 2 | + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | + * |
| 5 | + * This code is free software; you can redistribute it and/or modify it |
| 6 | + * under the terms of the GNU General Public License version 2 only, as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | + * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | + * accompanied this code). |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License version |
| 16 | + * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | + * |
| 19 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | + * or visit www.oracle.com if you need additional information or have any |
| 21 | + * questions. |
| 22 | + */ |
| 23 | + |
| 24 | +/* |
| 25 | + * @test |
| 26 | + * @bug 8301813 |
| 27 | + * @summary Bad caret position in error message |
| 28 | + * @library /tools/lib ../../lib |
| 29 | + * @modules jdk.javadoc/jdk.javadoc.internal.tool |
| 30 | + * @build toolbox.ToolBox javadoc.tester.* |
| 31 | + * @run main TestNoTagName |
| 32 | + */ |
| 33 | + |
| 34 | +import java.nio.file.Path; |
| 35 | + |
| 36 | +import javadoc.tester.JavadocTester; |
| 37 | +import toolbox.ToolBox; |
| 38 | + |
| 39 | +public class TestNoTagName extends JavadocTester { |
| 40 | + |
| 41 | + public static void main(String... args) throws Exception { |
| 42 | + var test = new TestNoTagName(); |
| 43 | + test.runTests(); |
| 44 | + } |
| 45 | + |
| 46 | + private ToolBox tb = new ToolBox(); |
| 47 | + |
| 48 | + @Test |
| 49 | + public void test_inline_missing(Path base) throws Exception { |
| 50 | + Path src = base.resolve("src"); |
| 51 | + tb.writeJavaFiles(src, """ |
| 52 | + /** |
| 53 | + * abc {@ } def |
| 54 | + */ |
| 55 | + public class C { private C() { } } |
| 56 | + """ |
| 57 | + ); |
| 58 | + javadoc("-d", base.resolve("api").toString(), |
| 59 | + src.resolve("C.java").toString() |
| 60 | + ); |
| 61 | + checkExit(Exit.ERROR); |
| 62 | + checkOutput(Output.OUT, true, """ |
| 63 | + C.java:2: error: no tag name after '@' |
| 64 | + * abc {@ } def |
| 65 | + ^ |
| 66 | + """); |
| 67 | + } |
| 68 | + |
| 69 | + @Test |
| 70 | + public void test_inline_bad(Path base) throws Exception { |
| 71 | + Path src = base.resolve("src"); |
| 72 | + tb.writeJavaFiles(src, """ |
| 73 | + /** |
| 74 | + * abc {@/ } def |
| 75 | + */ |
| 76 | + public class C { private C() { } } |
| 77 | + """ |
| 78 | + ); |
| 79 | + javadoc("-d", base.resolve("api").toString(), |
| 80 | + src.resolve("C.java").toString() |
| 81 | + ); |
| 82 | + checkExit(Exit.ERROR); |
| 83 | + checkOutput(Output.OUT, true, """ |
| 84 | + C.java:2: error: no tag name after '@' |
| 85 | + * abc {@/ } def |
| 86 | + ^ |
| 87 | + """); |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + public void test_block_missing(Path base) throws Exception { |
| 92 | + Path src = base.resolve("src"); |
| 93 | + tb.writeJavaFiles(src, """ |
| 94 | + /** |
| 95 | + * abc. |
| 96 | + * @ def |
| 97 | + */ |
| 98 | + public class C { private C() { } } |
| 99 | + """ |
| 100 | + ); |
| 101 | + javadoc("-d", base.resolve("api").toString(), |
| 102 | + src.resolve("C.java").toString() |
| 103 | + ); |
| 104 | + checkExit(Exit.ERROR); |
| 105 | + checkOutput(Output.OUT, true, """ |
| 106 | + C.java:3: error: no tag name after '@' |
| 107 | + * @ def |
| 108 | + ^ |
| 109 | + """); |
| 110 | + } |
| 111 | + |
| 112 | + @Test |
| 113 | + public void test_block_bad(Path base) throws Exception { |
| 114 | + Path src = base.resolve("src"); |
| 115 | + tb.writeJavaFiles(src, """ |
| 116 | + /** |
| 117 | + * abc. |
| 118 | + * @/ def |
| 119 | + */ |
| 120 | + public class C { private C() { } } |
| 121 | + """ |
| 122 | + ); |
| 123 | + javadoc("-d", base.resolve("api").toString(), |
| 124 | + src.resolve("C.java").toString() |
| 125 | + ); |
| 126 | + checkExit(Exit.ERROR); |
| 127 | + checkOutput(Output.OUT, true, """ |
| 128 | + C.java:3: error: no tag name after '@' |
| 129 | + * @/ def |
| 130 | + ^ |
| 131 | + """); |
| 132 | + } |
| 133 | +} |
0 commit comments