PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Tests/Interop/net/namespaces/modification/addition_spec.rb

#
Ruby | 75 lines | 66 code | 9 blank | 0 comment | 7 complexity | 14af32816a5e051045a208c1683dd8ed MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. require File.dirname(__FILE__) + '/../../spec_helper'
  2. describe "Adding to .NET namespaces" do
  3. it "is allowed for methods" do
  4. begin
  5. module NotEmptyNamespace
  6. def bar
  7. 1
  8. end
  9. end
  10. class Bar
  11. include NotEmptyNamespace
  12. end
  13. Bar.new.bar.should == 1
  14. ensure
  15. module NotEmptyNamespace
  16. undef :bar
  17. end
  18. end
  19. end
  20. it "is allowed for methods with module_function" do
  21. begin
  22. module NotEmptyNamespace
  23. def bar
  24. 1
  25. end
  26. module_function :bar
  27. end
  28. NotEmptyNamespace.bar.should == 1
  29. ensure
  30. module NotEmptyNamespace
  31. class << self
  32. undef :bar
  33. end
  34. end
  35. end
  36. end
  37. it "is allowed for Ruby classes" do
  38. begin
  39. module NotEmptyNamespace
  40. class Test; end
  41. end
  42. NotEmptyNamespace::Test.new.should be_kind_of NotEmptyNamespace::Test
  43. ensure
  44. module NotEmptyNamespace
  45. self.send(:remove_const, :Test)
  46. end
  47. end
  48. end
  49. it "is allowed for ruby modules" do
  50. begin
  51. module NotEmptyNamespace
  52. module Bar
  53. def bar
  54. 1
  55. end
  56. module_function :bar
  57. end
  58. end
  59. NotEmptyNamespace::Bar.bar.should == 1
  60. ensure
  61. module NotEmptyNamespace
  62. self.send(:remove_const, :Bar)
  63. end
  64. end
  65. end
  66. end