Search in sources :

Example 6 with MutableTruffleString

use of com.oracle.truffle.api.strings.MutableTruffleString in project graal by oracle.

the class TStringAsManagedTest method testAll.

@Test
public void testAll() throws Exception {
    forAllStrings(true, (a, array, codeRange, isValid, encoding, codepoints, byteIndices) -> {
        TruffleString b = node.execute(a, encoding);
        MutableTruffleString bMutable = nodeMutable.execute(a, encoding);
        assertBytesEqual(bMutable, encoding, array);
        if (a instanceof MutableTruffleString) {
            ((MutableTruffleString) a).writeByteUncached(0, (byte) 123, encoding);
        }
        assertBytesEqual(b, encoding, array);
        Assert.assertFalse(b.isNative());
        Assert.assertFalse(bMutable.isNative());
    });
}
Also used : TruffleString(com.oracle.truffle.api.strings.TruffleString) MutableTruffleString(com.oracle.truffle.api.strings.MutableTruffleString) MutableTruffleString(com.oracle.truffle.api.strings.MutableTruffleString) Test(org.junit.Test)

Example 7 with MutableTruffleString

use of com.oracle.truffle.api.strings.MutableTruffleString in project graal by oracle.

the class TStringAsTruffleStringTest method testAll.

@Test
public void testAll() throws Exception {
    forAllStrings(true, (a, array, codeRange, isValid, encoding, codepoints, byteIndices) -> {
        TruffleString b = node.execute(a, encoding);
        if (a instanceof MutableTruffleString) {
            ((MutableTruffleString) a).writeByteUncached(0, (byte) 123, encoding);
            assertBytesEqual(b, encoding, array);
        } else {
            Assert.assertSame(a, b);
        }
    });
}
Also used : TruffleString(com.oracle.truffle.api.strings.TruffleString) MutableTruffleString(com.oracle.truffle.api.strings.MutableTruffleString) MutableTruffleString(com.oracle.truffle.api.strings.MutableTruffleString) Test(org.junit.Test)

Aggregations

MutableTruffleString (com.oracle.truffle.api.strings.MutableTruffleString)7 Test (org.junit.Test)7 TruffleString (com.oracle.truffle.api.strings.TruffleString)6