test/glue/tc_aspects.rb in glue-0.20.0 vs test/glue/tc_aspects.rb in glue-0.21.0
- old
+ new
@@ -5,97 +5,97 @@
include Glue
class TestCaseAspects < Test::Unit::TestCase # :nodoc: all
- class Monitor
- def self.pre(this)
- this.ma = 2
- end
+ class Monitor
+ def self.pre(this)
+ this.ma = 2
+ end
- def self.post(this)
- this.mb = 5
- end
- end
+ def self.post(this)
+ this.mb = 5
+ end
+ end
- module Localize
- def localize
- @ll = 5
- end
- end
+ module Localize
+ def localize
+ @ll = 5
+ end
+ end
- module Tester
- include Aspects
+ module Tester
+ include Aspects
- attr_accessor :ta
- pre { |this| this.ta = 5 }
- end
-
- class Dummy
- include Aspects
- include Tester
-
- attr_accessor :a, :b, :c
- attr_accessor :oa, :ob
- attr_accessor :ma, :mb
- attr_accessor :ll
- attr_accessor :pa
+ attr_accessor :ta
+ pre { |this| this.ta = 5 }
+ end
+
+ class Dummy
+ include Aspects
+ include Tester
+
+ attr_accessor :a, :b, :c
+ attr_accessor :oa, :ob
+ attr_accessor :ma, :mb
+ attr_accessor :ll
+ attr_accessor :pa
- pre :pre_advice
- wrap Monitor
- wrap Localize, :pre => :localize
- post { |this| this.pa = 3 }
+ pre :pre_advice
+ wrap Monitor
+ wrap Localize, :pre => :localize
+ post { |this| this.pa = 3 }
- def initialize
- @a = 0
- end
-
- def hello(q)
- @a += 1 + q
- end
+ def initialize
+ @a = 0
+ end
+
+ def hello(q)
+ @a += 1 + q
+ end
- def pre_advice
- @b = 1
- @a += 1
- end
+ def pre_advice
+ @b = 1
+ @a += 1
+ end
- def post_advice
- @c = 1
- end
-
- end
+ def post_advice
+ @c = 1
+ end
+
+ end
- # Class aspect.
-
- class Observer < Aspect
- def self.pre(this)
- this.oa = 9
- end
- end
-
- # Instance aspect.
+ # Class aspect.
+
+ class Observer < Aspect
+ def self.pre(this)
+ this.oa = 9
+ end
+ end
+
+ # Instance aspect.
- class Epilogue < Aspect
- def post(this)
- this.ob = 9
- end
- end
-
- def test_all
- Observer.wrap(Dummy, :hello)
- Epilogue.new.wrap(Dummy, :hello)
- Aspects.wrap(Dummy, :hello)
+ class Epilogue < Aspect
+ def post(this)
+ this.ob = 9
+ end
+ end
+
+ def test_all
+ Observer.wrap(Dummy, :hello)
+ Epilogue.new.wrap(Dummy, :hello)
+ Aspects.wrap(Dummy, :hello)
- d = Dummy.new
- d.hello(3)
- assert_equal 5, d.a
- assert_equal 1, d.b
- assert_equal 9, d.oa
- assert_equal 9, d.ob
- assert_equal 2, d.ma
- assert_equal 5, d.mb
- assert_equal 5, d.ll
- assert_equal 3, d.pa
- assert_equal 5, d.ta
- end
+ d = Dummy.new
+ d.hello(3)
+ assert_equal 5, d.a
+ assert_equal 1, d.b
+ assert_equal 9, d.oa
+ assert_equal 9, d.ob
+ assert_equal 2, d.ma
+ assert_equal 5, d.mb
+ assert_equal 5, d.ll
+ assert_equal 3, d.pa
+ assert_equal 5, d.ta
+ end
end