PageRenderTime 35ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Tests/Interop/net/delegate/shared/instantiation.rb

#
Ruby | 31 lines | 24 code | 7 blank | 0 comment | 0 complexity | 60625157653f38e5787afb21d8e3c7cd 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__) + "/../fixtures/classes"
  2. describe :delegate_instantiation, :shared => true do
  3. before(:each) do
  4. @class = @method
  5. end
  6. it "creates a delegate from bound methods" do
  7. @class.new(DelegateTester.method(:bar)).should be_kind_of @class
  8. end
  9. it "creates a delegate from lambdas" do
  10. @class.new(lambda { puts '123' }).should be_kind_of @class
  11. end
  12. it "creates a delegate from procs" do
  13. @class.new(proc { puts '123' }).should be_kind_of @class
  14. end
  15. it "creates a delegate from blocks" do
  16. (@class.new {puts '123'}).should be_kind_of @class
  17. end
  18. it "requires an argument" do
  19. lambda {@class.new}.should raise_error ArgumentError
  20. end
  21. it "requires a proc-like object" do
  22. lambda {@class.new(1)}.should raise_error TypeError
  23. end
  24. end