/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* See LICENSE.txt included in this distribution for the specific
* language governing permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at LICENSE.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/**
* Unit tests for JFlexXref.
*/
public class JFlexXrefTest {
/**
* This is what we expect to find at the beginning of the first line
* returned by an xref.
*/
"<div id='lines'\n><div>";
/** the end of each line in an xref file */
/** the end of an xref file */
@SuppressWarnings("javadoc")
repository = new TestRepository();
"/org/opensolaris/opengrok/index/source.zip"));
}
}
/**
* Regression test case for bug #15890. Check that we get the expected the
* expected line count from input with some special characters that used
* to cause trouble.
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
"line 1\n" +
"line 2\n" +
"line 3\n" +
"line 4 with \u000B char\n" +
"line 5 with \u000C char\n" +
"line 6 with \u0085 char\n" +
"line 7 with \u2028 char\n" +
"line 8 with \u2029 char\n" +
"line 9\n";
}
/**
* Helper method that checks the line count for
* {@link #testBug15890LineCount()}.
*
* @param xref an instance of the xref class to test
*/
@SuppressWarnings("resource")
}
/**
* Regression test case for bug #15890. Check that an anchor is correctly
* inserted for definitions that appear after some special characters that
* used to cause trouble.
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
}
/**
* Helper method for {@link #testBug15890Anchor()}.
*
* @param klass the Xref sub-class to test
* @param path path to input file with a definition
*/
@SuppressWarnings("resource")
{
// Input files contain non-ascii characters and are encoded in UTF-8
//TODO improve below to reflect all possible classes of a definition
"No anchor found",
}
/**
* Regression test case for bug #14663, which used to break syntax
* highlighting in ShXref.
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
// \" should not start a new string literal
// \" should not terminate a string literal
"<b>echo</b> <span class=\"s\">\"\\\"\"</span>");
// \` should not start a command substitution
// \` should not start command substitution inside a string
"<b>echo</b> <span class=\"s\">\"\\`\"</span>");
// \` should not terminate command substitution
"<b>echo</b> <span>`\\``</span>");
// $# should not start a comment
}
/**
* Helper method that checks that the expected output is produced for a
* line with the specified xref class. Fails if the output is not as
* expected.
*
* @param xrefClass xref class to test
* @param inputLine the source code line to parse
* @param expectedOutput the expected output from the xreffer
*/
@SuppressWarnings("resource")
new StringReader(inputLine));
}
/**
* Regression test case for bug #16883. Some of the state used to survive
* across invocations in ShXref, so that a syntax error in one file might
* cause broken highlighting in subsequent files. Test that the instance
* is properly reset now.
* @throws Exception
*/
@Test
// Analyze a script with broken syntax (unterminated string literal)
// Reuse the xref and verify that the broken syntax in the previous
// file doesn't cause broken highlighting in the next file
out = new StringWriter();
}
/**
* <p>
* Test the handling of #include in C and C++. In particular, these issues
* are tested:
* </p>
*
* <ul>
*
* <li>
* </li>
*
* <li>
* Verify that the link generated for #include <vector> performs a
* path search (bug #17816)
* </li>
*
* </ul>
* @throws Exception
*/
@SuppressWarnings("static-method")
@Test
testCXrefInclude(CXref.class);
testCXrefInclude(CxxXref.class);
}
@SuppressWarnings("resource")
throws Exception
{
{"#include <abc.h>", "#<b>include</b> <<a href=\"/source"
{"#include \"abc.h\"", "#<b>include</b> <span class=\"s\">\"<a href=\"/source"
{"#include <vector>", "#<b>include</b> <<a href=\"/source"
};
}
}
/**
* Verify that ShXref handles here-documents. Bug #18198.
* @throws IOException
*/
@Test
"cat<<EOF\n" +
"This shouldn't cause any problem.\n" +
"EOF\n" +
"var='some string'\n");
// The single-quote on line 2 shouldn't start a string literal.
// The string literal on line 4 should be recognized as one.
}
/**
* Test that JavaXref handles empty Java comments. Bug #17885.
* @throws IOException
*/
@Test
// Verify that the comment's <span> block is terminated.
}
@Test
// The next call used to fail with an ArrayIndexOutOfBoundsException.
}
}