Skip to content

Commit

Permalink
converted test-fs-read.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaozg committed May 1, 2015
1 parent fb514af commit ebea0d6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 46 deletions.
2 changes: 1 addition & 1 deletion tests/test-fs-exists.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require('tap')(function(test)

local f = module.path

test('fs.exists empty', function()
test('fs.exists', function()
-- TODO: Is it OK that this callback signature is different from node.js,
-- which is function(exists)?
FS.exists(f, function(err, y)
Expand Down
43 changes: 43 additions & 0 deletions tests/test-fs-read.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--[[
Copyright 2012-2015 The Luvit Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License")
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS-IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--]]

require('tap')(function(test)
local math = require('math')
local string = require('string')
local FS = require('fs')
local Path = require('path')

test('fs.read and fs.readSync', function()
local filepath = Path.join(module.dir, 'fixtures', 'x.txt')
print(filepath)
local fd = FS.openSync(filepath, 'r')
local expected = 'xyz\n'
local readCalled = 0

FS.read(fd, #expected, 0, function(err, str, bytesRead)
readCalled = readCalled + 1
assert(not err)
assert(str == expected)
assert(#str == #expected)
end)

local r,e = FS.readSync(fd, #expected, 0)
assert(r == expected)
assert(#r == #expected)
end)
end)
45 changes: 0 additions & 45 deletions tests/to-convert/test-fs-read.lua

This file was deleted.

0 comments on commit ebea0d6

Please sign in to comment.