JFlexXrefTest.java revision 1167
0N/A * The contents of this file are subject to the terms of the 0N/A * Common Development and Distribution License (the "License"). 0N/A * You may not use this file except in compliance with the License. 0N/A * language governing permissions and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL HEADER in each 0N/A * If applicable, add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your own identifying 0N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1472N/A * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * Unit tests for JFlexXref. 0N/A * This is what we expect to find at the beginning of the first line 0N/A * returned by an xref. 0N/A "<a class=\"l\" name=\"1\" href=\"#1\">" +
0N/A " 1 </a>";
0N/A * Regression test case for bug #15890. Check that we get the expected the 0N/A * expected line count from input with some special characters that used 0N/A "line 4 with \u000B char\n" +
0N/A "line 5 with \u000C char\n" +
0N/A "line 6 with \u0085 char\n" +
0N/A "line 7 with \u2028 char\n" +
0N/A "line 8 with \u2029 char\n" +
0N/A * Helper method that checks the line count for 0N/A * {@link #testBug15890LineCount()}. 0N/A * @param xref an instance of the xref class to test 0N/A * Regression test case for bug #15890. Check that an anchor is correctly 0N/A * inserted for definitions that appear after some special characters that 0N/A * used to cause trouble. 0N/A * Helper method for {@link #testBug15890Anchor()}. 0N/A * @param klass the Xref sub-class to test 0N/A * @param path path to input file with a definition 0N/A // Input files contain non-ascii characters and are encoded in UTF-8 0N/A //TODO improve below to reflect all possible classes of a definition 0N/A * Regression test case for bug #14663, which used to break syntax 0N/A * highlighting in ShXref. 0N/A // \" should not start a new string literal 0N/A // \" should not terminate a string literal 0N/A "<b>echo</b> <span class=\"s\">\"\\\"\"</span>");
0N/A // \` should not start a command substitution 0N/A // \` should not start command substitution inside a string 0N/A "<b>echo</b> <span class=\"s\">\"\\`\"</span>");
0N/A // \` should not terminate command substitution 0N/A "<b>echo</b> <span>`\\``</span>");
0N/A // $# should not start a comment 0N/A * Helper method that checks that the expected output is produced for a 0N/A * line with the specified xref class. Fails if the output is not as 0N/A * @param xrefClass xref class to test 0N/A * @param inputLine the source code line to parse 0N/A * @param expectedOutput the expected output from the xreffer 0N/A * Regression test case for bug #16883. Some of the state used to survive 0N/A * across invocations in ShXref, so that a syntax error in one file might 0N/A * cause broken highlighting in subsequent files. Test that the instance 0N/A * is properly reset now. 0N/A // Analyze a script with broken syntax (unterminated string literal) 0N/A "<b>echo</b> <span class=\"s\">\"xyz</span>",
0N/A // Reuse the xref and verify that the broken syntax in the previous 0N/A // file doesn't cause broken highlighting in the next file 0N/A "<b>echo</b> <span class=\"s\">\"hello\"</span>",
0N/A * Test the handling of #include in C and C++. In particular, these issues 0N/A * Verify that we use breadcrumb path for both #include <x/y.h> and 0N/A * #include "x/y.h" in C and C++ (bug #17817) 0N/A * Verify that the link generated for #include <vector> performs a 0N/A * path search (bug #17816) 0N/A {
"#include <abc.h>",
"#<b>include</b> <<a href=\"/source/s?path=abc.h\">abc.h</a>>" },
0N/A {
"#include <abc/def.h>",
"#<b>include</b> <<a href=\"/source/s?path=abc\">abc</a>/<a href=\"/source/s?path=abc/def.h\">def.h</a>>" },
0N/A {
"#include \"abc.h\"",
"#<b>include</b> <span class=\"s\">\"<a href=\"/source/s?path=abc.h\">abc.h</a>\"</span>" },
0N/A {
"#include \"abc/def.h\"",
"#<b>include</b> <span class=\"s\">\"<a href=\"/source/s?path=abc\">abc</a>/<a href=\"/source/s?path=abc/def.h\">def.h</a>\"</span>" },
0N/A {
"#include <vector>",
"#<b>include</b> <<a href=\"/source/s?path=vector\">vector</a>>" },
0N/A * Verify that ShXref handles here-documents. Bug #18198. 0N/A "This shouldn't cause any problem.\n" +
0N/A // The single-quote on line 2 shouldn't start a string literal. 0N/A // The string literal on line 4 should be recognized as one. 0N/A * Test that JavaXref handles empty Java comments. Bug #17885. // Verify that the comment's <span> block is terminated.