@@ -4733,22 +4733,33 @@ struct lines
47334733 auto deleteMe = testFilename();
47344734 scope (exit) { imported! " std.file" .remove(deleteMe); }
47354735
4736- auto f = File (deleteMe, " r" );
4737- scope (exit) { f.close(); }
4736+ // Setup
4737+ {
4738+ auto f = File (deleteMe, " w" );
4739+ scope (exit) { f.close(); }
4740+ foreach (i; 1 .. 11 )
4741+ f.writeln(i);
4742+ }
47384743
4739- auto myLines = lines(f);
4740- foreach (string line; myLines)
4741- continue ;
4744+ // Actual tests
4745+ {
4746+ auto f = File (deleteMe, " r" );
4747+ scope (exit) { f.close(); }
47424748
4743- auto myByLineCopy = f.byLineCopy; // but cannot safely iterate yet
4744- /*
4745- still `@system`:
4746- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.empty`
4747- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.popFront`
4748- - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.front`
4749- */
4750- // foreach (line; myByLineCopy)
4751- // continue;
4749+ auto myLines = lines(f);
4750+ foreach (string line; myLines)
4751+ continue ;
4752+
4753+ auto myByLineCopy = f.byLineCopy; // but cannot safely iterate yet
4754+ /*
4755+ still `@system`:
4756+ - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.empty`
4757+ - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.popFront`
4758+ - cannot call `@system` function `std.stdio.File.ByLineCopy!(immutable(char), char).ByLineCopy.front`
4759+ */
4760+ // foreach (line; myByLineCopy)
4761+ // continue;
4762+ }
47524763}
47534764
47544765@system unittest
0 commit comments