PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/Ruby/Tests/Interop/net/ruby/additions/clr_new_spec.rb

#
Ruby | 39 lines | 34 code | 4 blank | 1 comment | 8 complexity | 9ea23b5e2ec8e5b04bef816605d50905 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. require File.dirname(__FILE__) + "/../fixtures/classes"
  3. describe "Added method clr_new" do
  4. it "calls the CLR ctor for a CLR type" do
  5. ctor = CLRNew::Ctor.clr_new
  6. ctor.should be_kind_of CLRNew::Ctor
  7. ctor.tracker.should == 1
  8. end
  9. it "calls the CLR ctor for a subclassed CLR type" do
  10. ctor = CLRNew::Ctor.clr_new
  11. ctor.should be_kind_of CLRNew::Ctor
  12. ctor.tracker.should == 1
  13. end
  14. it "calls the CLR ctor for aliased CLR types" do
  15. Array.clr_new.should == []
  16. Hash.clr_new.should == {}
  17. (Thread.clr_new(System::Threading::ThreadStart.new {})).should be_kind_of Thread
  18. IO.clr_new.should be_kind_of IO
  19. String.clr_new.should == ""
  20. Object.clr_new.should be_kind_of Object
  21. Exception.clr_new.should be_kind_of Exception
  22. #TODO: All builtins?
  23. end
  24. it "doesn't call any Ruby initializer" do
  25. ctor = CLRNew::Ctor.clr_new
  26. ctor.tracker.should_not == 2
  27. end
  28. it "raises a TypeError if called on a pure Ruby type" do
  29. class Bar;end
  30. lambda { Bar.clr_new }.should raise_error TypeError
  31. lambda { Class.new.clr_new }.should raise_error TypeError
  32. lambda { Numeric.clr_new }.should raise_error TypeError
  33. end
  34. end