Skip to content

Commit

Permalink
move `fun' splat examples to fun_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
quix committed May 21, 2009
1 parent fbffb17 commit c6655a3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
25 changes: 25 additions & 0 deletions spec/fun_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,29 @@ def f
end
end.compute(:f, 10).should == 33
end

it "should support splat in block args" do
pure do
fun :area => [:width, :height] do |*a|
a[0]*a[1]
end

def width
3
end

def height
4
end
end.compute(:area, 3).should == 12
end

it "should support splat with single-element array" do
pure do
name = [:f]
fun(*name) do
name
end
end.compute(:f, 3).should == [:f]
end
end
27 changes: 0 additions & 27 deletions spec/splat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,5 @@ def f(a, b, *stuff)
}.should raise_error(Pure::PurePrivate::SplatError)
end
end

describe "with `fun'" do
it "should work in block args" do
pure do
fun :area => [:width, :height] do |*a|
a[0]*a[1]
end

def width
3
end

def height
4
end
end.compute(:area, 3).should == 12
end

it "should work for single-element array" do
pure do
name = [:f]
fun(*name) do
name
end
end.compute(:f, 3).should == [:f]
end
end
end

0 comments on commit c6655a3

Please sign in to comment.