diff --git a/Rakefile b/Rakefile index fd44e2b51..d0668cd36 100644 --- a/Rakefile +++ b/Rakefile @@ -82,7 +82,7 @@ FileList["test/stdlib/**/*_test.rb"].each do |test| end end -task :stdlib_test do +task :stdlib_test => :compile do test_files = FileList["test/stdlib/**/*_test.rb"].reject do |path| path =~ %r{Ractor} end diff --git a/core/builtin.rbs b/core/builtin.rbs index f0120b6d2..5482071df 100644 --- a/core/builtin.rbs +++ b/core/builtin.rbs @@ -99,6 +99,7 @@ type real = Integer | Float | Rational type string = String | _ToStr type encoding = Encoding | string +type path = string | _ToPath type io = IO | _ToIO diff --git a/core/dir.rbs b/core/dir.rbs index ebd422f27..a04ca4e0b 100644 --- a/core/dir.rbs +++ b/core/dir.rbs @@ -102,7 +102,7 @@ class Dir # The optional *encoding* keyword argument specifies the encoding of the # directory. If not specified, the filesystem encoding is used. # - def initialize: (string, ?encoding: encoding | nil) -> void + def initialize: (path dir, ?encoding: encoding?) -> self # # Equivalent to calling `Dir.glob([`*string,...*`], 0)`. # - def self.[]: (*string patterns, ?base: string) ?{ (String path) -> void } -> Array[String] + def self.[]: (*path patterns, ?base: path?, ?sort: bool) -> Array[String] # # Returns `true` if the named file is a directory, `false` otherwise. # - def self.exist?: (string file) -> bool + def self.exist?: (path | _ToIO file_name) -> bool # # Returns the home directory of the current user or the named user if given. # - def self.home: (?string user) -> String + def self.home: (?string? user) -> String # # Returns the path parameter passed to *dir*'s constructor. diff --git a/test/stdlib/Dir_test.rb b/test/stdlib/Dir_test.rb index 241fc7cec..f52abee0c 100644 --- a/test/stdlib/Dir_test.rb +++ b/test/stdlib/Dir_test.rb @@ -24,10 +24,6 @@ def test_square_bracket Dir, :[], "*/*" assert_send_type "(::ToStr) -> ::Array[::String]", Dir, :[], ToStr.new("*/*") - assert_send_type "(::String) { (::String) -> void } -> Array[String]", - Dir, :[], "*/*" do end - assert_send_type "(::String, ::String, base: ::String) -> ::Array[::String]", - Dir, :[], "*/*", "*", base: __dir__ end def test_chdir