Search in sources :

Example 1 with DynamicObject

use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.

the class InheritedShapePropertiesTest method testTop.

@Test
public void testTop() {
    final DynamicObjectFactory factory = TOP_LAYOUT.createInheritedShapeTopShape(14, 2);
    final DynamicObject object = TOP_LAYOUT.createInheritedShapeTop(factory);
    Assert.assertEquals(14, TOP_LAYOUT.getA(object));
    Assert.assertEquals(2, TOP_LAYOUT.getB(object));
}
Also used : DynamicObjectFactory(com.oracle.truffle.api.object.DynamicObjectFactory) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 2 with DynamicObject

use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.

the class InheritedShapePropertiesTest method testBase.

@Test
public void testBase() {
    final DynamicObjectFactory factory = BASE_LAYOUT.createInheritedShapeBaseShape(14);
    final DynamicObject object = BASE_LAYOUT.createInheritedShapeBase(factory);
    Assert.assertEquals(14, BASE_LAYOUT.getA(object));
}
Also used : DynamicObjectFactory(com.oracle.truffle.api.object.DynamicObjectFactory) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 3 with DynamicObject

use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.

the class NullabilityTest method testCreateAlllowedNull.

@Test
public void testCreateAlllowedNull() {
    final DynamicObject object = LAYOUT.createNullabilityTest("foo", null);
    Assert.assertNotNull(object);
    Assert.assertEquals("foo", LAYOUT.getNotNullable(object));
    Assert.assertNull(LAYOUT.getNullable(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 4 with DynamicObject

use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.

the class NullabilityTest method testCreateNonNull.

@Test
public void testCreateNonNull() {
    final DynamicObject object = LAYOUT.createNullabilityTest("foo", "bar");
    Assert.assertNotNull(object);
    Assert.assertEquals("foo", LAYOUT.getNotNullable(object));
    Assert.assertEquals("bar", LAYOUT.getNullable(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 5 with DynamicObject

use of com.oracle.truffle.api.object.DynamicObject in project graal by oracle.

the class NullabilityTest method testSetNullableToNull.

@Test
public void testSetNullableToNull() {
    final DynamicObject object = LAYOUT.createNullabilityTest("foo", "bar");
    Assert.assertNotNull(object);
    Assert.assertEquals("bar", LAYOUT.getNullable(object));
    LAYOUT.setNullable(object, null);
    Assert.assertNull(LAYOUT.getNullable(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Aggregations

DynamicObject (com.oracle.truffle.api.object.DynamicObject)100 Test (org.junit.Test)91 Location (com.oracle.truffle.api.object.Location)17 Shape (com.oracle.truffle.api.object.Shape)16 DynamicObjectFactory (com.oracle.truffle.api.object.DynamicObjectFactory)8 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)7 Property (com.oracle.truffle.api.object.Property)7 ObjectType (com.oracle.truffle.api.object.ObjectType)6 IncompatibleLocationException (com.oracle.truffle.api.object.IncompatibleLocationException)4 Layout (com.oracle.truffle.api.object.Layout)4 FinalLocationException (com.oracle.truffle.api.object.FinalLocationException)2 PropertyBuilder (com.oracle.truffle.object.dsl.processor.model.PropertyBuilder)2 VariableElement (javax.lang.model.element.VariableElement)2 LocationFactory (com.oracle.truffle.api.object.LocationFactory)1 ShapeImpl (com.oracle.truffle.object.ShapeImpl)1 DefaultLayoutFactory (com.oracle.truffle.object.basic.DefaultLayoutFactory)1 PrintStream (java.io.PrintStream)1 ArrayList (java.util.ArrayList)1 IdentityHashMap (java.util.IdentityHashMap)1