[3922] MacRuby/trunk/spec/frozen/language
Revision: 3922 http://trac.macosforge.org/projects/ruby/changeset/3922 Author: lsansonetti@apple.com Date: 2010-04-12 22:26:55 -0700 (Mon, 12 Apr 2010) Log Message: ----------- enable BEGIN language spec, one example is failing (will investigate that later) Added Paths: ----------- MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb Removed Paths: ------------- MacRuby/trunk/spec/frozen/language/BEGIN_spec_disabled.rb Copied: MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb (from rev 3920, MacRuby/trunk/spec/frozen/language/BEGIN_spec_disabled.rb) =================================================================== --- MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb (rev 0) +++ MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb 2010-04-13 05:26:55 UTC (rev 3922) @@ -0,0 +1,57 @@ +require File.expand_path('../../spec_helper', __FILE__) + +describe "The BEGIN keyword" do + ruby_version_is "" ... "1.9" do + it "runs in a new isolated scope" do + lambda { + eval "BEGIN { var_in_begin = 'foo' }; var_in_begin" + }.should raise_error NameError + + lambda { + outside_var = 'foo' + eval "BEGIN { outside_var }" + }.should raise_error NameError + end + end + + ruby_version_is "1.9" do + it "runs in a shared scope" do + lambda { + eval "BEGIN { var_in_begin = 'foo' }; var_in_begin" + }.should_not raise_error NameError + + lambda { + outside_var = 'foo' + eval "BEGIN { outside_var }" + }.should_not raise_error NameError + end + + it "must appear in a top-level context" do + lambda do + eval "1.times{ BEGIN{ :begun }}" + end.should raise_error(SyntaxError) + end + end + + it "runs first in a given code unit" do + o = Object.new + class << o + ARY = [] + eval "ARY << 'foo'; BEGIN { ARY << 'bar' }" + def ary; ARY; end + end + + o.ary.should == ['bar', 'foo'] + end + + it "runs multiple begins in FIFO order" do + o = Object.new + class << o + ARY = [] + eval "BEGIN { ARY << 'foo' }; BEGIN { ARY << 'bar' }" + def ary; ARY; end + end + + o.ary.should == ['foo', 'bar'] + end +end Deleted: MacRuby/trunk/spec/frozen/language/BEGIN_spec_disabled.rb =================================================================== --- MacRuby/trunk/spec/frozen/language/BEGIN_spec_disabled.rb 2010-04-13 05:26:28 UTC (rev 3921) +++ MacRuby/trunk/spec/frozen/language/BEGIN_spec_disabled.rb 2010-04-13 05:26:55 UTC (rev 3922) @@ -1,57 +0,0 @@ -require File.expand_path('../../spec_helper', __FILE__) - -describe "The BEGIN keyword" do - ruby_version_is "" .. "1.9" do - it "runs in a new isolated scope" do - lambda { - eval "BEGIN { var_in_begin = 'foo' }; var_in_begin" - }.should raise_error NameError - - lambda { - outside_var = 'foo' - eval "BEGIN { outside_var }" - }.should raise_error NameError - end - end - - ruby_version_is "1.9" do - it "runs in a shared scope" do - lambda { - eval "BEGIN { var_in_begin = 'foo' }; var_in_begin" - }.should_not raise_error NameError - - lambda { - outside_var = 'foo' - eval "BEGIN { outside_var }" - }.should_not raise_error NameError - end - - it "must appear in a top-level context" do - lambda do - eval "1.times{ BEGIN{ :begun }}" - end.should raise_error(SyntaxError) - end - end - - it "runs first in a given code unit" do - o = Object.new - class << o - ARY = [] - eval "ARY << 'foo'; BEGIN { ARY << 'bar' }" - def ary; ARY; end - end - - o.ary.should == ['bar', 'foo'] - end - - it "runs multiple begins in FIFO order" do - o = Object.new - class << o - ARY = [] - eval "BEGIN { ARY << 'foo' }; BEGIN { ARY << 'bar' }" - def ary; ARY; end - end - - o.ary.should == ['foo', 'bar'] - end -end
participants (1)
-
source_changes@macosforge.org