use of com.oracle.truffle.api.object.Shape in project graal by oracle.
the class ImplicitCastTest method testIntObject.
@Test
public void testIntObject() {
Shape rootShape = layout.createShape(new ObjectType());
DynamicObject object = rootShape.newInstance();
object.define("a", intVal);
object.define("a", "");
Location location = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(Object.class, getLocationType(location));
Assert.assertEquals(String.class, object.get("a").getClass());
}
use of com.oracle.truffle.api.object.Shape in project graal by oracle.
the class SharedShapeTest method testShapeIsSharedAndIdentity.
@Test
public void testShapeIsSharedAndIdentity() {
DynamicObject object = rootShape.newInstance();
Assert.assertEquals(false, rootShape.isShared());
Assert.assertSame(sharedShape, rootShape.makeSharedShape());
Assert.assertEquals(true, sharedShape.isShared());
object.setShapeAndGrow(rootShape, sharedShape);
object.define("a", 1);
final Shape sharedShapeWithA = object.getShape();
Assert.assertEquals(true, sharedShapeWithA.isShared());
DynamicObject object2 = rootShape.newInstance();
object2.setShapeAndGrow(rootShape, sharedShape);
object2.define("a", 1);
Assert.assertSame(sharedShapeWithA, object2.getShape());
// Currently, sharing is a transition and transitions do not commute magically
DynamicObject object3 = rootShape.newInstance();
object3.define("a", 1);
object3.setShapeAndGrow(object3.getShape(), object3.getShape().makeSharedShape());
Assert.assertNotSame(sharedShapeWithA, object3.getShape());
}
use of com.oracle.truffle.api.object.Shape in project graal by oracle.
the class ImplicitCastTest method testIntOtherDoesNotGoBack.
@Test
public void testIntOtherDoesNotGoBack() {
Shape rootShape = layout.createShape(new ObjectType());
DynamicObject object = rootShape.newInstance();
object.define("a", intVal);
Location location1 = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(int.class, getLocationType(location1));
object.define("a", otherVal);
Location location2 = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(otherPrimClass, getLocationType(location2));
Assert.assertEquals(otherVal.getClass(), object.get("a").getClass());
DOTestAsserts.assertSameLocation(location1, location2);
object.define("a", intVal);
Location location3 = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(otherPrimClass, getLocationType(location3));
Assert.assertEquals(otherVal.getClass(), object.get("a").getClass());
DOTestAsserts.assertSameLocation(location2, location3);
}
use of com.oracle.truffle.api.object.Shape in project graal by oracle.
the class ImplicitCastTest method testIntOther.
@Test
public void testIntOther() {
Shape rootShape = layout.createShape(new ObjectType());
DynamicObject object = rootShape.newInstance();
object.define("a", intVal);
Location location1 = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(int.class, getLocationType(location1));
object.define("a", otherVal);
Location location2 = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(otherPrimClass, getLocationType(location2));
Assert.assertEquals(otherVal.getClass(), object.get("a").getClass());
DOTestAsserts.assertSameLocation(location1, location2);
}
use of com.oracle.truffle.api.object.Shape in project graal by oracle.
the class ImplicitCastTest method testIntOtherObject.
@Test
public void testIntOtherObject() {
Shape rootShape = layout.createShape(new ObjectType());
DynamicObject object = rootShape.newInstance();
object.define("a", intVal);
object.define("a", otherVal);
object.define("a", "");
Location location = object.getShape().getProperty("a").getLocation();
Assert.assertEquals(Object.class, getLocationType(location));
Assert.assertEquals(String.class, object.get("a").getClass());
}
Aggregations