neilcsmith-net commented on code in PR #9258:
URL: https://github.com/apache/netbeans/pull/9258#discussion_r2919505846
##########
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:
Not sure what you mean? But the tests are isolated and don't (shouldn't)
affect each other. The entire contents of `doc` is set to the second String
parameter, reformatted, and tested against the third String parameter.
The first check is there to make sure `golden` does not change.
--
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