Search in sources :

Example 31 with DynamicObject

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

the class IdentifierTest method testContainsKey.

@Test
public void testContainsKey() {
    final DynamicObject object = LAYOUT.createIdentifierTest(1, 2);
    Assert.assertTrue(object.containsKey(IdentifierTestLayout.A_IDENTIFIER));
    Assert.assertTrue(object.containsKey(IdentifierTestLayout.B_IDENTIFIER));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 32 with DynamicObject

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

the class IdentifierTest method testHasProperty.

@Test
public void testHasProperty() {
    final DynamicObject object = LAYOUT.createIdentifierTest(1, 2);
    Assert.assertTrue(object.getShape().hasProperty(IdentifierTestLayout.A_IDENTIFIER));
    Assert.assertTrue(object.getShape().hasProperty(IdentifierTestLayout.B_IDENTIFIER));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 33 with DynamicObject

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

the class IdentifierTest method testGet.

@Test
public void testGet() {
    final DynamicObject object = LAYOUT.createIdentifierTest(1, 2);
    Assert.assertEquals(1, object.get(IdentifierTestLayout.A_IDENTIFIER));
    Assert.assertEquals(2, object.get(IdentifierTestLayout.B_IDENTIFIER));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 34 with DynamicObject

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

the class ImplicitCastTest method testCanAssignIntToDouble.

@Test
public void testCanAssignIntToDouble() {
    final DynamicObject object = CAST_LAYOUT.createCast(14, 14.2);
    final Shape shapeBefore = object.getShape();
    assertTrue(object.set(CastLayout.DOUBLE_VALUE_IDENTIFIER, 14));
    assertEquals(shapeBefore, object.getShape());
}
Also used : Shape(com.oracle.truffle.api.object.Shape) DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 35 with DynamicObject

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

the class ImplicitCastTest method testCantAssignIntToDouble.

@Test(expected = IncompatibleLocationException.class)
public void testCantAssignIntToDouble() throws IncompatibleLocationException, FinalLocationException {
    final DynamicObject object = NO_CAST_LAYOUT.createNoCast(14, 14.2);
    object.getShape().getProperty(NoCastLayout.DOUBLE_VALUE_IDENTIFIER).set(object, 14, object.getShape());
}
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