/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
- require File.dirname(__FILE__) + "/../../spec_helper"
- require File.dirname(__FILE__) + "/../fixtures/classes"
-
- describe "Added method clr_new" do
- it "calls the CLR ctor for a CLR type" do
- ctor = CLRNew::Ctor.clr_new
- ctor.should be_kind_of CLRNew::Ctor
- ctor.tracker.should == 1
- end
-
- it "calls the CLR ctor for a subclassed CLR type" do
- ctor = CLRNew::Ctor.clr_new
- ctor.should be_kind_of CLRNew::Ctor
- ctor.tracker.should == 1
- end
-
- it "calls the CLR ctor for aliased CLR types" do
- Array.clr_new.should == []
- Hash.clr_new.should == {}
- (Thread.clr_new(System::Threading::ThreadStart.new {})).should be_kind_of Thread
- IO.clr_new.should be_kind_of IO
- String.clr_new.should == ""
- Object.clr_new.should be_kind_of Object
- Exception.clr_new.should be_kind_of Exception
- #TODO: All builtins?
- end
-
- it "doesn't call any Ruby initializer" do
- ctor = CLRNew::Ctor.clr_new
- ctor.tracker.should_not == 2
- end
-
- it "raises a TypeError if called on a pure Ruby type" do
- class Bar;end
- lambda { Bar.clr_new }.should raise_error TypeError
- lambda { Class.new.clr_new }.should raise_error TypeError
- lambda { Numeric.clr_new }.should raise_error TypeError
- end
- end