< prev index next >

test/langtools/tools/javac/processing/model/TestSourceVersion.java

Print this page




  79             for(SourceVersion version : SourceVersion.values()) {
  80                 boolean isKeyword = version.compareTo(value) >= 0;
  81 
  82                 check(isKeyword,  isKeyword(key, version), "keyword", version);
  83                 check(!isKeyword, isName(key, version),    "name",    version);
  84             }
  85         }
  86     }
  87 
  88     private static void testRestrictedKeywords() {
  89         // Restricted keywords are not full keywords
  90 
  91         /*
  92          * JLS 3.9
  93          * " A further ten character sequences are restricted
  94          * keywords: open, module, requires, transitive, exports,
  95          * opens, to, uses, provides, and with"
  96          */
  97         Set<String> restrictedKeywords =
  98             Set.of("open", "module", "requires", "transitive", "exports",
  99                    "opens", "to", "uses", "provides", "with");


 100 
 101         for(String key : restrictedKeywords) {
 102             for(SourceVersion version : SourceVersion.values()) {
 103                 check(false, isKeyword(key, version), "keyword", version);
 104                 check(true,  isName(key, version),    "name",    version);
 105             }
 106         }
 107     }
 108 
 109     private static void testVar() {
 110 
 111         for(SourceVersion version : SourceVersion.values()) {
 112             check(false, isKeyword("var",     version), "keyword", version);
 113             check(false, isKeyword("foo.var", version), "keyword", version);
 114             check(false, isKeyword("var.foo", version), "keyword", version);
 115 
 116             check(true, isName("var", version),     "name", version);
 117             check(true, isName("foo.var", version), "name", version);
 118             check(true, isName("var.foo", version), "name", version);
 119         }


  79             for(SourceVersion version : SourceVersion.values()) {
  80                 boolean isKeyword = version.compareTo(value) >= 0;
  81 
  82                 check(isKeyword,  isKeyword(key, version), "keyword", version);
  83                 check(!isKeyword, isName(key, version),    "name",    version);
  84             }
  85         }
  86     }
  87 
  88     private static void testRestrictedKeywords() {
  89         // Restricted keywords are not full keywords
  90 
  91         /*
  92          * JLS 3.9
  93          * " A further ten character sequences are restricted
  94          * keywords: open, module, requires, transitive, exports,
  95          * opens, to, uses, provides, and with"
  96          */
  97         Set<String> restrictedKeywords =
  98             Set.of("open", "module", "requires", "transitive", "exports",
  99                    "opens", "to", "uses", "provides", "with",
 100                    // Assume "record" and "sealed" will be restricted keywords.
 101                    "record", "sealed");
 102 
 103         for(String key : restrictedKeywords) {
 104             for(SourceVersion version : SourceVersion.values()) {
 105                 check(false, isKeyword(key, version), "keyword", version);
 106                 check(true,  isName(key, version),    "name",    version);
 107             }
 108         }
 109     }
 110 
 111     private static void testVar() {
 112 
 113         for(SourceVersion version : SourceVersion.values()) {
 114             check(false, isKeyword("var",     version), "keyword", version);
 115             check(false, isKeyword("foo.var", version), "keyword", version);
 116             check(false, isKeyword("var.foo", version), "keyword", version);
 117 
 118             check(true, isName("var", version),     "name", version);
 119             check(true, isName("foo.var", version), "name", version);
 120             check(true, isName("var.foo", version), "name", version);
 121         }
< prev index next >