Search in sources :

Example 1 with LocationFactory

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

the class LocationTest method testDeleteDeclaredProperty.

@Test
public void testDeleteDeclaredProperty() {
    DynamicObject object = rootShape.newInstance();
    object.define("a", new Object(), 0, new LocationFactory() {

        public Location createLocation(Shape shape, Object value) {
            return shape.allocator().declaredLocation(value);
        }
    });
    Assert.assertTrue(object.containsKey("a"));
    object.define("a", 42);
    Assert.assertEquals(1, object.getShape().getPropertyCount());
    object.delete("a");
    Assert.assertFalse(object.containsKey("a"));
}
Also used : Shape(com.oracle.truffle.api.object.Shape) DynamicObject(com.oracle.truffle.api.object.DynamicObject) DynamicObject(com.oracle.truffle.api.object.DynamicObject) LocationFactory(com.oracle.truffle.api.object.LocationFactory) Location(com.oracle.truffle.api.object.Location) ObjectLocation(com.oracle.truffle.api.object.ObjectLocation) Test(org.junit.Test)

Aggregations

DynamicObject (com.oracle.truffle.api.object.DynamicObject)1 Location (com.oracle.truffle.api.object.Location)1 LocationFactory (com.oracle.truffle.api.object.LocationFactory)1 ObjectLocation (com.oracle.truffle.api.object.ObjectLocation)1 Shape (com.oracle.truffle.api.object.Shape)1 Test (org.junit.Test)1