You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2018/07/03 04:17:44 UTC

[incubator-netbeans] 04/05: Generalizing golden file lookup.

This is an automated email from the ASF dual-hosted git repository.

jlahoda pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git

commit 7b6fd7540b4b7c829b881d24ba61a9d16567b990
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Sat Jun 30 12:27:36 2018 +0200

    Generalizing golden file lookup.
---
 .../java/completion/CompletionTestBase.java        | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
index 428ce16..47a095f 100644
--- a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
+++ b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
@@ -266,7 +266,7 @@ public class CompletionTestBase extends NbTestCase {
         
         File goldenFile = null;
         String version = System.getProperty("java.specification.version");
-        for (String variant : VERSION_VARIANTS.get(version)) {
+        for (String variant : computeVersionVariantsFor(version)) {
             goldenFile = new File(getDataDir(), "/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/" + variant + "/" + goldenFileName);
             if (goldenFile.exists())
                 break;
@@ -278,16 +278,17 @@ public class CompletionTestBase extends NbTestCase {
         LifecycleManager.getDefault().saveAll();
     }
 
-    private static final Map<String, List<String>> VERSION_VARIANTS = new HashMap<>();
-
-    static {
-        VERSION_VARIANTS.put("1.8", Arrays.asList("1.8"));
-        VERSION_VARIANTS.put("9", Arrays.asList("9", "1.8"));
-        VERSION_VARIANTS.put("1.9", Arrays.asList("9", "1.8"));
-        VERSION_VARIANTS.put("10", Arrays.asList("10", "9", "1.8"));
-        VERSION_VARIANTS.put("1.10", Arrays.asList("10", "9", "1.8"));
-        VERSION_VARIANTS.put("11", Arrays.asList("11", "10", "9", "1.8"));
-        VERSION_VARIANTS.put("1.11", Arrays.asList("11", "10", "9", "1.8"));
+    private List<String> computeVersionVariantsFor(String version) {
+        int dot = version.indexOf('.');
+        version = version.substring(dot + 1);
+        int versionNum = Integer.parseInt(version);
+        List<String> versions = new ArrayList<>();
+        
+        for (int v = versionNum; v >= 8; v--) {
+            versions.add(v != 8 ? "" + v : "1." + v);
+        }
+        
+        return versions;
     }
 
     private void copyToWorkDir(File resource, File toFile) throws IOException {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

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