Skip to content

Commit

Permalink
Update record IO tests to no longer use <~>
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Harshbarger <ben.harshb@gmail.com>
  • Loading branch information
benharsh committed Jun 13, 2022
1 parent 3115744 commit 00dc68f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
9 changes: 7 additions & 2 deletions test/io/ferguson/recordeof.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@ proc MyRecord.writeThis(f) throws {
}

proc MyRecord.readWriteHelper(f) throws {
f <~> i;
f <~> new ioLiteral("\n");
var nl = new ioLiteral("\n");
if f.writing then
f.write(i);
else
f.readIt(i);

if f.writing then f.write(nl); else f.read(nl);
}

{
Expand Down
2 changes: 1 addition & 1 deletion test/io/ferguson/recordeof.good
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
recordeof.chpl:30: warning: reader with a style argument is deprecated
recordeof.chpl:35: warning: reader with a style argument is deprecated
Done
21 changes: 12 additions & 9 deletions test/io/recordio.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ var B: [0..#3] MyRecord;
- f is a Writer or a Reader
- the compiler will generate readThis/writeThis for you if you don't
provide one
- the I/O operator <~> is available to read or write (depending
on which situation we are being called in). This operator will soon
be deprecated
*/
proc MyRecord.readThis(f) throws {
readWriteHelper(f);
Expand All @@ -100,20 +97,26 @@ proc MyRecord.writeThis(f) throws {
}

proc MyRecord.readWriteHelper(f) throws {
f <~> i;
f <~> new ioLiteral("\t");
f <~> r;
f <~> new ioLiteral("\t");
var tab = new ioLiteral("\t");
var nl = new ioLiteral("\n");
if f.writing then
f.write(i, tab, r, tab);
else
f.read(i, tab, r, tab);

// When doing the string I/O, we need to specify that we'd like
// the string to be single-quoted. Unfortunately, readf is
// not currently available on a Reader, so we have to rely
// on the caller setting the string formatting with the channel's
// style.
// In the future, we hope to allow readf in this situation.
f <~> s;
// TODO: 'f.read' isn't respecting the desire for single-quotes
if f.writing then
f.write(s);
else
f.readIt(s);

f <~> new ioLiteral("\n");
if f.writing then f.write(nl); else f.read(nl);
}

{
Expand Down
2 changes: 1 addition & 1 deletion test/io/recordio.good
Original file line number Diff line number Diff line change
@@ -1 +1 @@
recordio.chpl:122: warning: reader with a style argument is deprecated
recordio.chpl:124: warning: reader with a style argument is deprecated

0 comments on commit 00dc68f

Please sign in to comment.