# Ruby Treasures 0.2
# Copyright (C) 2002 Paul Brannan <paul@atdesk.com>
# 
# You may distribute this software under the same terms as Ruby (see the file
# COPYING that was distributed with this library).
# 
require 'ds_test_helpers.rb'
require 'hacks/safe_mixin'

module Foo
  mixin_requires :foo, :bar

  def xyz
    foo
    bar
  end
end

class SafeMixinTest < RUNIT::TestCase
  def test_simple
    assert_exception(RuntimeError) do
      self.class.__send__(:include, Foo)
    end

    assert_exception(RuntimeError) do
      self.extend(Foo)
    end

    eval "def foo; end"

    assert_exception(RuntimeError) do
      self.class.__send__(:include, Foo)
    end

    assert_exception(RuntimeError) do
      self.extend(Foo)
    end

    eval "def bar; end"

    self.class.__send__(:include, Foo)
    self.extend(Foo)
  end
end

exit run_test(SafeMixinTest)

