mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Expect bool as sort:
option at glob [Feature #18287]
This commit is contained in:
parent
6896324465
commit
89b440bf72
Notes:
git
2021-11-18 21:47:39 +09:00
Merged: https://github.com/ruby/ruby/pull/5084 Merged-By: nobu <nobu@ruby-lang.org>
4 changed files with 20 additions and 1 deletions
|
@ -3858,6 +3858,7 @@ debug_counter.$(OBJEXT): {$(VPATH)}thread_native.h
|
||||||
dir.$(OBJEXT): $(hdrdir)/ruby.h
|
dir.$(OBJEXT): $(hdrdir)/ruby.h
|
||||||
dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
|
dir.$(OBJEXT): $(hdrdir)/ruby/ruby.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/array.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/array.h
|
||||||
|
dir.$(OBJEXT): $(top_srcdir)/internal/class.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/compilers.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/compilers.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/dir.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/dir.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/encoding.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/encoding.h
|
||||||
|
@ -3865,6 +3866,7 @@ dir.$(OBJEXT): $(top_srcdir)/internal/error.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/file.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/file.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/gc.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/gc.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/io.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/io.h
|
||||||
|
dir.$(OBJEXT): $(top_srcdir)/internal/object.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/serial.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/serial.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/static_assert.h
|
||||||
dir.$(OBJEXT): $(top_srcdir)/internal/string.h
|
dir.$(OBJEXT): $(top_srcdir)/internal/string.h
|
||||||
|
@ -3888,6 +3890,7 @@ dir.$(OBJEXT): {$(VPATH)}dir.rbinc
|
||||||
dir.$(OBJEXT): {$(VPATH)}encindex.h
|
dir.$(OBJEXT): {$(VPATH)}encindex.h
|
||||||
dir.$(OBJEXT): {$(VPATH)}encoding.h
|
dir.$(OBJEXT): {$(VPATH)}encoding.h
|
||||||
dir.$(OBJEXT): {$(VPATH)}id.h
|
dir.$(OBJEXT): {$(VPATH)}id.h
|
||||||
|
dir.$(OBJEXT): {$(VPATH)}id_table.h
|
||||||
dir.$(OBJEXT): {$(VPATH)}intern.h
|
dir.$(OBJEXT): {$(VPATH)}intern.h
|
||||||
dir.$(OBJEXT): {$(VPATH)}internal.h
|
dir.$(OBJEXT): {$(VPATH)}internal.h
|
||||||
dir.$(OBJEXT): {$(VPATH)}internal/anyargs.h
|
dir.$(OBJEXT): {$(VPATH)}internal/anyargs.h
|
||||||
|
|
3
dir.c
3
dir.c
|
@ -112,6 +112,7 @@ char *strchr(char*,char);
|
||||||
#include "internal/file.h"
|
#include "internal/file.h"
|
||||||
#include "internal/gc.h"
|
#include "internal/gc.h"
|
||||||
#include "internal/io.h"
|
#include "internal/io.h"
|
||||||
|
#include "internal/object.h"
|
||||||
#include "internal/vm.h"
|
#include "internal/vm.h"
|
||||||
#include "ruby/encoding.h"
|
#include "ruby/encoding.h"
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
|
@ -2937,7 +2938,7 @@ dir_glob_option_base(VALUE base)
|
||||||
static int
|
static int
|
||||||
dir_glob_option_sort(VALUE sort)
|
dir_glob_option_sort(VALUE sort)
|
||||||
{
|
{
|
||||||
return (sort ? 0 : FNM_GLOB_NOSORT);
|
return (rb_bool_expected(sort, "sort") ? 0 : FNM_GLOB_NOSORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
|
@ -55,6 +55,15 @@ describe :dir_glob, shared: true do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
ruby_version_is "3.1" do
|
||||||
|
it "true or false is expected as sort:" do
|
||||||
|
-> {Dir.send(@method, '*', sort: nil)}.should raise_error ArgumentError, /true or false/
|
||||||
|
-> {Dir.send(@method, '*', sort: 0)}.should raise_error ArgumentError, /true or false/
|
||||||
|
-> {Dir.send(@method, '*', sort: "")}.should raise_error ArgumentError, /true or false/
|
||||||
|
-> {Dir.send(@method, '*', sort: Object.new)}.should raise_error ArgumentError, /true or false/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "matches non-dotfiles with '*'" do
|
it "matches non-dotfiles with '*'" do
|
||||||
expected = %w[
|
expected = %w[
|
||||||
brace
|
brace
|
||||||
|
|
|
@ -176,6 +176,12 @@ class TestDir < Test::Unit::TestCase
|
||||||
assert_raise_with_message(ArgumentError, /nul-separated/) do
|
assert_raise_with_message(ArgumentError, /nul-separated/) do
|
||||||
Dir.glob(@root + "\0\0\0" + File.join(@root, "*"))
|
Dir.glob(@root + "\0\0\0" + File.join(@root, "*"))
|
||||||
end
|
end
|
||||||
|
assert_raise_with_message(ArgumentError, /expected true or false/) do
|
||||||
|
Dir.glob(@root, sort: 1)
|
||||||
|
end
|
||||||
|
assert_raise_with_message(ArgumentError, /expected true or false/) do
|
||||||
|
Dir.glob(@root, sort: nil)
|
||||||
|
end
|
||||||
|
|
||||||
assert_equal(("a".."z").step(2).map {|f| File.join(File.join(@root, f), "") },
|
assert_equal(("a".."z").step(2).map {|f| File.join(File.join(@root, f), "") },
|
||||||
Dir.glob(File.join(@root, "*/")))
|
Dir.glob(File.join(@root, "*/")))
|
||||||
|
|
Loading…
Add table
Reference in a new issue