Skip to content
This repository
Browse code

tests: test-readdir: initial commit

seeing some readdir stuff that is weird in virgo. write a readdir test
for luvit.
  • Loading branch information...
commit 76809b381999f407f716056f5564db708ca714de 1 parent c4570f3
Brandon Philips philips authored

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. +38 0 tests/test-readdir.lua
38 tests/test-readdir.lua
... ... @@ -0,0 +1,38 @@
  1 +--[[
  2 +
  3 +Copyright 2012 The Luvit Authors. All Rights Reserved.
  4 +
  5 +Licensed under the Apache License, Version 2.0 (the "License");
  6 +you may not use this file except in compliance with the License.
  7 +You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 +Unless required by applicable law or agreed to in writing, software
  12 +distributed under the License is distributed on an "AS-IS" BASIS,
  13 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 +See the License for the specific language governing permissions and
  15 +limitations under the License.
  16 +
  17 +--]]
  18 +
  19 +require("helper")
  20 +local path = require('path')
  21 +local fs = require('fs')
  22 +
  23 +local dir = path.join(__dirname, 'tmp', 'readdir')
  24 +if not fs.existsSync(dir) then
  25 + fs.mkdirSync(dir, "0755")
  26 +end
  27 +
  28 +fs.writeFileSync(path.join(dir, "1"), "")
  29 +fs.writeFileSync(path.join(dir, "2"), "")
  30 +fs.writeFileSync(path.join(dir, "3"), "")
  31 +
  32 +local files = fs.readdirSync(dir)
  33 +assert(#files == 3)
  34 +
  35 +fs.readdir(dir, function(err, files)
  36 + assert(err == nil)
  37 + assert(#files == 3)
  38 +end)

0 comments on commit 76809b3

Please sign in to comment.
Something went wrong with that request. Please try again.