< prev index next >

test/jdk/java/lang/constant/TypeDescriptorTest.java

Print this page




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.lang.invoke.TypeDescriptor;
  25 import java.lang.constant.ClassDesc;
  26 
  27 import org.testng.annotations.Test;
  28 
  29 import static java.lang.constant.ConstantDescs.*;
  30 import static org.testng.Assert.assertEquals;
  31 import static org.testng.Assert.assertFalse;
  32 import static org.testng.Assert.assertNull;
  33 import static org.testng.Assert.assertTrue;
  34 
  35 /**
  36  * @test
  37  * @compile TypeDescriptorTest.java
  38  * @run testng TypeDescriptorTest
  39  * @summary unit tests for implementations of java.lang.invoke.TypeDescriptor
  40  */
  41 @Test
  42 public class TypeDescriptorTest {
  43     private<F extends TypeDescriptor.OfField<F>> void testArray(F f, boolean isArray, F component, F array) {
  44         if (isArray) {
  45             assertTrue(f.isArray());
  46             assertEquals(f.arrayType(), array);
  47             assertEquals(f.componentType(), component);
  48         }
  49         else {
  50             assertFalse(f.isArray());
  51             assertEquals(f.arrayType(), array);
  52             assertNull(f.componentType());
  53         }
  54     }
  55 
  56     public void testClass() {
  57         testArray(int.class, false, null, int[].class);




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 import java.lang.invoke.TypeDescriptor;
  25 import java.lang.constant.ClassDesc;
  26 
  27 import org.testng.annotations.Test;
  28 
  29 import static java.lang.constant.ConstantDescs.*;
  30 import static org.testng.Assert.assertEquals;
  31 import static org.testng.Assert.assertFalse;
  32 import static org.testng.Assert.assertNull;
  33 import static org.testng.Assert.assertTrue;
  34 
  35 /**
  36  * @test
  37  * @compile -XDfolding=false TypeDescriptorTest.java
  38  * @run testng TypeDescriptorTest
  39  * @summary unit tests for implementations of java.lang.invoke.TypeDescriptor
  40  */
  41 @Test
  42 public class TypeDescriptorTest {
  43     private<F extends TypeDescriptor.OfField<F>> void testArray(F f, boolean isArray, F component, F array) {
  44         if (isArray) {
  45             assertTrue(f.isArray());
  46             assertEquals(f.arrayType(), array);
  47             assertEquals(f.componentType(), component);
  48         }
  49         else {
  50             assertFalse(f.isArray());
  51             assertEquals(f.arrayType(), array);
  52             assertNull(f.componentType());
  53         }
  54     }
  55 
  56     public void testClass() {
  57         testArray(int.class, false, null, int[].class);


< prev index next >