ebarboni commented on code in PR #9258:
URL: https://github.com/apache/netbeans/pull/9258#discussion_r2919815931


##########
java/java.source.base/test/unit/src/org/netbeans/modules/java/source/save/FormatingTest.java:
##########
@@ -6328,7 +6325,52 @@ public void testForVar2() throws Exception {
                 + "    }\n"
                 + "}\n";
         reformat(doc, content, golden);
-        JavaSourceTest.SourceLevelQueryImpl.sourceLevel = oldLevel;
+    }
+
+    public void testForVarUnnamed() throws Exception {
+        sourceLevel = "22";
+        testFile = new File(getWorkDir(), "Test.java");
+        TestUtilities.copyStringToFile(testFile, "");
+        FileObject testSourceFO = FileUtil.toFileObject(testFile);
+        DataObject testSourceDO = DataObject.find(testSourceFO);
+        EditorCookie ec = (EditorCookie) 
testSourceDO.getCookie(EditorCookie.class);
+        final Document doc = ec.openDocument();
+        doc.putProperty(Language.class, JavaTokenId.language());
+        String content
+                = """
+                  package hierbas.del.litoral;
+                  
+                  public class Test {
+                  
+                      public static void main(String[] args) {
+                          int[] orderIDs = {34, 45, 23, 27, 15};
+                          int total = 0;
+                          for (   var   _:orderIDs) {
+                            total++;
+                          }
+                      }
+                  }
+                  """;
+
+        String golden
+                = """
+                  package hierbas.del.litoral;
+                  
+                  public class Test {
+                  
+                      public static void main(String[] args) {
+                          int[] orderIDs = {34, 45, 23, 27, 15};
+                          int total = 0;
+                          for (var _ : orderIDs) {
+                              total++;
+                          }
+                      }
+                  }
+                  """;
+
+        //check no change then formatted
+        reformat(doc, golden, golden);
+        reformat(doc, content, golden);

Review Comment:
   exactly ensure `golden` is `golden` but for every use of reformat in the 
test. 
   More for the future of course (because it break 2 tests):
   
   ```
   private void reformat(Document doc, String content, String golden) throws 
Exception {
           reformat(doc, golden, golden, 0, golden.length());
           reformat(doc, content, golden, 0, content.length());
       }
   ```
   
   Tested for fun (only 2 golden not golden), 
    test135210 generate javadoc line
    testJavadoc reformat is in 2 step         



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to