Skip to content

Commit

Permalink
Merge pull request #292 from hnakamur/test-fs-exists
Browse files Browse the repository at this point in the history
tests: test-fs-exists ported from node.js
  • Loading branch information
rphillips committed Aug 12, 2012
2 parents 109d8ce + a27c0a2 commit 69bb0ea
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/test-fs-exists.lua
@@ -0,0 +1,46 @@
--[[
Copyright 2012 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("helper")
local FS = require('fs')
local Path = require('path')
local f = __filename
local exists
local doesNotExist
-- TODO: Is it OK that this callback signature is different from node.js,
-- which is function(exists)?
FS.exists(f, function(err, y)
exists = y
-- p("exists=" .. tostring(exists))
end)
FS.exists(f .. '-NO', function(err, y)
doesNotExist = y
-- p("doesNotExist=" .. tostring(doesNotExist))
end)
assert(FS.existsSync(f))
assert(not FS.existsSync(f .. '-NO'))
process:on('exit', function()
assert(exists == true)
assert(doesNotExist == false)
end)

0 comments on commit 69bb0ea

Please sign in to comment.