Search in sources :

Example 16 with DynamicObject

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

the class TypesTest method testBoolean.

@Test
public void testBoolean() {
    final DynamicObject object = create();
    Assert.assertEquals(true, LAYOUT.getB(object));
    LAYOUT.setB(object, false);
    Assert.assertEquals(false, LAYOUT.getB(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 17 with DynamicObject

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

the class TypesTest method testLong.

@Test
public void testLong() {
    final DynamicObject object = create();
    Assert.assertEquals(4, LAYOUT.getL(object));
    LAYOUT.setL(object, 40);
    Assert.assertEquals(40, LAYOUT.getL(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 18 with DynamicObject

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

the class VolatileTest method testCompareAndSetSuccess.

@Test
public void testCompareAndSetSuccess() {
    final DynamicObject object = LAYOUT.createVolatileTest(14, null);
    Assert.assertEquals(14, LAYOUT.getVolatileInt(object));
    Assert.assertTrue(LAYOUT.compareAndSetVolatileInt(object, 14, 22));
    Assert.assertEquals(22, LAYOUT.getVolatileInt(object));
    Assert.assertNull(LAYOUT.getVolatileThread(object));
    Assert.assertTrue(LAYOUT.compareAndSetVolatileThread(object, null, Thread.currentThread()));
    Assert.assertEquals(Thread.currentThread(), LAYOUT.getVolatileThread(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 19 with DynamicObject

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

the class VolatileTest method testCompareAndSetFailure.

@Test
public void testCompareAndSetFailure() {
    final DynamicObject object = LAYOUT.createVolatileTest(14, null);
    Assert.assertEquals(14, LAYOUT.getVolatileInt(object));
    Assert.assertFalse(LAYOUT.compareAndSetVolatileInt(object, 44, 22));
    Assert.assertNull(LAYOUT.getVolatileThread(object));
    Assert.assertFalse(LAYOUT.compareAndSetVolatileThread(object, Thread.currentThread(), Thread.currentThread()));
    Assert.assertNull(LAYOUT.getVolatileThread(object));
}
Also used : DynamicObject(com.oracle.truffle.api.object.DynamicObject) Test(org.junit.Test)

Example 20 with DynamicObject

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

the class VolatileTest method testGetVolatile.

@Test
public void testGetVolatile() {
    final DynamicObject object = LAYOUT.createVolatileTest(14, null);
    Assert.assertEquals(14, LAYOUT.getVolatileInt(object));
    Assert.assertNull(LAYOUT.getVolatileThread(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