Skip to content
Snippets Groups Projects
Commit f18c38c2 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

remove unnecessary "0x00" byte during save

parent c2530788
Branches
No related tags found
No related merge requests found
......@@ -236,7 +236,7 @@ public class LoadSaveFunctions {
if (!ascii && openConn.isTextMode()) {
throw error(RError.Message.CONN_XDR);
}
openConn.writeChar(ascii ? ASCII_HEADER : XDR_HEADER, 0, "", false);
openConn.writeChar(ascii ? ASCII_HEADER : XDR_HEADER, 0, null, false);
RSerialize.serialize(openConn, toSave, ascii ? RSerialize.ASCII : RSerialize.XDR, RSerialize.DEFAULT_VERSION, null);
} catch (IOException ex) {
throw error(RError.Message.GENERIC, ex.getMessage());
......
......@@ -76896,7 +76896,24 @@ Error in cat(x, file = file, sep = c(rep.int(sep, ncolumns - 1), "\n"), :
#{ rv <- charToRaw("Hello"); rc <- rawConnection(rv, "r+"); writeChar(", World", rc); res <- rawToChar(rawConnectionValue(rc)); close(rc); res }
[1] ", World"
 
##com.oracle.truffle.r.test.library.base.TestConnections.testRawWriteBinary#Ignored.Unknown#
##com.oracle.truffle.r.test.library.base.TestConnections.testRawWriteBinary#Ignored.ImplementationError#
#conn <- rawConnection(raw(0), "w"); value <- c(1,2,3); save(value, file=conn); rawConnectionValue(conn)
[1] 52 44 58 32 0a 58 0a 00 00 00 02 00 03 03 02 00 02 03 00 00 00 04 02 00 00
[26] 00 01 00 04 00 09 00 00 00 05 76 61 6c 75 65 00 00 00 0e 00 00 00 03 3f f0
[51] 00 00 00 00 00 00 40 00 00 00 00 00 00 00 40 08 00 00 00 00 00 00 00 00 00
[76] fe
##com.oracle.truffle.r.test.library.base.TestConnections.testRawWriteBinary#Ignored.ImplementationError#
#conn <- rawConnection(raw(0), "wb"); value <- list(a=c(1,2,3), b='foo'); save(value, file=conn); rawConnectionValue(conn)
[1] 52 44 58 32 0a 58 0a 00 00 00 02 00 03 03 02 00 02 03 00 00 00 04 02 00 00
[26] 00 01 00 04 00 09 00 00 00 05 76 61 6c 75 65 00 00 02 13 00 00 00 02 00 00
[51] 00 0e 00 00 00 03 3f f0 00 00 00 00 00 00 40 00 00 00 00 00 00 00 40 08 00
[76] 00 00 00 00 00 00 00 00 10 00 00 00 01 00 04 00 09 00 00 00 03 66 6f 6f 00
[101] 00 04 02 00 00 00 01 00 04 00 09 00 00 00 05 6e 61 6d 65 73 00 00 00 10 00
[126] 00 00 02 00 04 00 09 00 00 00 01 61 00 04 00 09 00 00 00 01 62 00 00 00 fe
[151] 00 00 00 fe
##com.oracle.truffle.r.test.library.base.TestConnections.testRawWriteBinary#Ignored.ImplementationError#
#{ s <- "äöüß"; rc <- rawConnection(raw(0), "wb"); write(charToRaw(s), rc); res <- rawConnectionValue(rc); close(rc); res }
[1] 63 33 20 61 34 20 63 33 20 62 36 20 63 33 0a 62 63 20 63 33 20 39 66 0a
 
......@@ -241,8 +241,12 @@ public class TestConnections extends TestRBase {
public void testRawWriteBinary() {
// this test is currently ignored, since 'charToRaw' is not compliant
assertEval(Ignored.Unknown, "{ s <- \"äöüß\"; rc <- rawConnection(raw(0), \"wb\"); write(charToRaw(s), rc); res <- rawConnectionValue(rc); close(rc); res }");
assertEval(Ignored.ImplementationError, "{ s <- \"äöüß\"; rc <- rawConnection(raw(0), \"wb\"); write(charToRaw(s), rc); res <- rawConnectionValue(rc); close(rc); res }");
assertEval("{ zz <- rawConnection(raw(0), \"wb\"); x <- c(\"a\", \"this will be truncated\", \"abc\"); nc <- c(3, 10, 3); writeChar(x, zz, nc, eos = NULL); writeChar(x, zz, eos = \"\\r\\n\"); res <- rawConnectionValue(zz); close(zz); res }");
assertEval(Ignored.ImplementationError, "conn <- rawConnection(raw(0), \"wb\"); value <- list(a=c(1,2,3), b='foo'); save(value, file=conn); rawConnectionValue(conn)");
// ignored because save refuses to write to a rawConnection that is not configured to binary
assertEval(Ignored.ImplementationError, "conn <- rawConnection(raw(0), \"w\"); value <- c(1,2,3); save(value, file=conn); rawConnectionValue(conn)");
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment