@@ -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
@@ -2314,4 +2312,105 @@ public class Markdown{}
23142312 assertEquals ("invalid tag name" ,"@literal" ,innerTag .getTagName ());
23152313 }
23162314 }
2315+
2316+ public void testInconsistencyInCodeAndLiteralTagsMarkdown4609_01 () throws JavaModelException {
2317+ String source = """
2318+ /// Performs:
2319+ ///
2320+ /// {@code
2321+ /// for (String s : strings) {
2322+ /// if (s.equals(value)) {
2323+ /// return 0;
2324+ /// }
2325+ /// if (s.startsWith(value)) {
2326+ /// return 1;
2327+ /// }
2328+ /// return -1;
2329+ /// }
2330+ /// }
2331+ /// The general contract of `hashCode` is:
2332+ ///
2333+ /// - Whenever it is invoked on the same object more than once during
2334+ /// an execution of a Java application, the `hashCode` method
2335+ /// must consistently return the same integer, provided no information
2336+ /// used in `equals` comparisons on the object is modified.
2337+ /// This integer need not remain consistent from one execution of an
2338+ /// application to another execution of the same application.
2339+ /// - If two objects are equal according to the
2340+ /// [equals][#equals(Object)] method, then calling the
2341+ /// `hashCode` method on each of the two objects must produce the
2342+ /// same integer result.
2343+ /// - It is _not_ required that if two objects are unequal
2344+ /// according to the [equals][#equals(Object)] method, then
2345+ /// calling the `hashCode` method on each of the two objects
2346+ /// must produce distinct integer results. However, the programmer
2347+ /// should be aware that producing distinct integer results for
2348+ /// unequal objects may improve the performance of hash tables.
2349+ public class Markdown{}
2350+ """ ;
2351+ this .workingCopies = new ICompilationUnit [1 ];
2352+ this .workingCopies [0 ] = getWorkingCopy ("/Converter_25/src/markdown/Markdown.java" , source , null );
2353+ if (this .docCommentSupport .equals (JavaCore .ENABLED )) {
2354+ CompilationUnit compilUnit = (CompilationUnit ) runConversion (this .workingCopies [0 ], true );
2355+ TypeDeclaration typedeclaration = (TypeDeclaration ) compilUnit .types ().get (0 );
2356+ Javadoc javadoc = typedeclaration .getJavadoc ();
2357+ List <TagElement > tags = javadoc .tags ();
2358+ List <ASTNode > frags = tags .get (0 ).fragments ();
2359+
2360+ assertEquals ("Incorrect Frags" , 22 , frags .size ());
2361+ assertEquals ("Invalid element" , ASTNode .TAG_ELEMENT , frags .get (1 ).getNodeType ());
2362+ assertEquals ("Invalid Text element content" , "The general contract of `hashCode` is:" , frags .get (2 ).toString ());
2363+ }
2364+
2365+ }
2366+
2367+ public void testInconsistencyInCodeAndLiteralTagsMarkdown4609_02 () throws JavaModelException {
2368+ String source = """
2369+ /// Performs:
2370+ ///
2371+ /// {@literal
2372+ /// for (String s : strings) {
2373+ /// if (s.equals(value)) {
2374+ /// return 0;
2375+ /// }
2376+ /// if (s.startsWith(value)) {
2377+ /// return 1;
2378+ /// }
2379+ /// return -1;
2380+ /// }
2381+ /// }
2382+ /// The general contract of `hashCode` is:
2383+ ///
2384+ /// - Whenever it is invoked on the same object more than once during
2385+ /// an execution of a Java application, the `hashCode` method
2386+ /// must consistently return the same integer, provided no information
2387+ /// used in `equals` comparisons on the object is modified.
2388+ /// This integer need not remain consistent from one execution of an
2389+ /// application to another execution of the same application.
2390+ /// - If two objects are equal according to the
2391+ /// [equals][#equals(Object)] method, then calling the
2392+ /// `hashCode` method on each of the two objects must produce the
2393+ /// same integer result.
2394+ /// - It is _not_ required that if two objects are unequal
2395+ /// according to the [equals][#equals(Object)] method, then
2396+ /// calling the `hashCode` method on each of the two objects
2397+ /// must produce distinct integer results. However, the programmer
2398+ /// should be aware that producing distinct integer results for
2399+ /// unequal objects may improve the performance of hash tables.
2400+ public class Markdown{}
2401+ """ ;
2402+ this .workingCopies = new ICompilationUnit [1 ];
2403+ this .workingCopies [0 ] = getWorkingCopy ("/Converter_25/src/markdown/Markdown.java" , source , null );
2404+ if (this .docCommentSupport .equals (JavaCore .ENABLED )) {
2405+ CompilationUnit compilUnit = (CompilationUnit ) runConversion (this .workingCopies [0 ], true );
2406+ TypeDeclaration typedeclaration = (TypeDeclaration ) compilUnit .types ().get (0 );
2407+ Javadoc javadoc = typedeclaration .getJavadoc ();
2408+ List <TagElement > tags = javadoc .tags ();
2409+ List <ASTNode > frags = tags .get (0 ).fragments ();
2410+
2411+ assertEquals ("Incorrect Frags" , 22 , frags .size ());
2412+ assertEquals ("Invalid element" , ASTNode .TAG_ELEMENT , frags .get (1 ).getNodeType ());
2413+ assertEquals ("Invalid Text element content" , "The general contract of `hashCode` is:" , frags .get (2 ).toString ());
2414+ }
2415+ }
23172416}
0 commit comments