@@ -1854,15 +1854,13 @@ class IllegelTagElement {}
18541854 Javadoc javadoc = typedeclaration .getJavadoc ();
18551855 List <TagElement > te = javadoc .tags ();
18561856 assertEquals ("TagElement length is grater than one" , 1 , te .size ());
1857- List <TagElement > tes = (te .get (0 )).fragments ();
1858- assertEquals ("inner TagElement length is grater than one" , 1 , tes .size ());
1859- assertEquals ("TagName" , "@link" , tes .get (0 ).getTagName ());
1860- List <?> fragments = tes .get (0 ).fragments ();
1857+ List <?> tes = (te .get (0 )).fragments ();
1858+ assertEquals ("TagName" , "@link" , ((TagElement )tes .get (0 )).getTagName ());
1859+ List <?> fragments = ((TagElement )tes .get (0 )).fragments ();
18611860 assertEquals ("fragments count does not match" , 2 , fragments .size ());
18621861 assertTrue (fragments .get (0 ) instanceof MethodRef );
18631862 assertTrue (fragments .get (1 ) instanceof TextElement );
1864- assertEquals ("Incorrect text" , "value" , fragments .get (1 ).toString ());
1865- assertEquals ("Incorrect name" , "#getValue()" , fragments .get (0 ).toString ());
1863+ assertEquals ("Incorrect TagElement" , 1 , ((TextElement ) (tes .get (1 ))).getFlags () & ASTNode .MALFORMED ); //MALFOUND flag
18661864 }
18671865 }
18681866
@@ -2234,4 +2232,106 @@ public class Markdown{}
22342232 assertEquals ("incorrect Fifth tagElement" , ASTNode .TAG_ELEMENT , tags .get (4 ).getNodeType ());
22352233 }
22362234 }
2235+
2236+ public void testInconsistencyInCodeAndLiteralTagsMarkdown4609_01 () throws JavaModelException {
2237+ String source = """
2238+ /// Performs:
2239+ ///
2240+ /// {@code
2241+ /// for (String s : strings) {
2242+ /// if (s.equals(value)) {
2243+ /// return 0;
2244+ /// }
2245+ /// if (s.startsWith(value)) {
2246+ /// return 1;
2247+ /// }
2248+ /// return -1;
2249+ /// }
2250+ /// }
2251+ /// The general contract of `hashCode` is:
2252+ ///
2253+ /// - Whenever it is invoked on the same object more than once during
2254+ /// an execution of a Java application, the `hashCode` method
2255+ /// must consistently return the same integer, provided no information
2256+ /// used in `equals` comparisons on the object is modified.
2257+ /// This integer need not remain consistent from one execution of an
2258+ /// application to another execution of the same application.
2259+ /// - If two objects are equal according to the
2260+ /// [equals][#equals(Object)] method, then calling the
2261+ /// `hashCode` method on each of the two objects must produce the
2262+ /// same integer result.
2263+ /// - It is _not_ required that if two objects are unequal
2264+ /// according to the [equals][#equals(Object)] method, then
2265+ /// calling the `hashCode` method on each of the two objects
2266+ /// must produce distinct integer results. However, the programmer
2267+ /// should be aware that producing distinct integer results for
2268+ /// unequal objects may improve the performance of hash tables.
2269+ public class Markdown{}
2270+ """ ;
2271+ this .workingCopies = new ICompilationUnit [1 ];
2272+ this .workingCopies [0 ] = getWorkingCopy ("/Converter_25/src/markdown/Markdown.java" , source , null );
2273+ if (this .docCommentSupport .equals (JavaCore .ENABLED )) {
2274+ CompilationUnit compilUnit = (CompilationUnit ) runConversion (this .workingCopies [0 ], true );
2275+ TypeDeclaration typedeclaration = (TypeDeclaration ) compilUnit .types ().get (0 );
2276+ Javadoc javadoc = typedeclaration .getJavadoc ();
2277+ List <TagElement > tags = javadoc .tags ();
2278+ List <ASTNode > frags = tags .get (0 ).fragments ();
2279+
2280+ assertEquals ("Incorrect Frags" , 22 , frags .size ());
2281+ assertEquals ("Invalid element" , ASTNode .TAG_ELEMENT , frags .get (1 ).getNodeType ());
2282+ assertEquals ("Invalid Text element content" , "The general contract of `hashCode` is:" , frags .get (2 ).toString ());
2283+ }
2284+
2285+ }
2286+
2287+ public void testInconsistencyInCodeAndLiteralTagsMarkdown4609_02 () throws JavaModelException {
2288+ String source = """
2289+ /// Performs:
2290+ ///
2291+ /// {@literal
2292+ /// for (String s : strings) {
2293+ /// if (s.equals(value)) {
2294+ /// return 0;
2295+ /// }
2296+ /// if (s.startsWith(value)) {
2297+ /// return 1;
2298+ /// }
2299+ /// return -1;
2300+ /// }
2301+ /// }
2302+ /// The general contract of `hashCode` is:
2303+ ///
2304+ /// - Whenever it is invoked on the same object more than once during
2305+ /// an execution of a Java application, the `hashCode` method
2306+ /// must consistently return the same integer, provided no information
2307+ /// used in `equals` comparisons on the object is modified.
2308+ /// This integer need not remain consistent from one execution of an
2309+ /// application to another execution of the same application.
2310+ /// - If two objects are equal according to the
2311+ /// [equals][#equals(Object)] method, then calling the
2312+ /// `hashCode` method on each of the two objects must produce the
2313+ /// same integer result.
2314+ /// - It is _not_ required that if two objects are unequal
2315+ /// according to the [equals][#equals(Object)] method, then
2316+ /// calling the `hashCode` method on each of the two objects
2317+ /// must produce distinct integer results. However, the programmer
2318+ /// should be aware that producing distinct integer results for
2319+ /// unequal objects may improve the performance of hash tables.
2320+ public class Markdown{}
2321+ """ ;
2322+ this .workingCopies = new ICompilationUnit [1 ];
2323+ this .workingCopies [0 ] = getWorkingCopy ("/Converter_25/src/markdown/Markdown.java" , source , null );
2324+ if (this .docCommentSupport .equals (JavaCore .ENABLED )) {
2325+ CompilationUnit compilUnit = (CompilationUnit ) runConversion (this .workingCopies [0 ], true );
2326+ TypeDeclaration typedeclaration = (TypeDeclaration ) compilUnit .types ().get (0 );
2327+ Javadoc javadoc = typedeclaration .getJavadoc ();
2328+ List <TagElement > tags = javadoc .tags ();
2329+ List <ASTNode > frags = tags .get (0 ).fragments ();
2330+
2331+ assertEquals ("Incorrect Frags" , 22 , frags .size ());
2332+ assertEquals ("Invalid element" , ASTNode .TAG_ELEMENT , frags .get (1 ).getNodeType ());
2333+ assertEquals ("Invalid Text element content" , "The general contract of `hashCode` is:" , frags .get (2 ).toString ());
2334+ }
2335+
2336+ }
22372337}
0 commit comments