Sha256: 3477893051792db82e142e6ba4232606903ad47951c40e84fa75a51c03828545

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

# Copied from cruby and modified to skip unsupported syntaxes
require 'test/unit'
require 'nodejs'
require 'nodejs/dir'

class TestNodejsDir < Test::Unit::TestCase

  def tmpdir
    `require('os').tmpdir()`
  end

  def test_dir_entries
    path = tmpdir + "/testing_nodejs_dir_entries_implementation_#{Time.now.to_i}"
    Dir.mkdir(path)
    result = Dir.entries(path)
    assert_equal(result.length, 0)
    File.open(path + '/bar', "w") {}
    File.open(path + '/baz', "w") {}
    result = Dir.entries(path)
    assert_equal(result.length, 2)
  end
  
  def test_dir_glob
    path = tmpdir + "/testing_nodejs_dir_glob_implementation_#{Time.now.to_i}"
    Dir.mkdir(path)
    result = Dir.glob(path + '/*')
    assert_equal(result.length, 0)
    File.open(path + '/bar', "w") {}
    File.open(path + '/baz', "w") {}
    result = Dir.glob(path + '/ba*')
    assert_equal(result.length, 2)
    result = Dir.glob(path + '/*z')
    assert_equal(result.length, 1)
    result = Dir.glob([path + '/baz', path + '/bar'])
    assert_equal(result.length, 2)
    result = Dir.glob(Pathname.new(path).join('*'))
    assert_equal(result.length, 2)
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
opal-1.7.4 test/nodejs/test_dir.rb
opal-1.7.3 test/nodejs/test_dir.rb
opal-1.7.2 test/nodejs/test_dir.rb
opal-1.7.1 test/nodejs/test_dir.rb
opal-1.7.0 test/nodejs/test_dir.rb
opal-1.7.0.rc1 test/nodejs/test_dir.rb
opal-1.6.1 test/nodejs/test_dir.rb
opal-1.6.0 test/nodejs/test_dir.rb
opal-1.6.0.rc1 test/nodejs/test_dir.rb
opal-1.6.0.alpha1 test/nodejs/test_dir.rb
opal-1.5.1 test/nodejs/test_dir.rb
opal-1.5.0 test/nodejs/test_dir.rb
opal-1.5.0.rc1 test/nodejs/test_dir.rb
opal-1.4.1 test/nodejs/test_dir.rb
opal-1.4.0 test/nodejs/test_dir.rb
opal-1.4.0.alpha1 test/nodejs/test_dir.rb
opal-1.3.2 test/nodejs/test_dir.rb
opal-1.3.1 test/nodejs/test_dir.rb
opal-1.3.0 test/nodejs/test_dir.rb
opal-1.3.0.rc1 test/nodejs/test_dir.rb