Revision: 1092 http://trac.macosforge.org/projects/ruby/changeset/1092 Author: eloy.de.enige@gmail.com Date: 2009-03-23 02:32:04 -0700 (Mon, 23 Mar 2009) Log Message: ----------- Moved 1.8 specific tests into a language version file and added a 1.9 example. Modified Paths: -------------- MacRuby/branches/experimental/spec/frozen/language/def_spec.rb Added Paths: ----------- MacRuby/branches/experimental/spec/frozen/language/versions/def_1.8.rb MacRuby/branches/experimental/spec/frozen/language/versions/def_1.9.rb Modified: MacRuby/branches/experimental/spec/frozen/language/def_spec.rb =================================================================== --- MacRuby/branches/experimental/spec/frozen/language/def_spec.rb 2009-03-23 08:26:45 UTC (rev 1091) +++ MacRuby/branches/experimental/spec/frozen/language/def_spec.rb 2009-03-23 09:32:04 UTC (rev 1092) @@ -17,7 +17,7 @@ def initialize end end - DefInitializeSpec.new.private_methods(false).should include('initialize') + DefInitializeSpec.should have_private_instance_method(:initialize, false) end end @@ -27,7 +27,7 @@ def initialize_copy end end - DefInitializeCopySpec.new.private_methods(false).should include('initialize_copy') + DefInitializeCopySpec.should have_private_instance_method(:initialize_copy, false) end end @@ -52,30 +52,6 @@ foo(1, 2, 3, 4, 5, 6, 7, 8).should == [1, 2, 3, 4, 5, [6, 7, 8]] end - it "creates a method that can be invoked with an inline hash argument" do - def foo(a,b,*c); [a,b,c] end - - foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit', *[789, 'yeah']). - should == - ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit'}, [789, 'yeah']] - end - - it "creates a method that can be invoked with an inline hash and a block" do - def foo(a,b,*c,&d); [a,b,c,yield(d)] end - - foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit', *[789, 'yeah']) { 3 }. - should == - ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit'}, [789, 'yeah'], 3] - - foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', *[789, 'yeah']) do 3 end.should == - ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes' }, [789, 'yeah'], 3] - - l = lambda { 3 } - - foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', *[789, 'yeah'], &l).should == - ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes' }, [789, 'yeah'], 3] - end - it "allows only a single * argument" do lambda { eval 'def foo(a, *b, *c); end' }.should raise_error(SyntaxError) end @@ -348,7 +324,7 @@ other = DefSpecNested.new other.an_instance_method.should == other - DefSpecNested.instance_methods.should include("an_instance_method") + DefSpecNested.should have_instance_method(:an_instance_method) end it "creates a class method when evaluated in a class method" do @@ -513,3 +489,5 @@ lambda { bar(3,4,5) }.should raise_error(ArgumentError) end end + +language_version __FILE__, "def" \ No newline at end of file Added: MacRuby/branches/experimental/spec/frozen/language/versions/def_1.8.rb =================================================================== --- MacRuby/branches/experimental/spec/frozen/language/versions/def_1.8.rb (rev 0) +++ MacRuby/branches/experimental/spec/frozen/language/versions/def_1.8.rb 2009-03-23 09:32:04 UTC (rev 1092) @@ -0,0 +1,25 @@ +describe "An instance method definition with a splat" do + it "creates a method that can be invoked with an inline hash argument" do + def foo(a,b,*c); [a,b,c] end + + foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit', *[789, 'yeah']). + should == + ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit'}, [789, 'yeah']] + end + + it "creates a method that can be invoked with an inline hash and a block" do + def foo(a,b,*c,&d); [a,b,c,yield] end + + foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit', *[789, 'yeah']) { 3 }. + should == + ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes', 'oh' => 'shit'}, [789, 'yeah'], 3] + + foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', *[789, 'yeah']) do 3 end.should == + ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes' }, [789, 'yeah'], 3] + + l = lambda { 3 } + + foo('abc', 'rbx' => 'cool', 'specs' => 'fail sometimes', *[789, 'yeah'], &l).should == + ['abc', { 'rbx' => 'cool', 'specs' => 'fail sometimes' }, [789, 'yeah'], 3] + end +end \ No newline at end of file Added: MacRuby/branches/experimental/spec/frozen/language/versions/def_1.9.rb =================================================================== --- MacRuby/branches/experimental/spec/frozen/language/versions/def_1.9.rb (rev 0) +++ MacRuby/branches/experimental/spec/frozen/language/versions/def_1.9.rb 2009-03-23 09:32:04 UTC (rev 1092) @@ -0,0 +1,9 @@ +describe "An instance method definition with a splat" do + it "raises a SyntaxError when invoked with an inline hash argument" do + def foo(a,b,*c); [a,b,c] end + + lambda do + instance_eval "foo('abc', 'specs' => 'fail sometimes', 'on' => '1.9', *[789, 'yeah'])" + end.should raise_error(SyntaxError) + end +end \ No newline at end of file
participants (1)
-
source_changes@macosforge.org