1 package runtime.valhalla.valuetypes;
   2 
   3 import jdk.test.lib.Asserts;
   4 
   5 /*
   6  * @test ValueTypeCreation
   7  * @summary Value Type creation test
   8  * @library /testlibrary /
   9  * @run main/othervm -noverify -Xint runtime.valhalla.valuetypes.ValueTypeCreation
  10  */
  11 public class ValueTypeCreation {
  12     public static void main(String[] args) {
  13         ValueTypeCreation valueTypeCreation = new ValueTypeCreation();
  14         valueTypeCreation.run();
  15     }
  16 
  17     public void run() {
  18         testPoint();
  19         testLong8();
  20         // Embedded oops not yet supported
  21         //testPerson();
  22     }
  23 
  24     void testPoint() {
  25         Point p = Point.createPoint(1, 2);
  26         Asserts.assertEquals(p.x, 1, "invalid point x value");
  27         Asserts.assertEquals(p.y, 2, "invalid point y value");
  28         Point p2 = clonePoint(p);
  29         Asserts.assertEquals(p2.x, 1, "invalid point clone x value");
  30         Asserts.assertEquals(p2.y, 2, "invalid point clone y value");
  31     }
  32 
  33     static Point clonePoint(Point p) {
  34         Point q = p;
  35         return q;
  36     }
  37 
  38     void testLong8() {
  39         Long8Value long8Value = Long8Value.create(1, 2, 3, 4, 5, 6, 7, 8);
  40         Asserts.assertEquals(long8Value.getLongField1(), 1L, "Field 1 incorrect");
  41         Asserts.assertEquals(long8Value.getLongField8(), 8L, "Field 8 incorrect");
  42         Long8Value.check(long8Value, 1, 2, 3, 4, 5, 6, 7, 8);
  43     }
  44 
  45     void testPerson() {
  46         Person person = Person.create(1, "John", "Smith");
  47         Asserts.assertEquals(person.getId(), 1L, "Id field incorrect");
  48         Asserts.assertEquals(person.getFirstName(), "John", "First name incorrect");
  49         Asserts.assertEquals(person.getLastName(), "Smith", "Last name incorrect");
  50     }
  51 }