@@ -227,16 +227,18 @@ end
227227
228228local function testVFS ()
229229 local file = ' test_vfs_dir/lines.txt'
230+ local nosuchfile = ' test_vfs_dir/nosuchfile'
230231 testing .expectEqual (vfs .fileExists (file ), true , ' lines.txt should exist' )
231- testing .expectEqual (vfs .fileExists (' test_vfs_dir/ nosuchfile' ), false , ' nosuchfile should not exist' )
232+ testing .expectEqual (vfs .fileExists (nosuchfile ), false , ' nosuchfile should not exist' )
232233
234+ local expectedLines = { ' 1' , ' 2' , ' ' , ' 4' }
233235 local getLine = vfs .lines (file )
234- for _ ,v in pairs ({ ' 1 ' , ' 2 ' , ' ' , ' 4 ' } ) do
236+ for _ ,v in pairs (expectedLines ) do
235237 testing .expectEqual (getLine (), v )
236238 end
237239 testing .expectEqual (getLine (), nil , ' All lines should have been read' )
238240 local ok = pcall (function ()
239- vfs .lines (' test_vfs_dir/ nosuchfile' )
241+ vfs .lines (nosuchfile )
240242 end )
241243 testing .expectEqual (ok , false , ' Should not be able to read lines from nonexistent file' )
242244
@@ -259,6 +261,14 @@ local function testVFS()
259261
260262 testing .expectEqual (handle :close (), true , ' File should be closeable' )
261263 testing .expectEqual (vfs .type (handle ), ' closed file' , ' File should be closed' )
264+
265+ handle = vfs .open (nosuchfile )
266+ testing .expectEqual (handle , nil , ' vfs.open should return nil on nonexistent files' )
267+
268+ getLine = vfs .open (file ):lines ()
269+ for _ ,v in pairs (expectedLines ) do
270+ testing .expectEqual (getLine (), v )
271+ end
262272end
263273
264274local function testCommitCrime ()
0 commit comments