test_namecollision.rb 891 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env ruby
  2. #--
  3. # Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org).
  4. # Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net).
  5. # All rights reserved.
  6. # Permission is granted for use, copying, modification, distribution,
  7. # and distribution of modified versions of this work as long as the
  8. # above copyright notice is included.
  9. #++
  10. require 'test/unit'
  11. require 'builder/xchar'
  12. class TestNameCollisions < Test::Unit::TestCase
  13. module Collide
  14. def xchr
  15. end
  16. end
  17. def test_no_collision
  18. assert_nothing_raised do
  19. Builder.check_for_name_collision(Collide, :not_defined)
  20. end
  21. end
  22. def test_collision
  23. assert_raise RuntimeError do
  24. Builder.check_for_name_collision(Collide, "xchr")
  25. end
  26. end
  27. def test_collision_with_symbol
  28. assert_raise RuntimeError do
  29. Builder.check_for_name_collision(Collide, :xchr)
  30. end
  31. end
  32. end