Attributation works in literal class but not in anonymous class?

# Creates a method that necessitates overridding.
# If it not overridden and called upon a TypeError
# will be raised.

···

#
# class C
# abstract :a
# end
#
# c = C.new
# c.a #=> Error: undefined abstraction #a
#
class Module
  def abstract( *sym )
    sym.each { |s|
      define_method( s ) { raise TypeError, "undefined abstraction
##{s}" }
    }
  end
end

require 'test/unit'
#require 'nano/module/abstract'

# fixture

class Aq
  abstract :q
end

class TC_Module < Test::Unit::TestCase

  # abstract literal

  def test01
    ac = Aq.new
    assert_raises( TypeError ) { ac.q }
  end

  # abstract anonymous

  def test02
    ac = Class.new { abstract :q }
    assert_raises( TypeError ) { ac.q }
  end

end

Loaded suite tc_abstract
Started
..F
Finished in 0.065452 seconds.

  1) Failure:
test02(TC_Module) [tc_abstract.rb:22]:
<TypeError> exception expected but was
Class: <NoMethodError>
Message: <"undefined method `q' for #<Class:0xb7cfedf0>">
---Backtrace---
tc_abstract.rb:22:in `test02'
tc_abstract.rb:22:in `assert_raise'
tc_abstract.rb:22:in `test02'
---------------

2 tests, 2 assertions, 1 failures, 0 errors

T.

Hi --

···

On Wed, 31 Aug 2005, Trans wrote:

def test02
   ac = Class.new { abstract :q }

      ac = Class.new { abstract :q } .new

David

--
David A. Black
dblack@wobblini.net

David A. Black wrote:

Hi --

> def test02
> ac = Class.new { abstract :q }

      ac = Class.new { abstract :q } .new

Doh! Thanks.

T.

···

On Wed, 31 Aug 2005, Trans wrote: