-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GR-45621] Promote Set class to core library
PullRequest: truffleruby/4135
- Loading branch information
Showing
9 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require_relative '../../spec_helper' | ||
require_relative 'fixtures/classes' | ||
|
||
ruby_version_is "3.2" do | ||
describe "Enumerable#to_set" do | ||
it "returns a new Set created from self" do | ||
[1, 2, 3].to_set.should == Set[1, 2, 3] | ||
{a: 1, b: 2}.to_set.should == Set[[:b, 2], [:a, 1]] | ||
end | ||
|
||
it "passes down passed blocks" do | ||
[1, 2, 3].to_set { |x| x * x }.should == Set[1, 4, 9] | ||
end | ||
|
||
it "instantiates an object of provided as the first argument set class" do | ||
set = [1, 2, 3].to_set(EnumerableSpecs::SetSubclass) | ||
set.should be_kind_of(EnumerableSpecs::SetSubclass) | ||
set.to_a.sort.should == [1, 2, 3] | ||
end | ||
|
||
it "does not need explicit `require 'set'`" do | ||
output = ruby_exe(<<~RUBY, options: '--disable-gems', args: '2>&1') | ||
puts [1, 2, 3].to_set | ||
RUBY | ||
|
||
output.chomp.should == "#<Set: {1, 2, 3}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require_relative '../../spec_helper' | ||
|
||
describe 'Set' do | ||
ruby_version_is '3.2' do | ||
it 'is available without explicit requiring' do | ||
output = ruby_exe(<<~RUBY, options: '--disable-gems', args: '2>&1') | ||
puts Set.new([1, 2, 3]) | ||
RUBY | ||
output.chomp.should == "#<Set: {1, 2, 3}>" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
slow:Enumerable#to_set does not need explicit `require 'set'` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
slow:Set is available without explicit requiring |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters