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