use of com.oracle.truffle.api.object.Location 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.Location 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.Location 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());
}
use of com.oracle.truffle.api.object.Location in project graal by oracle.
the class LocationTest method testLocationDecoratorEquals.
@Test
public void testLocationDecoratorEquals() {
Allocator allocator = rootShape.allocator();
Location intLocation1 = allocator.locationForType(int.class);
Location intLocation2 = allocator.locationForType(int.class);
Assert.assertEquals(intLocation1.getClass(), intLocation2.getClass());
Assert.assertNotEquals(intLocation1, intLocation2);
}
use of com.oracle.truffle.api.object.Location in project graal by oracle.
the class LocationTest method testChangeFlagsChangeLocation.
@Test
public void testChangeFlagsChangeLocation() {
DynamicObject object = rootShape.newInstance();
object.define("foo", 42);
Location location = object.getShape().getProperty("foo").getLocation();
object.define("foo", "str", 111);
Assert.assertEquals("str", object.get("foo"));
Property newProperty = object.getShape().getProperty("foo");
Assert.assertEquals(111, newProperty.getFlags());
Location newLocation = newProperty.getLocation();
Assert.assertNotSame(location, newLocation);
}
Aggregations