C0 code coverage information
Generated on Sun Oct 26 11:18:06 -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/utils'
4 require 'aquarium/extensions'
5 require 'aquarium/aspects/pointcut'
6 require 'aquarium/aspects/pointcut_composition'
7
8 include Aquarium::Utils::HashUtils
9 include Aquarium::Aspects
10
11 describe Pointcut, "#and" do
12 it "should return a new Pointcut." do
13 pc1 = Pointcut.new
14 pc2 = Pointcut.new :types => ClassWithPublicInstanceMethod, :method_options => :exclude_ancestor_methods
15 pc12 = (pc1.and(pc2))
16 pc12.should_not equal(pc1)
17 pc12.should_not equal(pc2)
18 end
19 end
20
21 describe Pointcut, "#and (when one pointcut is empty)" do
22 before :all do
23 @pc1 = Pointcut.new
24 @pc2 = Pointcut.new :types => ClassWithPublicInstanceMethod, :method_options => :exclude_ancestor_methods
25 end
26
27 it "should return a new empty Pointcut if the left-hand Pointcut is empty, independent of the right-hand Pointcut." do
28 (@pc1.and(@pc2)).should == @pc1
29 end
30
31 it "should return a new empty Pointcut if the right-hand Pointcut is empty, independent of the left-hand Pointcut." do
32 (@pc2.and(@pc1)).should == @pc1
33 end
34 end
35
36 describe Pointcut, "#and (when both pointcuts are not empty)" do
37 before(:each) do
38 @example_types = {}
39 [ClassWithPublicInstanceMethod, ClassWithProtectedInstanceMethod, ClassWithPrivateInstanceMethod,
40 ClassWithPublicClassMethod, ClassWithPrivateClassMethod].each {|c| @example_types[c] = []}
41 @empty_set = Set.new
42 end
43
44 it "should return a new Pointcut whose join points are the intersection of the left- and right-hand side Pointcuts, each with multiple types." do
45 pc1 = Pointcut.new :types => [ClassWithAttribs, ClassWithPublicInstanceMethod, ClassWithPrivateInstanceMethod], :attributes => [/^attr/], :attribute_options => [:readers]
46 pc2 = Pointcut.new :types => [ClassWithAttribs, ClassWithPublicInstanceMethod, ClassWithProtectedInstanceMethod], :attributes => :attrRW_ClassWithAttribs, :attribute_options => [:exclude_ancestor_methods]
47 pc = pc1.and pc2
48 expected_jp = JoinPoint.new :type => ClassWithAttribs, :method => :attrRW_ClassWithAttribs
49 pc.join_points_matched.should == Set.new([expected_jp])
50 pc.join_points_not_matched.should == @empty_set
51 end
52
53 it "should return a new Pointcut whose join points are the intersection of the left- and right-hand side Pointcuts, each with multiple objects." do
54 cwa = ClassWithAttribs.new
55 pub = ClassWithPublicInstanceMethod.new
56 pri = ClassWithPrivateInstanceMethod.new
57 pro = ClassWithProtectedInstanceMethod.new
58 pc1 = Pointcut.new :objects => [cwa, pub, pri], :attributes => [/^attr/], :attribute_options => [:readers, :exclude_ancestor_methods]
59 pc2 = Pointcut.new :objects => [cwa, pub, pro], :attributes => :attrRW_ClassWithAttribs
60 pc = pc1.and pc2
61 expected_jp = JoinPoint.new :object => cwa, :method => :attrRW_ClassWithAttribs
62 pc.join_points_matched.should == Set.new([expected_jp])
63 pc.join_points_not_matched.should == @empty_set
64 end
65
66 it "should return a new Pointcut whose join points are the intersection of the left- and right-hand side Pointcuts, each with a single type." do
67 pc1 = Pointcut.new :types => "ClassWithAttribs", :attributes => [/^attr/], :attribute_options => [:readers]
68 pc2 = Pointcut.new :types => "ClassWithAttribs", :attributes => :attrRW_ClassWithAttribs
69 pc = pc1.and pc2
70 expected_jp = JoinPoint.new :type => ClassWithAttribs, :method => :attrRW_ClassWithAttribs
71 pc.join_points_matched.should == Set.new([expected_jp])
72 pc.join_points_not_matched.should == @empty_set
73 end
74
75 it "should return a new Pointcut whose join points are the intersection of the left- and right-hand side Pointcuts, each with a single object." do
76 cwa = ClassWithAttribs.new
77 pc1 = Pointcut.new :object => cwa, :attributes => [/^attr/], :attribute_options => [:readers]
78 pc2 = Pointcut.new :object => cwa, :attributes => :attrRW_ClassWithAttribs
79 pc = pc1.and pc2
80 expected_jp = JoinPoint.new :object => cwa, :method => :attrRW_ClassWithAttribs
81 pc.join_points_matched.should == Set.new([expected_jp])
82 pc.join_points_not_matched.should == @empty_set
83 end
84 end
85
86 describe Pointcut, "#and (algebraic properties for type-based pointcuts)" do
87 before :all do
88 @pc1 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/], :attribute_options => [:writers]
89 @pc2 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/], :attribute_options => [:writers]
90 @pc3 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/]
91 end
92
93 it "should be unitary for type-based Pointcuts." do
94 pc = @pc1.and @pc2
95 pc.should == @pc1
96 pc.should == @pc2
97 end
98
99 it "should be commutative for type-based Pointcuts." do
100 pc13 = @pc1.and @pc3
101 pc31 = @pc3.and @pc1
102 pc13.should == pc31
103 end
104
105 it "should be associativity for type-based Pointcuts." do
106 pc123a = (@pc1.and(@pc2)).and(@pc3)
107 pc123b = @pc1.and(@pc2.and(@pc3))
108 pc123a.should == pc123b
109 end
110 end
111
112 describe Pointcut, "#and (algebraic properties for object-based pointcuts)" do
113 before :all do
114 cwa = ClassWithAttribs.new
115 @pc1 = Pointcut.new :objects => cwa, :attributes => [/^attr/], :attribute_options => [:writers]
116 @pc2 = Pointcut.new :objects => cwa, :attributes => [/^attr/], :attribute_options => [:writers]
117 @pc3 = Pointcut.new :objects => cwa, :attributes => [/^attr/]
118 end
119
120 it "should be unitary for object-based Pointcuts." do
121 pc = @pc1.and @pc2
122 pc.should == @pc1
123 pc.should == @pc2
124 end
125
126 it "should be commutative for object-based Pointcuts." do
127 pc13 = @pc1.and @pc3
128 pc31 = @pc3.and @pc1
129 pc13.should == pc31
130 end
131
132 it "should be associativity for object-based Pointcuts." do
133 pc123a = (@pc1.and(@pc2)).and(@pc3)
134 pc123b = @pc1.and(@pc2.and(@pc3))
135 pc123a.should == pc123b
136 end
137 end
138
139 describe Pointcut, "#&" do
140
141 it "should be a synonym for #and." do
142 pc1 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/], :attribute_options => [:writers]
143 pc2 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/], :attribute_options => [:writers]
144 pc3 = Pointcut.new :types => ClassWithAttribs, :attributes => [/^attr/]
145 pc123a = (pc1 & pc2) & pc3
146 pc123b = pc1 & (pc2 & pc3)
147 pc123a.should == pc123b
148 cwa = ClassWithAttribs.new
149 pca = Pointcut.new :objects => cwa, :attributes => [/^attr/], :attribute_options => [:writers]
150 pcb = Pointcut.new :objects => cwa, :attributes => [/^attr/], :attribute_options => [:writers]
151 pcc = Pointcut.new :objects => cwa, :attributes => [/^attr/]
152 pcabc1 = (pca & pcb) & pcc
153 pcabc2 = pca & (pcb & pcc)
154 pcabc1.should == pcabc2
155 end
156 end
Generated using the rcov code coverage analysis tool for Ruby version 0.8.1.2.