30 lines
		
	
	
		
			684 B
		
	
	
	
		
			Crystal
		
	
	
	
	
	
		
		
			
		
	
	
			30 lines
		
	
	
		
			684 B
		
	
	
	
		
			Crystal
		
	
	
	
	
	
|  | require "./spec_helper" | ||
|  | 
 | ||
|  | describe Array do | ||
|  |   describe "#union" do | ||
|  |     it "works with no elements" do | ||
|  |       ([] of Set(Int32)).union.should eq(Set(Int32).new) | ||
|  |     end | ||
|  | 
 | ||
|  |     it "correctly performs a union" do | ||
|  |       [Set { 1 }, Set { 2 }, Set {1, 2, 3}].union.should eq(Set { 1,2,3}) | ||
|  |     end | ||
|  |   end | ||
|  | 
 | ||
|  |   describe "#intersect" do | ||
|  |     expect_raises(Enumerable::EmptyError) do | ||
|  |       ([] of Set(Int32)).intersect | ||
|  |     end | ||
|  | 
 | ||
|  |     it "correctly performs an intersection" do | ||
|  |       [Set {1}, Set {1,2}, Set {1,2,3}].intersect.should eq(Set{1}) | ||
|  |     end | ||
|  |   end | ||
|  | 
 | ||
|  |   describe "#zip_with" do | ||
|  |     it "performs as expected" do | ||
|  |       [1,2,3].zip_with([2,3,4]) { |l,r| l*r }.should eq([2,6,12]) | ||
|  |     end | ||
|  |   end | ||
|  | end |