rubysl-set 0.0.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +0 -1
- data/.travis.yml +8 -0
- data/README.md +2 -2
- data/Rakefile +0 -1
- data/lib/rubysl/set.rb +2 -0
- data/lib/rubysl/set/set.rb +1237 -0
- data/lib/{rubysl-set → rubysl/set}/version.rb +1 -1
- data/lib/set.rb +1 -0
- data/rubysl-set.gemspec +19 -18
- data/spec/add_spec.rb +26 -0
- data/spec/append_spec.rb +6 -0
- data/spec/classify_spec.rb +34 -0
- data/spec/clear_spec.rb +16 -0
- data/spec/collect_spec.rb +6 -0
- data/spec/constructor_spec.rb +14 -0
- data/spec/delete_if_spec.rb +45 -0
- data/spec/delete_spec.rb +36 -0
- data/spec/difference_spec.rb +6 -0
- data/spec/divide_spec.rb +33 -0
- data/spec/each_spec.rb +33 -0
- data/spec/empty_spec.rb +9 -0
- data/spec/enumerable/to_set_spec.rb +18 -0
- data/spec/eql_spec.rb +16 -0
- data/spec/equal_value_spec.rb +37 -0
- data/spec/exclusion_spec.rb +17 -0
- data/spec/flatten_merge_spec.rb +22 -0
- data/spec/flatten_spec.rb +39 -0
- data/spec/hash_spec.rb +14 -0
- data/spec/include_spec.rb +6 -0
- data/spec/initialize_copy_spec.rb +17 -0
- data/spec/initialize_spec.rb +23 -0
- data/spec/inspect_spec.rb +17 -0
- data/spec/intersection_spec.rb +10 -0
- data/spec/keep_if_spec.rb +39 -0
- data/spec/length_spec.rb +6 -0
- data/spec/map_spec.rb +6 -0
- data/spec/member_spec.rb +6 -0
- data/spec/merge_spec.rb +18 -0
- data/spec/minus_spec.rb +6 -0
- data/spec/plus_spec.rb +6 -0
- data/spec/pretty_print_cycle_spec.rb +9 -0
- data/spec/pretty_print_spec.rb +16 -0
- data/spec/proper_subset_spec.rb +33 -0
- data/spec/proper_superset_spec.rb +33 -0
- data/spec/reject_spec.rb +49 -0
- data/spec/replace_spec.rb +16 -0
- data/spec/select_spec.rb +43 -0
- data/spec/shared/add.rb +14 -0
- data/spec/shared/collect.rb +20 -0
- data/spec/shared/difference.rb +15 -0
- data/spec/shared/include.rb +7 -0
- data/spec/shared/intersection.rb +15 -0
- data/spec/shared/length.rb +6 -0
- data/spec/shared/union.rb +15 -0
- data/spec/size_spec.rb +6 -0
- data/spec/sortedset/add_spec.rb +34 -0
- data/spec/sortedset/append_spec.rb +6 -0
- data/spec/sortedset/classify_spec.rb +34 -0
- data/spec/sortedset/clear_spec.rb +16 -0
- data/spec/sortedset/collect_spec.rb +6 -0
- data/spec/sortedset/constructor_spec.rb +14 -0
- data/spec/sortedset/delete_if_spec.rb +47 -0
- data/spec/sortedset/delete_spec.rb +36 -0
- data/spec/sortedset/difference_spec.rb +6 -0
- data/spec/sortedset/divide_spec.rb +33 -0
- data/spec/sortedset/each_spec.rb +35 -0
- data/spec/sortedset/empty_spec.rb +9 -0
- data/spec/sortedset/eql_spec.rb +17 -0
- data/spec/sortedset/equal_value_spec.rb +12 -0
- data/spec/sortedset/exclusion_spec.rb +17 -0
- data/spec/sortedset/flatten_merge_spec.rb +7 -0
- data/spec/sortedset/flatten_spec.rb +47 -0
- data/spec/sortedset/hash_spec.rb +14 -0
- data/spec/sortedset/include_spec.rb +6 -0
- data/spec/sortedset/initialize_copy_spec.rb +17 -0
- data/spec/sortedset/initialize_spec.rb +31 -0
- data/spec/sortedset/inspect_spec.rb +9 -0
- data/spec/sortedset/intersection_spec.rb +10 -0
- data/spec/sortedset/keep_if_spec.rb +32 -0
- data/spec/sortedset/length_spec.rb +6 -0
- data/spec/sortedset/map_spec.rb +6 -0
- data/spec/sortedset/member_spec.rb +6 -0
- data/spec/sortedset/merge_spec.rb +18 -0
- data/spec/sortedset/minus_spec.rb +6 -0
- data/spec/sortedset/plus_spec.rb +6 -0
- data/spec/sortedset/pretty_print_cycle_spec.rb +9 -0
- data/spec/sortedset/pretty_print_spec.rb +16 -0
- data/spec/sortedset/proper_subset_spec.rb +32 -0
- data/spec/sortedset/proper_superset_spec.rb +32 -0
- data/spec/sortedset/reject_spec.rb +51 -0
- data/spec/sortedset/replace_spec.rb +16 -0
- data/spec/sortedset/select_spec.rb +36 -0
- data/spec/sortedset/shared/add.rb +14 -0
- data/spec/sortedset/shared/collect.rb +20 -0
- data/spec/sortedset/shared/difference.rb +15 -0
- data/spec/sortedset/shared/include.rb +7 -0
- data/spec/sortedset/shared/intersection.rb +15 -0
- data/spec/sortedset/shared/length.rb +6 -0
- data/spec/sortedset/shared/union.rb +15 -0
- data/spec/sortedset/size_spec.rb +6 -0
- data/spec/sortedset/subset_spec.rb +32 -0
- data/spec/sortedset/subtract_spec.rb +16 -0
- data/spec/sortedset/superset_spec.rb +32 -0
- data/spec/sortedset/to_a_spec.rb +7 -0
- data/spec/sortedset/union_spec.rb +10 -0
- data/spec/subset_spec.rb +33 -0
- data/spec/subtract_spec.rb +16 -0
- data/spec/superset_spec.rb +33 -0
- data/spec/to_a_spec.rb +7 -0
- data/spec/union_spec.rb +10 -0
- metadata +282 -86
- data/lib/rubysl-set.rb +0 -7
data/lib/set.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "rubysl/set"
|
data/rubysl-set.gemspec
CHANGED
@@ -1,22 +1,23 @@
|
|
1
|
-
#
|
2
|
-
require
|
1
|
+
# coding: utf-8
|
2
|
+
require './lib/rubysl/set/version'
|
3
3
|
|
4
|
-
Gem::Specification.new do |
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "rubysl-set"
|
6
|
+
spec.version = RubySL::Set::VERSION
|
7
|
+
spec.authors = ["Brian Shirai"]
|
8
|
+
spec.email = ["brixen@gmail.com"]
|
9
|
+
spec.description = %q{Ruby standard library set.}
|
10
|
+
spec.summary = %q{Ruby standard library set.}
|
11
|
+
spec.homepage = "https://github.com/rubysl/rubysl-set"
|
12
|
+
spec.license = "BSD"
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
gem.require_paths = ["lib"]
|
16
|
-
gem.version = RubySL::Set::VERSION
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_development_dependency "mspec", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
|
22
23
|
end
|
data/spec/add_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'set'
|
2
|
+
require File.expand_path('../shared/add', __FILE__)
|
3
|
+
|
4
|
+
describe "Set#add" do
|
5
|
+
it_behaves_like :set_add, :add
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Set#add?" do
|
9
|
+
before :each do
|
10
|
+
@set = Set.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "adds the passed Object to self" do
|
14
|
+
@set.add?("cat")
|
15
|
+
@set.should include("cat")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns self when the Object has not yet been added to self" do
|
19
|
+
@set.add?("cat").should equal(@set)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns nil when the Object has already been added to self" do
|
23
|
+
@set.add?("cat")
|
24
|
+
@set.add?("cat").should be_nil
|
25
|
+
end
|
26
|
+
end
|
data/spec/append_spec.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#classify" do
|
4
|
+
before(:each) do
|
5
|
+
@set = Set["one", "two", "three", "four"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "yields each Object in self" do
|
9
|
+
res = []
|
10
|
+
@set.classify { |x| res << x }
|
11
|
+
res.sort.should == ["one", "two", "three", "four"].sort
|
12
|
+
end
|
13
|
+
|
14
|
+
ruby_version_is "" ... "1.8.8" do
|
15
|
+
it "raises a LocalJumpError when passed no block" do
|
16
|
+
lambda { @set.classify }.should raise_error(LocalJumpError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ruby_version_is "1.8.8" do
|
21
|
+
it "returns an Enumerator when passed no block" do
|
22
|
+
enum = @set.classify
|
23
|
+
enum.should be_an_instance_of(enumerator_class)
|
24
|
+
|
25
|
+
classified = enum.each { |x| x.length }
|
26
|
+
classified.should == { 3 => Set["one", "two"], 4 => Set["four"], 5 => Set["three"] }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "classifies the Objects in self based on the block's return value" do
|
31
|
+
classified = @set.classify { |x| x.length }
|
32
|
+
classified.should == { 3 => Set["one", "two"], 4 => Set["four"], 5 => Set["three"] }
|
33
|
+
end
|
34
|
+
end
|
data/spec/clear_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#clear" do
|
4
|
+
before(:each) do
|
5
|
+
@set = Set["one", "two", "three", "four"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "removes all elements from self" do
|
9
|
+
@set.clear
|
10
|
+
@set.should be_empty
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns self" do
|
14
|
+
@set.clear.should equal(@set)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set[]" do
|
4
|
+
it "returns a new Set populated with the passed Objects" do
|
5
|
+
set = Set[1, 2, 3]
|
6
|
+
|
7
|
+
set.instance_of?(Set).should be_true
|
8
|
+
set.size.should eql(3)
|
9
|
+
|
10
|
+
set.should include(1)
|
11
|
+
set.should include(2)
|
12
|
+
set.should include(3)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#delete_if" do
|
4
|
+
before(:each) do
|
5
|
+
@set = Set["one", "two", "three"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "yields every element of self" do
|
9
|
+
ret = []
|
10
|
+
@set.delete_if { |x| ret << x }
|
11
|
+
ret.sort.should == ["one", "two", "three"].sort
|
12
|
+
end
|
13
|
+
|
14
|
+
it "deletes every element from self for which the passed block returns true" do
|
15
|
+
@set.delete_if { |x| x.size == 3 }
|
16
|
+
@set.size.should eql(1)
|
17
|
+
|
18
|
+
@set.should_not include("one")
|
19
|
+
@set.should_not include("two")
|
20
|
+
@set.should include("three")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "returns self" do
|
24
|
+
@set.delete_if { |x| x }.should equal(@set)
|
25
|
+
end
|
26
|
+
|
27
|
+
ruby_version_is "" ... "1.8.8" do
|
28
|
+
it "raises a LocalJumpError when passed no block" do
|
29
|
+
lambda { @set.delete_if }.should raise_error(LocalJumpError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
ruby_version_is "1.8.8" do
|
34
|
+
it "returns an Enumerator when passed no block" do
|
35
|
+
enum = @set.delete_if
|
36
|
+
enum.should be_an_instance_of(enumerator_class)
|
37
|
+
|
38
|
+
enum.each { |x| x.size == 3 }
|
39
|
+
|
40
|
+
@set.should_not include("one")
|
41
|
+
@set.should_not include("two")
|
42
|
+
@set.should include("three")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/spec/delete_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#delete" do
|
4
|
+
before(:each) do
|
5
|
+
@set = Set["a", "b", "c"]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "deletes the passed Object from self" do
|
9
|
+
@set.delete("a")
|
10
|
+
@set.should_not include("a")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "returns self" do
|
14
|
+
@set.delete("a").should equal(@set)
|
15
|
+
@set.delete("x").should equal(@set)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "Set#delete?" do
|
20
|
+
before(:each) do
|
21
|
+
@set = Set["a", "b", "c"]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "deletes the passed Object from self" do
|
25
|
+
@set.delete?("a")
|
26
|
+
@set.should_not include("a")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "returns self when the passed Object is in self" do
|
30
|
+
@set.delete?("a").should equal(@set)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns nil when the passed Object is not in self" do
|
34
|
+
@set.delete?("x").should be_nil
|
35
|
+
end
|
36
|
+
end
|
data/spec/divide_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#divide" do
|
4
|
+
it "divides self into a set of subsets based on the blocks return values" do
|
5
|
+
set = Set["one", "two", "three", "four", "five"].divide { |x| x.length }
|
6
|
+
set.map { |x| x.to_a.sort }.sort.should == [["five", "four"], ["one", "two"], ["three"]]
|
7
|
+
end
|
8
|
+
|
9
|
+
it "yields each Object to the block" do
|
10
|
+
ret = []
|
11
|
+
Set["one", "two", "three", "four", "five"].divide { |x| ret << x }
|
12
|
+
ret.sort.should == ["five", "four", "one", "three", "two"]
|
13
|
+
end
|
14
|
+
|
15
|
+
# BUG: Does not raise a LocalJumpError, but a NoMethodError
|
16
|
+
#
|
17
|
+
# it "raises a LocalJumpError when not passed a block" do
|
18
|
+
# lambda { Set[1].divide }.should raise_error(LocalJumpError)
|
19
|
+
# end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Set#divide when passed a block with an arity of 2" do
|
23
|
+
it "divides self into a set of subsets based on the blocks return values" do
|
24
|
+
set = Set[1, 3, 4, 6, 9, 10, 11].divide { |x, y| (x - y).abs == 1 }
|
25
|
+
set.map{ |x| x.to_a.sort }.sort.should == [[1], [3, 4], [6], [9, 10, 11]]
|
26
|
+
end
|
27
|
+
|
28
|
+
it "yields each two Object to the block" do
|
29
|
+
ret = []
|
30
|
+
Set[1, 2].divide { |x, y| ret << [x, y] }
|
31
|
+
ret.sort.should == [[1, 1], [1, 2], [2, 1], [2, 2]]
|
32
|
+
end
|
33
|
+
end
|
data/spec/each_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#each" do
|
4
|
+
before(:each) do
|
5
|
+
@set = Set[1, 2, 3]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "yields each Object in self" do
|
9
|
+
ret = []
|
10
|
+
@set.each { |x| ret << x }
|
11
|
+
ret.sort.should == [1, 2, 3]
|
12
|
+
end
|
13
|
+
|
14
|
+
it "returns self" do
|
15
|
+
@set.each { |x| x }.should equal(@set)
|
16
|
+
end
|
17
|
+
|
18
|
+
ruby_version_is "1.8.7" do
|
19
|
+
it "returns an Enumerator when not passed a block" do
|
20
|
+
enum = @set.each
|
21
|
+
|
22
|
+
ret = []
|
23
|
+
enum.each { |x| ret << x }
|
24
|
+
ret.sort.should == [1, 2, 3]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ruby_version_is "" ... "1.8.7" do
|
29
|
+
it "raises a LocalJumpError when not passed a block" do
|
30
|
+
lambda { @set.each }.should raise_error(LocalJumpError)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/empty_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Emumerable#to_set" do
|
4
|
+
it "returns a new Set created from self" do
|
5
|
+
[1, 2, 3].to_set.should == Set[1, 2, 3]
|
6
|
+
{:a => 1, :b => 2}.to_set.should == Set[[:b, 2], [:a, 1]]
|
7
|
+
end
|
8
|
+
|
9
|
+
it "allows passing an alternate class for Set" do
|
10
|
+
sorted_set = [1, 2, 3].to_set(SortedSet)
|
11
|
+
sorted_set.should == SortedSet[1, 2, 3]
|
12
|
+
sorted_set.instance_of?(SortedSet).should == true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "passes down passed blocks" do
|
16
|
+
[1, 2, 3].to_set { |x| x * x }.should == Set[1, 4, 9]
|
17
|
+
end
|
18
|
+
end
|
data/spec/eql_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
ruby_version_is "1.8.7" do
|
4
|
+
describe "Set#eql?" do
|
5
|
+
it "returns true when the passed argument is a Set and contains the same elements" do
|
6
|
+
Set[].should eql(Set[])
|
7
|
+
Set[1, 2, 3].should eql(Set[1, 2, 3])
|
8
|
+
Set[1, 2, 3].should eql(Set[3, 2, 1])
|
9
|
+
Set["a", :b, ?c].should eql(Set[?c, :b, "a"])
|
10
|
+
|
11
|
+
Set[1, 2, 3].should_not eql(Set[1.0, 2, 3])
|
12
|
+
Set[1, 2, 3].should_not eql(Set[2, 3])
|
13
|
+
Set[1, 2, 3].should_not eql(Set[])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#==" do
|
4
|
+
it "returns true when the passed Object is a Set and self and the Object contain the same elements" do
|
5
|
+
Set[].should == Set[]
|
6
|
+
Set[1, 2, 3].should == Set[1, 2, 3]
|
7
|
+
Set["1", "2", "3"].should == Set["1", "2", "3"]
|
8
|
+
|
9
|
+
Set[1, 2, 3].should_not == Set[1.0, 2, 3]
|
10
|
+
Set[1, 2, 3].should_not == [1, 2, 3]
|
11
|
+
end
|
12
|
+
|
13
|
+
it "does not depend on the order of the elements" do
|
14
|
+
Set[1, 2, 3].should == Set[3, 2, 1]
|
15
|
+
Set[:a, "b", ?c].should == Set[?c, "b", :a]
|
16
|
+
end
|
17
|
+
|
18
|
+
ruby_version_is "" ... "1.8.7" do
|
19
|
+
it "does depend on the order of nested Sets" do
|
20
|
+
Set[Set[1], Set[2], Set[3]].should_not == Set[Set[3], Set[2], Set[1]]
|
21
|
+
|
22
|
+
set1 = Set[Set["a", "b"], Set["c", "d"], Set["e", "f"]]
|
23
|
+
set2 = Set[Set["c", "d"], Set["a", "b"], Set["e", "f"]]
|
24
|
+
set1.should_not == set2
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
ruby_version_is "1.8.7" do
|
29
|
+
it "does not depend on the order of nested Sets" do
|
30
|
+
Set[Set[1], Set[2], Set[3]].should == Set[Set[3], Set[2], Set[1]]
|
31
|
+
|
32
|
+
set1 = Set[Set["a", "b"], Set["c", "d"], Set["e", "f"]]
|
33
|
+
set2 = Set[Set["c", "d"], Set["a", "b"], Set["e", "f"]]
|
34
|
+
set1.should == set2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#^" do
|
4
|
+
before :each do
|
5
|
+
@set = Set[1, 2, 3, 4]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "returns a new Set containing elements that are not in both self and the passed Enumberable" do
|
9
|
+
(@set ^ Set[3, 4, 5]).should == Set[1, 2, 5]
|
10
|
+
(@set ^ [3, 4, 5]).should == Set[1, 2, 5]
|
11
|
+
end
|
12
|
+
|
13
|
+
it "raises an ArgumentError when passed a non-Enumerable" do
|
14
|
+
lambda { @set ^ 3 }.should raise_error(ArgumentError)
|
15
|
+
lambda { @set ^ Object.new }.should raise_error(ArgumentError)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
3
|
+
describe "Set#flatten_merge" do
|
4
|
+
it "is protected" do
|
5
|
+
Set.should have_protected_instance_method("flatten_merge")
|
6
|
+
end
|
7
|
+
|
8
|
+
it "flattens the passed Set and merges it into self" do
|
9
|
+
set1 = Set[1, 2]
|
10
|
+
set2 = Set[3, 4, Set[5, 6]]
|
11
|
+
|
12
|
+
set1.send(:flatten_merge, set2).should == Set[1, 2, 3, 4, 5, 6]
|
13
|
+
end
|
14
|
+
|
15
|
+
it "raises an ArgumentError when trying to flatten a recursive Set" do
|
16
|
+
set1 = Set[1, 2, 3]
|
17
|
+
set2 = Set[5, 6, 7]
|
18
|
+
set2 << set2
|
19
|
+
|
20
|
+
lambda { set1.send(:flatten_merge, set2) }.should raise_error(ArgumentError)
|
21
|
+
end
|
22
|
+
end
|