Updated RubySpec source to 55122684.
[rbx.git] / spec / frozen / 1.8 / core / kernel / shared / lambda.rb
blobd6a0e1bd48526423784c9123b472193e328d4a8c
1 shared :kernel_lambda do |cmd|
2   describe "Kernel.#{cmd}" do
3     it "returns a Proc object" do
4       send(cmd) { true }.kind_of?(Proc).should == true
5     end
7     it "raises an ArgumentError when no block is given" do
8       lambda { send(cmd) }.should raise_error(ArgumentError)
9     end
11     it "raises an ArgumentError when given too many arguments" do
12       lambda {
13         send(cmd) { |a, b| a + b }.call(1, 2, 5)
14       }.should raise_error(ArgumentError)
15     end
17     it "raises an ArgumentError when given too few arguments" do
18       lambda {
19         send(cmd) { |a, b| a + b }.call(1)
20       }.should raise_error(ArgumentError)
21     end
23     it "returns from block into caller block" do
24       # More info in the pickaxe book pg. 359
25       def some_method(cmd)
26         p = send(cmd) { return 99 }
27         res = p.call
28         "returned #{res}"
29       end
31       # Have to pass in the cmd errors otherwise
32       some_method(cmd).should == "returned 99"
34       def some_method2(&b) b end
35       a_proc = send(cmd) { return true }
36       res = some_method2(&a_proc)
38       res.call.should == true
39     end
40   end
41 end