Skip to content

Commit a3531da

Browse files
committed
[GR-14806] Update specs
PullRequest: truffleruby/4044
2 parents e2b5200 + 4b9e6e8 commit a3531da

File tree

89 files changed

+1445
-251
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1445
-251
lines changed

spec/mspec/tool/tag_from_output.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
if spec_file
3333
spec_file = spec_file[SPEC_FILE, 1] or raise
3434
else
35-
if error_line =~ /^(\w+)[#\.](\w+) /
36-
module_method = error_line.split(' ', 2).first
37-
file = "#{$1.downcase}/#{$2}_spec.rb"
35+
if error_line =~ /^([\w:]+)[#\.](\w+) /
36+
mod, method = $1, $2
37+
file = "#{mod.downcase.gsub('::', '/')}/#{method}_spec.rb"
3838
spec_file = ['spec/ruby/core', 'spec/ruby/library', *Dir.glob('spec/ruby/library/*')].find { |dir|
3939
path = "#{dir}/#{file}"
4040
break path if File.exist?(path)

spec/ruby/.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ Lint/AssignmentInCondition:
3333
Lint/BooleanSymbol:
3434
Enabled: false
3535

36+
Lint/DeprecatedOpenSSLConstant:
37+
Exclude:
38+
- library/openssl/digest/**/*.rb
39+
3640
Lint/InterpolationCheck:
3741
Enabled: false
3842

spec/ruby/CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ In case there is a bug in MRI and the fix will be backported to previous version
179179
If it is not backported or not likely, use `ruby_version_is` instead.
180180
First, file a bug at https://bugs.ruby-lang.org/.
181181
The problem is `ruby_bug` would make non-MRI implementations fail this spec while MRI itself does not pass it, so it should only be used if the bug is/will be fixed and backported.
182+
Otherwise, non-MRI implementations would have to choose between being incompatible with the latest release of MRI to pass the spec or fail the spec, both which make no sense.
182183

183184
```ruby
184185
ruby_bug '#13669', ''...'3.2' do

spec/ruby/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ MSpec can automatically add new top-level constants in this file with:
128128

129129
$ CHECK_LEAKS=save mspec ../mspec/bin/mspec file
130130

131+
### Running Specs on S390x CPU Architecture
132+
133+
Run the specs with `DFLTCC=0` if you see failing specs related to the zlib library on s390x CPU architecture. The failures can happen with the zlib library applying the patch madler/zlib#410 to enable the deflate algorithm producing a different compressed byte stream.
134+
135+
$ DFLTCC=0 ../mspec/bin/mspec
136+
131137
### Contributing and Writing Specs
132138

133139
See [CONTRIBUTING.md](https://github.com/ruby/spec/blob/master/CONTRIBUTING.md) for documentation about contributing and writing specs (guards, matchers, etc).

spec/ruby/core/array/bsearch_index_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@
6363
@array.bsearch_index { |x| -1 }.should be_nil
6464
end
6565

66-
it "returns the middle element when block always returns zero" do
67-
@array.bsearch_index { |x| 0 }.should == 2
68-
end
69-
7066
context "magnitude does not effect the result" do
7167
it "returns the index of any matched elements where element is between 4n <= xn < 8n" do
7268
[1, 2].should include(@array.bsearch_index { |x| (1 - x / 4) * (2**100) })

spec/ruby/core/dir/glob_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@
106106
ruby_version_is '3.1' do
107107
it "recursively matches files and directories in nested dot subdirectory except . with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
108108
expected = %w[
109-
nested/.
110-
nested/.dotsubir
111-
nested/.dotsubir/.dotfile
112-
nested/.dotsubir/nondotfile
113-
]
109+
nested/.
110+
nested/.dotsubir
111+
nested/.dotsubir/.dotfile
112+
nested/.dotsubir/nondotfile
113+
]
114114

115115
Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
116116
end

spec/ruby/core/dir/home_spec.rb

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,21 @@
4040
home.should == "C:/rubyspäc/home"
4141
home.encoding.should == Encoding::UTF_8
4242
end
43-
end
4443

45-
it "retrieves the directory from HOME, USERPROFILE, HOMEDRIVE/HOMEPATH and the WinAPI in that order" do
46-
old_dirs = [ENV.delete('HOME'), ENV.delete('USERPROFILE'), ENV.delete('HOMEDRIVE'), ENV.delete('HOMEPATH')]
44+
it "retrieves the directory from HOME, USERPROFILE, HOMEDRIVE/HOMEPATH and the WinAPI in that order" do
45+
old_dirs = [ENV.delete('HOME'), ENV.delete('USERPROFILE'), ENV.delete('HOMEDRIVE'), ENV.delete('HOMEPATH')]
4746

48-
Dir.home.should == old_dirs[1].gsub("\\", "/")
49-
ENV['HOMEDRIVE'] = "C:"
50-
ENV['HOMEPATH'] = "\\rubyspec\\home1"
51-
Dir.home.should == "C:/rubyspec/home1"
52-
ENV['USERPROFILE'] = "C:\\rubyspec\\home2"
53-
# https://bugs.ruby-lang.org/issues/19244
54-
# Dir.home.should == "C:/rubyspec/home2"
55-
ENV['HOME'] = "C:\\rubyspec\\home3"
56-
Dir.home.should == "C:/rubyspec/home3"
57-
ensure
58-
ENV['HOME'], ENV['USERPROFILE'], ENV['HOMEDRIVE'], ENV['HOMEPATH'] = *old_dirs
47+
Dir.home.should == old_dirs[1].gsub("\\", "/")
48+
ENV['HOMEDRIVE'] = "C:"
49+
ENV['HOMEPATH'] = "\\rubyspec\\home1"
50+
Dir.home.should == "C:/rubyspec/home1"
51+
ENV['USERPROFILE'] = "C:\\rubyspec\\home2"
52+
Dir.home.should == "C:/rubyspec/home2"
53+
ENV['HOME'] = "C:\\rubyspec\\home3"
54+
Dir.home.should == "C:/rubyspec/home3"
55+
ensure
56+
ENV['HOME'], ENV['USERPROFILE'], ENV['HOMEDRIVE'], ENV['HOMEPATH'] = *old_dirs
57+
end
5958
end
6059
end
6160
end

spec/ruby/core/file/new_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@
188188
}.should raise_error(Errno::EEXIST, /File exists/)
189189
end
190190

191+
it "does not use the given block and warns to use File::open" do
192+
-> {
193+
@fh = File.new(@file) { raise }
194+
}.should complain(/warning: File::new\(\) does not take block; use File::open\(\) instead/)
195+
end
196+
191197
it "raises a TypeError if the first parameter can't be coerced to a string" do
192198
-> { File.new(true) }.should raise_error(TypeError)
193199
-> { File.new(false) }.should raise_error(TypeError)

spec/ruby/core/file/shared/fnmatch.rb

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102

103103
it "matches ranges of characters using exclusive bracket expression (e.g. [^t] or [!t])" do
104104
File.send(@method, 'ca[^t]', 'cat').should == false
105+
File.send(@method, 'ca[^t]', 'cas').should == true
105106
File.send(@method, 'ca[!t]', 'cat').should == false
106107
end
107108

@@ -125,6 +126,13 @@
125126
end
126127
end
127128

129+
it "matches wildcard with characters when flags includes FNM_PATHNAME" do
130+
File.send(@method, '*a', 'aa', File::FNM_PATHNAME).should == true
131+
File.send(@method, 'a*', 'aa', File::FNM_PATHNAME).should == true
132+
File.send(@method, 'a*', 'aaa', File::FNM_PATHNAME).should == true
133+
File.send(@method, '*a', 'aaa', File::FNM_PATHNAME).should == true
134+
end
135+
128136
it "does not match '/' characters with ? or * when flags includes FNM_PATHNAME" do
129137
File.send(@method, '?', '/', File::FNM_PATHNAME).should == false
130138
File.send(@method, '*', '/', File::FNM_PATHNAME).should == false
@@ -165,9 +173,19 @@
165173
File.should_not.send(@method, '*/*', 'dave/.profile', File::FNM_PATHNAME)
166174
end
167175

168-
it "matches patterns with leading periods to dotfiles by default" do
176+
it "matches patterns with leading periods to dotfiles" do
169177
File.send(@method, '.*', '.profile').should == true
178+
File.send(@method, '.*', '.profile', File::FNM_PATHNAME).should == true
170179
File.send(@method, ".*file", "nondotfile").should == false
180+
File.send(@method, ".*file", "nondotfile", File::FNM_PATHNAME).should == false
181+
end
182+
183+
it "does not match directories with leading periods by default with FNM_PATHNAME" do
184+
File.send(@method, '.*', '.directory/nondotfile', File::FNM_PATHNAME).should == false
185+
File.send(@method, '.*', '.directory/.profile', File::FNM_PATHNAME).should == false
186+
File.send(@method, '.*', 'foo/.directory/nondotfile', File::FNM_PATHNAME).should == false
187+
File.send(@method, '.*', 'foo/.directory/.profile', File::FNM_PATHNAME).should == false
188+
File.send(@method, '**/.dotfile', '.dotsubdir/.dotfile', File::FNM_PATHNAME).should == false
171189
end
172190

173191
it "matches leading periods in filenames when flags includes FNM_DOTMATCH" do
@@ -221,6 +239,33 @@
221239
File.send(@method, pattern, 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
222240
end
223241

242+
it "has special handling for ./ when using * and FNM_PATHNAME" do
243+
File.send(@method, './*', '.', File::FNM_PATHNAME).should be_false
244+
File.send(@method, './*', './', File::FNM_PATHNAME).should be_true
245+
File.send(@method, './*/', './', File::FNM_PATHNAME).should be_false
246+
File.send(@method, './**', './', File::FNM_PATHNAME).should be_true
247+
File.send(@method, './**/', './', File::FNM_PATHNAME).should be_true
248+
File.send(@method, './*', '.', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false
249+
File.send(@method, './*', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
250+
File.send(@method, './*/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false
251+
File.send(@method, './**', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
252+
File.send(@method, './**/', './', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
253+
end
254+
255+
it "matches **/* with FNM_PATHNAME to recurse directories" do
256+
File.send(@method, 'nested/**/*', 'nested/subdir', File::FNM_PATHNAME).should be_true
257+
File.send(@method, 'nested/**/*', 'nested/subdir/file', File::FNM_PATHNAME).should be_true
258+
File.send(@method, 'nested/**/*', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
259+
File.send(@method, 'nested/**/*', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
260+
end
261+
262+
it "matches ** with FNM_PATHNAME only in current directory" do
263+
File.send(@method, 'nested/**', 'nested/subdir', File::FNM_PATHNAME).should be_true
264+
File.send(@method, 'nested/**', 'nested/subdir/file', File::FNM_PATHNAME).should be_false
265+
File.send(@method, 'nested/**', 'nested/.dotsubdir', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_true
266+
File.send(@method, 'nested/**', 'nested/.dotsubir/.dotfile', File::FNM_PATHNAME | File::FNM_DOTMATCH).should be_false
267+
end
268+
224269
it "accepts an object that has a #to_path method" do
225270
File.send(@method, '\*', mock_to_path('a')).should == false
226271
end

spec/ruby/core/io/gets_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
end
2525
end
2626

27+
it "sets $_ to nil after the last line has been read" do
28+
while @io.gets
29+
end
30+
$_.should be_nil
31+
end
32+
2733
it "returns nil if called at the end of the stream" do
2834
IOSpecs.lines.length.times { @io.gets }
2935
@io.gets.should == nil

0 commit comments

Comments
 (0)