Skip to content

Commit e6e4d87

Browse files
committed
[GR-16414] Add ENV#{filter,filter!} aliases.
PullRequest: truffleruby/890
2 parents 1a6aa8d + 20e723c commit e6e4d87

File tree

6 files changed

+284
-245
lines changed

6 files changed

+284
-245
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ Compatibility:
1313
* Implemented `Integer#{allbits?,anybits?,nobits?}`.
1414
* `Integer#{ceil,floor,truncate}` now accept a precision and `Integer#round` accepts a rounding mode.
1515
* Added missing `Enumerable#filter` and `Enumerator::Lazy#filter` aliases to the respective `select` method (#1610).
16-
* Implement more `Ripper` methods as no-ops (#1694).
16+
* Implemented more `Ripper` methods as no-ops (#1694).
1717
* Implemented `rb_enc_sprintf` (#1702).
18+
* Implemented `ENV#{filter,filter!}` aliases for `select` and `select!`.
1819

1920
Changes:
2021

spec/tags/core/env/filter_tags.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

spec/tags/truffle/methods_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ fails:Public methods on String should not include find_character
5858
fails:Public methods on String should not include shorten!
5959
fails:Public methods on String should not include substring
6060
fails:Public methods on String should not include to_sub_replacement
61+
fails:Public methods on ENV.singleton_class should include slice
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[]
2+
[]=
3+
assoc
4+
clear
5+
delete
6+
delete_if
7+
each
8+
each_key
9+
each_pair
10+
each_value
11+
empty?
12+
fetch
13+
filter
14+
filter!
15+
has_key?
16+
has_value?
17+
include?
18+
index
19+
inspect
20+
invert
21+
keep_if
22+
key
23+
key?
24+
keys
25+
length
26+
member?
27+
rassoc
28+
rehash
29+
reject
30+
reject!
31+
replace
32+
select
33+
select!
34+
shift
35+
size
36+
slice
37+
store
38+
to_a
39+
to_h
40+
to_hash
41+
to_s
42+
update
43+
value?
44+
values
45+
values_at

spec/truffle/methods_spec.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@
1616
# but instead of jt untag, jt purge must be used to remove tags:
1717
# $ jt purge spec/truffle/methods_spec.rb
1818

19-
modules = [
20-
BasicObject, Kernel, Object,
21-
Module, Class,
22-
Enumerable, Enumerator, Enumerator::Lazy, Range,
23-
Numeric, Integer, Float,
24-
Rational, Complex,
25-
Array, Hash, String,
26-
File, IO,
19+
modules = %w[
20+
BasicObject Kernel Object
21+
Module Class
22+
Enumerable Enumerator Enumerator::Lazy Range
23+
Numeric Integer Float
24+
Rational Complex
25+
Array Hash String
26+
File IO
27+
ENV.singleton_class
2728
]
2829

2930
guard -> { !defined?(SlowSpecsTagger) } do
3031
if RUBY_ENGINE == "ruby"
3132
modules.each do |mod|
32-
file = File.expand_path("../methods/#{mod.name}.txt", __FILE__)
33+
file = File.expand_path("../methods/#{mod}.txt", __FILE__)
3334
methods = ruby_exe("puts #{mod}.public_instance_methods(false).sort")
3435
methods = methods.lines.map { |line| line.chomp.to_sym }
3536
contents = methods.map { |meth| "#{meth}\n" }.join
@@ -39,8 +40,8 @@
3940

4041
code = <<-EOR
4142
#{modules.inspect}.each { |m|
42-
puts m.name
43-
puts m.public_instance_methods(false).sort
43+
puts m
44+
puts eval(m).public_instance_methods(false).sort
4445
puts
4546
}
4647
EOR
@@ -51,10 +52,10 @@
5152
end
5253

5354
modules.each do |mod|
54-
describe "Public methods on #{mod.name}" do
55-
file = File.expand_path("../methods/#{mod.name}.txt", __FILE__)
55+
describe "Public methods on #{mod}" do
56+
file = File.expand_path("../methods/#{mod}.txt", __FILE__)
5657
expected = File.readlines(file).map { |line| line.chomp.to_sym }
57-
methods = all_methods[mod.name]
58+
methods = all_methods[mod]
5859

5960
if methods == expected
6061
it "are the same as on MRI" do

0 commit comments

Comments
 (0)