< prev index next >

test/langtools/jdk/jshell/TypeNameTest.java

Print this page
rev 52865 : [mq]: 8210031


 175         assertType("extFboundArr()[0]", "List<? extends Comparable<?>>");
 176         assertType("extFboundArr()[0].get(0)", "Comparable<?>");
 177         assertType("supFboundArr()", "List<?>[]");
 178         assertType("supFboundArr()[0]", "List<?>");
 179         assertType("supFboundArr()[0].get(0)", "Object");
 180         assertType("extFboundIter()", "Iterable<? extends List<? extends Comparable<?>>>");
 181         assertType("extFboundIter().iterator()", "java.util.Iterator<? extends List<? extends Comparable<?>>>");
 182         assertType("extFboundIter().iterator().next()", "List<? extends Comparable<?>>");
 183         assertType("extFboundIter().iterator().next().get(0)", "Comparable<?>");
 184         assertType("supFboundIter()", "Iterable<? extends List<?>>");
 185         assertType("supFboundIter().iterator()", "java.util.Iterator<? extends List<?>>");
 186         assertType("supFboundIter().iterator().next()", "List<?>");
 187         assertType("supFboundIter().iterator().next().get(0)", "Object");
 188         assertType("listOf(23)", "List<Integer>");
 189         assertType("listOf(true)", "List<Boolean>");
 190         assertType("listOf(true).get(0)", "Boolean");
 191         assertType("arrayOf(99)", "Integer[]");
 192         assertType("arrayOf(99)[0]", "Integer");
 193 
 194         assertEval("<Z> Z choose(Z z1, Z z2) { return z1; }");
 195         assertType("choose(1, 1L);", "Number&Comparable<? extends Number&Comparable<?>>", "Object");


 196     }
 197 
 198     public void testVariableTypeName() {
 199         assertType("\"x\"", "String");
 200 
 201         assertType("java.util.regex.Pattern.compile(\"x\")", "java.util.regex.Pattern");
 202         assertEval("import java.util.regex.*;");
 203         assertType("java.util.regex.Pattern.compile(\"x\")", "Pattern");
 204 
 205         assertType("new java.util.ArrayList()", "java.util.ArrayList");
 206         assertEval("import java.util.ArrayList;");
 207         assertType("new java.util.ArrayList()", "ArrayList");
 208 
 209         assertType("java.util.Locale.Category.FORMAT", "java.util.Locale.Category");
 210         assertEval("import static java.util.Locale.Category;");
 211         assertType("java.util.Locale.Category.FORMAT", "Category");
 212     }
 213 
 214     public void testReplNestedClassName() {
 215         assertEval("class D { static class E {} }");




 175         assertType("extFboundArr()[0]", "List<? extends Comparable<?>>");
 176         assertType("extFboundArr()[0].get(0)", "Comparable<?>");
 177         assertType("supFboundArr()", "List<?>[]");
 178         assertType("supFboundArr()[0]", "List<?>");
 179         assertType("supFboundArr()[0].get(0)", "Object");
 180         assertType("extFboundIter()", "Iterable<? extends List<? extends Comparable<?>>>");
 181         assertType("extFboundIter().iterator()", "java.util.Iterator<? extends List<? extends Comparable<?>>>");
 182         assertType("extFboundIter().iterator().next()", "List<? extends Comparable<?>>");
 183         assertType("extFboundIter().iterator().next().get(0)", "Comparable<?>");
 184         assertType("supFboundIter()", "Iterable<? extends List<?>>");
 185         assertType("supFboundIter().iterator()", "java.util.Iterator<? extends List<?>>");
 186         assertType("supFboundIter().iterator().next()", "List<?>");
 187         assertType("supFboundIter().iterator().next().get(0)", "Object");
 188         assertType("listOf(23)", "List<Integer>");
 189         assertType("listOf(true)", "List<Boolean>");
 190         assertType("listOf(true).get(0)", "Boolean");
 191         assertType("arrayOf(99)", "Integer[]");
 192         assertType("arrayOf(99)[0]", "Integer");
 193 
 194         assertEval("<Z> Z choose(Z z1, Z z2) { return z1; }");
 195         assertType("choose(1, 1L);",
 196                   "Number&Comparable<? extends Number&Comparable<?>&java.lang.constant.Constable&java.lang.constant.ConstantDesc>&java.lang.constant.Constable&java.lang.constant.ConstantDesc",
 197                 "Object");
 198     }
 199 
 200     public void testVariableTypeName() {
 201         assertType("\"x\"", "String");
 202 
 203         assertType("java.util.regex.Pattern.compile(\"x\")", "java.util.regex.Pattern");
 204         assertEval("import java.util.regex.*;");
 205         assertType("java.util.regex.Pattern.compile(\"x\")", "Pattern");
 206 
 207         assertType("new java.util.ArrayList()", "java.util.ArrayList");
 208         assertEval("import java.util.ArrayList;");
 209         assertType("new java.util.ArrayList()", "ArrayList");
 210 
 211         assertType("java.util.Locale.Category.FORMAT", "java.util.Locale.Category");
 212         assertEval("import static java.util.Locale.Category;");
 213         assertType("java.util.Locale.Category.FORMAT", "Category");
 214     }
 215 
 216     public void testReplNestedClassName() {
 217         assertEval("class D { static class E {} }");


< prev index next >