C0 code coverage information
Generated on Sun Oct 26 11:18:12 -0500 2008 with rcov 0.8.1.2
Code reported as executed by Ruby looks like this...
and this: this line is also marked as covered.
Lines considered as run by rcov, but not reported by Ruby, look like this,
and this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not executed.
1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'aquarium/spec_example_types'
3 require 'aquarium/extensions/set'
4
5 class Foo
6 def initialize name
7 @name = name
8 end
9 attr_reader :name
10 def eql? other
11 name.eql? other.name
12 end
13 alias :== :eql?
14 end
15 class Bar
16 end
17
18 describe "set comparison", :shared => true do
19 it "should return true for the same set" do
20 s = Set.new [Foo.new("f1"), Foo.new("f2")]
21 s.should eql(s)
22 end
23
24 it "should return true for equivalent sets" do
25 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
26 s2 = Set.new [Foo.new("f2"), Foo.new("f1")]
27 s1.should eql(s2)
28 end
29
30 it "should return false for sets where one is a subset of, but not equivalent to, the other set" do
31 s1 = Set.new [Foo.new("f1")]
32 s2 = Set.new [Foo.new("f2"), Foo.new("f1")]
33 s1.should_not eql(s2)
34 end
35
36 it "should return false for sets where some element pairs are of different types" do
37 s1 = Set.new [Foo.new("f1"), Bar.new]
38 s2 = Set.new [Foo.new("f1"), Foo.new("f2")]
39 s1.should_not eql(s2)
40 end
41 end
42
43 describe Set, "#==" do
44 it_should_behave_like "set comparison"
45 end
46
47 describe Set, "#eql?" do
48 it_should_behave_like "set comparison"
49 end
50
51 describe Set, "#union_using_eql_comparison" do
52 it "should return an equivalent set if unioned with itself" do
53 s = Set.new [Foo.new("f1"), Foo.new("f2")]
54 s.union_using_eql_comparison(s).should eql(s)
55 end
56
57 it "should return an equivalent set if unioned with another equivalent set" do
58 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
59 s2 = Set.new [Foo.new("f1"), Foo.new("f2")]
60 s1.union_using_eql_comparison(s2).should eql(s1)
61 end
62
63 it "should return an equivalent set if unioned with subset" do
64 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
65 s2 = Set.new [Foo.new("f1")]
66 s1.union_using_eql_comparison(s2).should eql(s1)
67 s2.union_using_eql_comparison(s1).should eql(s1)
68 end
69
70 it "should return a combined set if unioned with a disjoint set" do
71 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
72 s2 = Set.new [Foo.new("f3")]
73 s3 = Set.new [Foo.new("f1"), Foo.new("f2"), Foo.new("f3")]
74 s1.union_using_eql_comparison(s2).should eql(s3)
75 s2.union_using_eql_comparison(s1).should eql(s3)
76 end
77 end
78
79 describe Set, "#intersection_using_eql_comparison" do
80 it "should return an equivalent set if intersectioned with itself" do
81 s = Set.new [Foo.new("f1"), Foo.new("f2")]
82 s.intersection_using_eql_comparison(s).should eql(s)
83 end
84
85 it "should return an equivalent set if intersectioned with another equivalent set" do
86 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
87 s2 = Set.new [Foo.new("f1"), Foo.new("f2")]
88 s1.intersection_using_eql_comparison(s2).should eql(s1)
89 end
90
91 it "should return a subset if intersectioned with an equivalent subset" do
92 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
93 s2 = Set.new [Foo.new("f1")]
94 s1.intersection_using_eql_comparison(s2).should eql(s2)
95 s2.intersection_using_eql_comparison(s1).should eql(s2)
96 end
97
98 it "should return an empty set if intersectioned with a disjoint set" do
99 s1 = Set.new [Foo.new("f1"), Foo.new("f2")]
100 s2 = Set.new [Foo.new("f3")]
101 s1.intersection_using_eql_comparison(s2).should eql(Set.new)
102 s2.intersection_using_eql_comparison(s1).should eql(Set.new)
103 end
104 end
105
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.