[macruby-changes] [3875] MacRuby/trunk/spec/frozen/language
source_changes at macosforge.org
source_changes at macosforge.org
Sun Mar 28 12:55:40 PDT 2010
Revision: 3875
http://trac.macosforge.org/projects/ruby/changeset/3875
Author: eloy.de.enige at gmail.com
Date: 2010-03-28 12:55:40 -0700 (Sun, 28 Mar 2010)
Log Message:
-----------
Update RubySpec to 1d137b699c813be4d9f1f2728d68b44ab52ec36a (part 5)
Modified Paths:
--------------
MacRuby/trunk/spec/frozen/language/alias_spec.rb
MacRuby/trunk/spec/frozen/language/and_spec.rb
MacRuby/trunk/spec/frozen/language/array_spec.rb
MacRuby/trunk/spec/frozen/language/block_spec.rb
MacRuby/trunk/spec/frozen/language/break_spec.rb
MacRuby/trunk/spec/frozen/language/case_spec.rb
MacRuby/trunk/spec/frozen/language/catch_spec.rb
MacRuby/trunk/spec/frozen/language/class_spec.rb
MacRuby/trunk/spec/frozen/language/class_variable_spec.rb
MacRuby/trunk/spec/frozen/language/constants_spec.rb
MacRuby/trunk/spec/frozen/language/def_spec.rb
MacRuby/trunk/spec/frozen/language/defined_spec.rb
MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
MacRuby/trunk/spec/frozen/language/else_spec.rb
MacRuby/trunk/spec/frozen/language/encoding_spec.rb
MacRuby/trunk/spec/frozen/language/ensure_spec.rb
MacRuby/trunk/spec/frozen/language/execution_spec.rb
MacRuby/trunk/spec/frozen/language/file_spec.rb
MacRuby/trunk/spec/frozen/language/fixtures/super.rb
MacRuby/trunk/spec/frozen/language/for_spec.rb
MacRuby/trunk/spec/frozen/language/hash_spec.rb
MacRuby/trunk/spec/frozen/language/if_spec.rb
MacRuby/trunk/spec/frozen/language/line_spec.rb
MacRuby/trunk/spec/frozen/language/loop_spec.rb
MacRuby/trunk/spec/frozen/language/magic_comment_spec.rb
MacRuby/trunk/spec/frozen/language/metaclass_spec.rb
MacRuby/trunk/spec/frozen/language/method_spec.rb
MacRuby/trunk/spec/frozen/language/module_spec.rb
MacRuby/trunk/spec/frozen/language/next_spec.rb
MacRuby/trunk/spec/frozen/language/not_spec.rb
MacRuby/trunk/spec/frozen/language/numbers_spec.rb
MacRuby/trunk/spec/frozen/language/or_spec.rb
MacRuby/trunk/spec/frozen/language/order_spec.rb
MacRuby/trunk/spec/frozen/language/precedence_spec.rb
MacRuby/trunk/spec/frozen/language/predefined_spec.rb
MacRuby/trunk/spec/frozen/language/private_spec.rb
MacRuby/trunk/spec/frozen/language/redo_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/anchors_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/back-references_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/character_classes_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/escapes_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/grouping_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/interpolation_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/modifiers_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/repetition_spec.rb
MacRuby/trunk/spec/frozen/language/regexp/versions/character_classes_1.9.rb
MacRuby/trunk/spec/frozen/language/regexp_spec.rb
MacRuby/trunk/spec/frozen/language/rescue_spec.rb
MacRuby/trunk/spec/frozen/language/retry_spec.rb
MacRuby/trunk/spec/frozen/language/return_spec.rb
MacRuby/trunk/spec/frozen/language/splat_spec.rb
MacRuby/trunk/spec/frozen/language/string_spec.rb
MacRuby/trunk/spec/frozen/language/super_spec.rb
MacRuby/trunk/spec/frozen/language/symbol_spec.rb
MacRuby/trunk/spec/frozen/language/throw_spec.rb
MacRuby/trunk/spec/frozen/language/undef_spec.rb
MacRuby/trunk/spec/frozen/language/unless_spec.rb
MacRuby/trunk/spec/frozen/language/until_spec.rb
MacRuby/trunk/spec/frozen/language/variables_spec.rb
MacRuby/trunk/spec/frozen/language/versions/array_1.9.rb
MacRuby/trunk/spec/frozen/language/versions/regexp_1.9.rb
MacRuby/trunk/spec/frozen/language/while_spec.rb
MacRuby/trunk/spec/frozen/language/yield_spec.rb
Added Paths:
-----------
MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb
MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
MacRuby/trunk/spec/frozen/language/shared/
MacRuby/trunk/spec/frozen/language/shared/__FILE__.rb
MacRuby/trunk/spec/frozen/language/shared/__LINE__.rb
Added: MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb (rev 0)
+++ MacRuby/trunk/spec/frozen/language/BEGIN_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -0,0 +1,51 @@
+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
+ 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
Modified: MacRuby/trunk/spec/frozen/language/alias_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/alias_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/alias_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
class AliasObject
attr :foo
Modified: MacRuby/trunk/spec/frozen/language/and_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/and_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/and_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The '&&' statement" do
Modified: MacRuby/trunk/spec/frozen/language/array_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/array_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/array_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/array'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/array', __FILE__)
describe "Array literals" do
it "[] should return a new array populated with the given elements" do
Modified: MacRuby/trunk/spec/frozen/language/block_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/block_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/block_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/block'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/block', __FILE__)
describe "A block with mismatched arguments" do
it "Should fill in unsupplied arguments with nil" do
Modified: MacRuby/trunk/spec/frozen/language/break_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/break_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/break_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The break statement" do
it "ends block execution if used whithin block" do
Modified: MacRuby/trunk/spec/frozen/language/case_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/case_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/case_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The 'case'-construct" do
it "evaluates the body of the when clause matching the case target expression" do
Modified: MacRuby/trunk/spec/frozen/language/catch_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/catch_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/catch_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The catch keyword" do
ruby_version_is "" ... "1.9" do
Modified: MacRuby/trunk/spec/frozen/language/class_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/class_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/class_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
ClassSpecsNumber = 12
Modified: MacRuby/trunk/spec/frozen/language/class_variable_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/class_variable_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/class_variable_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/../fixtures/class_variables'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class_variables', __FILE__)
describe "A class variable" do
it "can be accessed from a subclass" do
Modified: MacRuby/trunk/spec/frozen/language/constants_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/constants_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/constants_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/../fixtures/constants'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/constants', __FILE__)
# Read the documentation in fixtures/constants.rb for the guidelines and
# rationale for the structure and organization of these specs.
Modified: MacRuby/trunk/spec/frozen/language/def_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/def_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/def_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# Language-level method behaviour
describe "Redefining a method" do
Modified: MacRuby/trunk/spec/frozen/language/defined_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/defined_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/defined_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/defined', __FILE__)
describe "The defined? keyword" do
class LanguageDefinedSpecs
@@ -156,6 +157,10 @@
ret.should == nil
end
+ it "returns nil for defined?(super) when a superclass undef's the method" do
+ DefinedSpecs::ClassWithoutMethod.new.test.should be_nil
+ end
+
it "returns 'expression' when defined?(:File) is sent" do
ret = defined?(:File)
ret.should == "expression"
@@ -165,12 +170,32 @@
ret = defined?(LanguageDefinedSpecs::SomeConst)
ret.should == "constant"
end
+
+ it "returns nil when defined?(LanguageDefinedSpecs::MissingConst) is sent" do
+ ret = defined?(LanguageDefinedSpecs::MissingConst)
+ ret.should == nil
+ end
+ it "returns nil when defined?(LanguageDefinedSpecs::MissingConst::MissingConst) is sent" do
+ ret = defined?(LanguageDefinedSpecs::MissingConst::MissingConst)
+ ret.should == nil
+ end
+
it "returns 'constant' when evaluating self::FOO in module AAA" do
ret = defined?(AAA::FOO)
ret.should == 'constant'
end
+ it "returns 'constant' when evaluating self::FOO in subclass's metaclass" do
+ o = Object.new
+ class << o
+ class Foo; Baz = 1; end
+ class Bar < Foo; def self.baz_defined?; defined? self::Baz; end; end
+ def bar; Bar; end
+ end
+ o.bar.baz_defined?.should == 'constant'
+ end
+
it "returns 'constant' when defined?(File) is sent" do
ret = defined?(File)
ret.should == "constant"
Modified: MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/eigenclass_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
describe "self in an eigenclass body (class << obj)" do
it "is TrueClass for true" do
Modified: MacRuby/trunk/spec/frozen/language/else_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/else_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/else_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1 +1 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
Modified: MacRuby/trunk/spec/frozen/language/encoding_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/encoding_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/encoding_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
ruby_version_is "1.9" do
describe "The __ENCODING__ pseudo-variable" do
Modified: MacRuby/trunk/spec/frozen/language/ensure_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/ensure_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/ensure_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/ensure'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/ensure', __FILE__)
describe "An ensure block inside a begin block" do
before :each do
Modified: MacRuby/trunk/spec/frozen/language/execution_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/execution_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/execution_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "``" do
it "returns the output of the executed sub-process" do
Modified: MacRuby/trunk/spec/frozen/language/file_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/file_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/file_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,59 +1,25 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/__FILE__', __FILE__)
-# specs for __FILE__
-
describe "The __FILE__ constant" do
- it "equals the current filename" do
- File.basename(__FILE__).should == "file_spec.rb"
- end
-
it "equals (eval) inside an eval" do
eval("__FILE__").should == "(eval)"
end
+end
- ruby_version_is "".."1.8.7" do
- it "equals a relative path when required using a relative path" do
- base_path = File.dirname(File.dirname(fixture(__FILE__, "file.rb")))
- path = "fixtures/file.rb"
- Dir.chdir(base_path) do
- require path
- ScratchPad.recorded.should == File.join(".",path)
- end
- end
- end
+describe "The __FILE__ constant" do
+ it_behaves_like :language___FILE__, :require, CodeLoadingSpecs::Method.new
+end
- ruby_version_is "1.8.8".."1.9" do
- it "equals an absolute path when required using a relative path" do
- base_path = File.dirname(File.dirname(fixture(__FILE__, "file.rb")))
- path = "./fixtures/file.rb"
- Dir.chdir(base_path) do
- require path
- ScratchPad.recorded.should == File.expand_path(path)
- end
- end
- end
+describe "The __FILE__ constant" do
+ it_behaves_like :language___FILE__, :require, Kernel
+end
- it "equals the full path when required using a full path" do
- path = fixture(__FILE__, "file.rb")
- require path
- ScratchPad.recorded.should == path
- end
+describe "The __FILE__ constant" do
+ it_behaves_like :language___FILE__, :load, CodeLoadingSpecs::Method.new
end
-
describe "The __FILE__ constant" do
- before(:each) do
- path = fixture(__FILE__,"file.rb")
- #puts "@@@@ Path is #{path} for fixture(#{__FILE__},'file.rb')"
- $:.unshift File.dirname(path)
- end
- after(:each) do
- $:.shift
- end
-
- it "equals the full path to the file when required" do
- require 'file.rb'
- ScratchPad.recorded.should == fixture(__FILE__, 'file.rb')
- end
-
+ it_behaves_like :language___FILE__, :load, Kernel
end
Added: MacRuby/trunk/spec/frozen/language/fixtures/defined.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/fixtures/defined.rb (rev 0)
+++ MacRuby/trunk/spec/frozen/language/fixtures/defined.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -0,0 +1,18 @@
+module DefinedSpecs
+ class ClassWithMethod
+ def test
+ end
+ end
+
+ class ClassUndefiningMethod < ClassWithMethod
+ undef :test
+ end
+
+ class ClassWithoutMethod < ClassUndefiningMethod
+ # If an undefined method overridden in descendants
+ # define?(super) should return nil
+ def test
+ defined?(super)
+ end
+ end
+end
Modified: MacRuby/trunk/spec/frozen/language/fixtures/super.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/fixtures/super.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/fixtures/super.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -202,4 +202,61 @@
public :example
end
end
+
+ class MM_A
+ undef_method :is_a?
+ end
+
+ class MM_B < MM_A
+ def is_a?(blah)
+ # should fire the method_missing below
+ super
+ end
+
+ def method_missing(*)
+ false
+ end
+ end
+
+ class Alias1
+ def name
+ [:alias1]
+ end
+ end
+
+ class Alias2 < Alias1
+ def initialize
+ @times = 0
+ end
+
+ def name
+ if @times >= 10
+ raise "runaway super"
+ end
+
+ @times += 1
+
+ # Use this so that we can see collect all supers that we see.
+ # One bug that arises is that we call Alias2#name from Alias2#name
+ # as it's superclass. In that case, either we get a runaway recursion
+ # super OR we get the return value being [:alias2, :alias2, :alias1]
+ # rather than [:alias2, :alias1].
+ #
+ # Which one depends on caches and how super is implemented.
+ [:alias2] + super
+ end
+ end
+
+ class Alias3 < Alias2
+ alias_method :name3, :name
+ # In the method table for Alias3 now should be a special alias entry
+ # that references Alias2 and Alias2#name (probably as an object).
+ #
+ # When name3 is called then, Alias2 (NOT Alias3) is presented as the
+ # current module to Alias2#name, so that when super is called,
+ # Alias2->superclass is next.
+ #
+ # Otherwise, Alias2 is next, which is where name was to begin with,
+ # causing the wrong #name method to be called.
+ end
end
Modified: MacRuby/trunk/spec/frozen/language/for_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/for_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/for_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# for name[, name]... in expr [do]
# body
Modified: MacRuby/trunk/spec/frozen/language/hash_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/hash_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/hash_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Hash literal" do
it "{} should return an empty hash" do
Modified: MacRuby/trunk/spec/frozen/language/if_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/if_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/if_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The if expression" do
it "evaluates body if expression is true" do
Modified: MacRuby/trunk/spec/frozen/language/line_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/line_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/line_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,19 +1,41 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/code_loading', __FILE__)
+require File.expand_path('../shared/__LINE__', __FILE__)
describe "The __LINE__ constant" do
- it "increments for each line" do
- cline = __LINE__
- __LINE__.should == cline + 1
- # comment is at cline + 2
- __LINE__.should == cline + 3
+ before :each do
+ ScratchPad.record []
end
- it "is eval aware" do
- eval("__LINE__").should == 1
- cmd =<<EOF
-# comment at line 1
-__LINE__
-EOF
- eval(cmd).should == 2
+ after :each do
+ ScratchPad.clear
end
+
+ it "equals the line number of the text inside an eval" do
+ eval <<-EOC
+ScratchPad << __LINE__
+
+# line 3
+
+ScratchPad << __LINE__
+ EOC
+
+ ScratchPad.recorded.should == [1, 5]
+ end
end
+
+describe "The __LINE__ constant" do
+ it_behaves_like :language___LINE__, :require, CodeLoadingSpecs::Method.new
+end
+
+describe "The __LINE__ constant" do
+ it_behaves_like :language___LINE__, :require, Kernel
+end
+
+describe "The __LINE__ constant" do
+ it_behaves_like :language___LINE__, :load, CodeLoadingSpecs::Method.new
+end
+
+describe "The __LINE__ constant" do
+ it_behaves_like :language___LINE__, :load, Kernel
+end
Modified: MacRuby/trunk/spec/frozen/language/loop_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/loop_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/loop_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The loop expression" do
it "repeats the given block until a break is called" do
Modified: MacRuby/trunk/spec/frozen/language/magic_comment_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/magic_comment_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/magic_comment_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
ruby_version_is "1.9" do
describe "Magic comment" do
Modified: MacRuby/trunk/spec/frozen/language/metaclass_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/metaclass_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/metaclass_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/../fixtures/class'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../../fixtures/class', __FILE__)
describe "self in a metaclass body (class << obj)" do
it "is TrueClass for true" do
Modified: MacRuby/trunk/spec/frozen/language/method_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/method_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/method_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# Why so many fixed arg tests? JRuby and I assume other Ruby impls have
# separate call paths for simple fixed arity methods. Testing up to five
Modified: MacRuby/trunk/spec/frozen/language/module_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/module_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/module_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
module LangModuleSpec
module Sub1; end
Modified: MacRuby/trunk/spec/frozen/language/next_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/next_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/next_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
class NextSpecs
def self.yielding_method(expected)
Modified: MacRuby/trunk/spec/frozen/language/not_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/not_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/not_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The not keyword" do
it "negates a `true' value" do
Modified: MacRuby/trunk/spec/frozen/language/numbers_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/numbers_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/numbers_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Ruby numbers in various ways" do
Modified: MacRuby/trunk/spec/frozen/language/or_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/or_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/or_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
-describe "The || statement" do
+describe "The || operator" do
it "evaluates to true if any of its operands are true" do
if false || true || nil
x = true
@@ -32,9 +32,22 @@
(false || ()).should be_nil
(() || ()).should be_nil
end
+
+ it "has a higher precedence than 'break' in 'break true || false'" do
+ # see also 'break true or false' below
+ lambda { break false || true }.call.should be_true
+ end
+
+ it "has a higher precedence than 'next' in 'next true || false'" do
+ lambda { next false || true }.call.should be_true
+ end
+
+ it "has a higher precedence than 'return' in 'return true || false'" do
+ lambda { return false || true }.call.should be_true
+ end
end
-describe "The or statement" do
+describe "The or operator" do
it "evaluates to true if any of its operands are true" do
x = nil
if false or true
@@ -61,4 +74,17 @@
(false or ()).should be_nil
(() or ()).should be_nil
end
+
+ it "has a lower precedence than 'break' in 'break true or false'" do
+ # see also 'break true || false' above
+ lambda { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/)
+ end
+
+ it "has a lower precedence than 'next' in 'next true or false'" do
+ lambda { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/)
+ end
+
+ it "has a lower precedence than 'return' in 'return true or false'" do
+ lambda { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/)
+ end
end
Modified: MacRuby/trunk/spec/frozen/language/order_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/order_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/order_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A method call" do
before :each do
Modified: MacRuby/trunk/spec/frozen/language/precedence_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/precedence_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/precedence_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# Specifying the behavior of operators in combination could
# lead to combinatorial explosion. A better way seems to be
Modified: MacRuby/trunk/spec/frozen/language/predefined_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/predefined_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/predefined_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# MacRuby TODO: We need StringIO for one spec: Predefined global $_ is set to the last line read by e.g. StringIO#gets
# require 'stringio'
Modified: MacRuby/trunk/spec/frozen/language/private_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/private_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/private_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/private'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/private', __FILE__)
describe "The private keyword" do
ruby_version_is ""..."1.9" do
Modified: MacRuby/trunk/spec/frozen/language/redo_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/redo_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/redo_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The redo statement" do
it "restarts block execution if used within block" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/anchors_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/anchors_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/anchors_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with anchors" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/back-references_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/back-references_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/back-references_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with back-references" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/character_classes_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/character_classes_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/character_classes_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexp with character classes" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/encoding_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with encoding modifiers" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/escapes_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/escapes_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/escapes_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with escape characters" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/grouping_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/grouping_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/grouping_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with grouping" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/interpolation_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/interpolation_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/interpolation_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with interpolation" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/modifiers_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/modifiers_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/modifiers_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with modifers" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/repetition_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/repetition_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/repetition_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path(File.dirname(__FILE__) + '/../fixtures/classes')
describe "Regexps with repetition" do
Modified: MacRuby/trunk/spec/frozen/language/regexp/versions/character_classes_1.9.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp/versions/character_classes_1.9.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp/versions/character_classes_1.9.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,4 @@
-# coding: utf-8
-
+# -*- encoding: utf-8 -*-
# The examples below are based on the definitions in
# http://unicode.org/reports/tr18/ , which was deemed authoritative in
# http://redmine.ruby-lang.org/issues/show/1889 .
@@ -22,11 +21,8 @@
"\u{0660}".match(/[[:alnum:]]/).to_a.should == ["\u{0660}"]
end
-not_compliant_on :macruby do
- # And also 1.9.2...
- it "matches Unicode marks with [[:alnum:]]" do
- "\u{36F}".match(/[[:alnum:]]/).to_a.should == ["\u{36F}"]
- end
+it "doesn't matches Unicode marks with [[:alnum:]]" do
+ "\u{36F}".match(/[[:alnum:]]/).should be_nil
end
it "doesn't match Unicode control characters with [[:alnum:]]" do
@@ -45,11 +41,8 @@
"\u{0660}".match(/[[:alpha:]]/).to_a.should == []
end
-not_compliant_on :macruby do
- # And also 1.9.2...
- it "matches Unicode marks with [[:alpha:]]" do
- "\u{36F}".match(/[[:alpha:]]/).to_a.should == ["\u{36F}"]
- end
+it "doesn't matches Unicode marks with [[:alpha:]]" do
+ "\u{36F}".match(/[[:alpha:]]/).should be_nil
end
it "doesn't match Unicode control characters with [[:alpha:]]" do
@@ -167,17 +160,12 @@
"\u{16}".match(/[[:graph:]]/).should be_nil
end
-not_compliant_on :macruby do
- it "doesn't match Unicode format characters with [[:graph:]]" do
- "\u{2060}".match(/[[:graph:]]/).should be_nil
- end
+it "match Unicode format characters with [[:graph:]]" do
+ "\u{2060}".match(/[[:graph:]]/).to_a.should == ["\u2060"]
end
-not_compliant_on :macruby do
- # And also 1.9.2...
- it "doesn't match Unicode private-use characters with [[:graph:]]" do
- "\u{E001}".match(/[[:graph:]]/).should be_nil
- end
+it "match Unicode private-use characters with [[:graph:]]" do
+ "\u{E001}".match(/[[:graph:]]/).to_a.should == ["\u{E001}"]
end
it "matches Unicode lowercase letter characters with [[:lower:]]" do
@@ -258,17 +246,12 @@
"\u{16}".match(/[[:print:]]/).should be_nil
end
-not_compliant_on :macruby do
- it "doesn't match Unicode format characters with [[:print:]]" do
- "\u{2060}".match(/[[:print:]]/).should be_nil
- end
+it "match Unicode format characters with [[:print:]]" do
+ "\u{2060}".match(/[[:print:]]/).to_a.should == ["\u{2060}"]
end
-not_compliant_on :macruby do
- # And 1.9.2...
- it "doesn't match Unicode private-use characters with [[:print:]]" do
- "\u{E001}".match(/[[:print:]]/).should be_nil
- end
+it "match Unicode private-use characters with [[:print:]]" do
+ "\u{E001}".match(/[[:print:]]/).to_a.should == ["\u{E001}"]
end
it "doesn't match Unicode lowercase letter characters with [[:punct:]]" do
@@ -493,11 +476,8 @@
"\u{36F}".match(/[[:word:]]/).to_a.should == ["\u{36F}"]
end
-not_compliant_on :macruby do
- # And 1.9.2...
- it "doesn't match Unicode Nl characters with [[:word:]]" do
- "\u{16EE}".match(/[[:word:]]/).should be_nil
- end
+it "match Unicode Nl characters with [[:word:]]" do
+ "\u{16EE}".match(/[[:word:]]/).to_a.should == ["\u{16EE}"]
end
it "doesn't match Unicode No characters with [[:word:]]" do
Modified: MacRuby/trunk/spec/frozen/language/regexp_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/regexp_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/regexp_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/classes', __FILE__)
describe "Literal Regexps" do
it "matches against $_ (last input) in a conditional if no explicit matchee provided" do
Modified: MacRuby/trunk/spec/frozen/language/rescue_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/rescue_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/rescue_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
class SpecificExampleException < StandardError
end
class OtherCustomException < StandardError
Modified: MacRuby/trunk/spec/frozen/language/retry_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/retry_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/retry_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The retry statement" do
it "re-executes the closest block" do
Modified: MacRuby/trunk/spec/frozen/language/return_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/return_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/return_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/return'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/return', __FILE__)
describe "The return keyword" do
it "returns any object directly" do
Added: MacRuby/trunk/spec/frozen/language/shared/__FILE__.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/shared/__FILE__.rb (rev 0)
+++ MacRuby/trunk/spec/frozen/language/shared/__FILE__.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -0,0 +1,35 @@
+describe :language___FILE__, :shared => true do
+ before :each do
+ CodeLoadingSpecs.spec_setup
+ @path = File.expand_path("file_fixture.rb", CODE_LOADING_DIR)
+ end
+
+ after :each do
+ CodeLoadingSpecs.spec_cleanup
+ end
+
+ it "equals the absolute path of a file loaded by an absolute path" do
+ @object.send(@method, @path).should be_true
+ ScratchPad.recorded.should == [@path]
+ end
+
+ ruby_version_is ""..."1.8.8" do
+ it "equals the relative path of a file loaded by a relative path" do
+ $LOAD_PATH << "."
+ Dir.chdir CODE_LOADING_DIR do
+ @object.send(@method, "file_fixture.rb").should be_true
+ end
+ ScratchPad.recorded.should == ["./file_fixture.rb"]
+ end
+ end
+
+ ruby_version_is "1.8.8" do
+ it "equals the absolute path of a file loaded by a relative path" do
+ $LOAD_PATH << "."
+ Dir.chdir CODE_LOADING_DIR do
+ @object.send(@method, "file_fixture.rb").should be_true
+ end
+ ScratchPad.recorded.should == [@path]
+ end
+ end
+end
Added: MacRuby/trunk/spec/frozen/language/shared/__LINE__.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/shared/__LINE__.rb (rev 0)
+++ MacRuby/trunk/spec/frozen/language/shared/__LINE__.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -0,0 +1,15 @@
+describe :language___LINE__, :shared => true do
+ before :each do
+ CodeLoadingSpecs.spec_setup
+ @path = File.expand_path("line_fixture.rb", CODE_LOADING_DIR)
+ end
+
+ after :each do
+ CodeLoadingSpecs.spec_cleanup
+ end
+
+ it "equals the line number of the text in a loaded file" do
+ @object.send(@method, @path).should be_true
+ ScratchPad.recorded.should == [1, 5]
+ end
+end
Modified: MacRuby/trunk/spec/frozen/language/splat_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/splat_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/splat_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "Splat operator" do
describe "used to assign a splatted object to an object" do
Modified: MacRuby/trunk/spec/frozen/language/string_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/string_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/string_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# Thanks http://www.zenspider.com/Languages/Ruby/QuickRef.html
@@ -150,12 +150,17 @@
"#{obj}".should == '42'
end
- it "interpolates the return value of Object#inspect, without ivars, if Object#to_s does not return a String instance" do
+ it "interpolates an implementation-dependent representation of an object that does not return a String from #to_s" do
obj = mock('to_s')
obj.stub!(:to_s).and_return(42)
- s = "#{obj}"[0..-2]
- s.should == obj.inspect[0, s.size]
+ # See rubyspec commit 787c132d by yugui. There is value in
+ # ensuring that this behavior works. So rather than removing
+ # this spec completely, the only thing that can be asserted
+ # is that if you interpolate an object that fails to return
+ # a String, you will still get a String and not raise an
+ # exception.
+ "#{obj}".should be_an_instance_of(String)
end
ruby_version_is '1.9' do
Modified: MacRuby/trunk/spec/frozen/language/super_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/super_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/super_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/super'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/super', __FILE__)
describe "The super keyword" do
it "calls the method on the calling class" do
@@ -129,4 +129,18 @@
# end
# end
# end
+
+ # Rubinius ticket github#157
+ it "calls method_missing when a superclass method is not found" do
+ lambda {
+ Super::MM_B.new.is_a?(Hash).should == false
+ }.should_not raise_error(NoMethodError)
+ end
+
+ # Rubinius ticket github#180
+ it "respects the original module a method is aliased from" do
+ lambda {
+ Super::Alias3.new.name3.should == [:alias2, :alias1]
+ }.should_not raise_error(RuntimeError)
+ end
end
Modified: MacRuby/trunk/spec/frozen/language/symbol_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/symbol_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/symbol_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "A Symbol literal" do
it "is a ':' followed by any number of valid characters" do
Modified: MacRuby/trunk/spec/frozen/language/throw_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/throw_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/throw_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The throw keyword" do
it "abandons processing" do
Modified: MacRuby/trunk/spec/frozen/language/undef_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/undef_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/undef_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
class UndefSpecClass
def meth(other);other;end
Modified: MacRuby/trunk/spec/frozen/language/unless_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/unless_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/unless_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
describe "The unless expression" do
it "evaluates the unless body when the expression is false" do
Modified: MacRuby/trunk/spec/frozen/language/until_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/until_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/until_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# until bool-expr [do]
# body
Modified: MacRuby/trunk/spec/frozen/language/variables_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/variables_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/variables_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/variables'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/variables', __FILE__)
# TODO: partition these specs into distinct cases based on the
# real parsed forms, not the superficial code forms.
@@ -227,11 +227,13 @@
b.should == 1
end
- it "returns the rhs values used for assignment as an array" do
- o = Object.new
- def o.masgn; a, b, c = 1, 2, 3; end
+ not_compliant_on :rubinius do
+ it "returns the rhs values used for assignment as an array" do
+ o = Object.new
+ def o.masgn; a, b, c = 1, 2, 3; end
- o.masgn.should == [1,2,3]
+ o.masgn.should == [1,2,3]
+ end
end
it "evaluates rhs left-to-right" do
@@ -1080,4 +1082,30 @@
instance.check_each_block
end
end
+
+describe "A local variable in a #define_method scope" do
+ ruby_bug '#1322', '1.8.7.228' do
+ it "shares the lexical scope containing the call to #define_method" do
+ # We need a new scope to reproduce this bug.
+ handle = mock("handle for containing scope method")
+
+ def handle.produce_bug
+ local = 1
+
+ klass = Class.new
+ klass.send :define_method, :set_local do |arg|
+ lambda { local = 2 }.call
+ end
+
+ # We must call with at least one argument to reproduce the bug.
+ klass.new.set_local(nil)
+
+ local
+ end
+
+ handle.produce_bug.should == 2
+ end
+ end
+end
+
language_version __FILE__, "variables"
Modified: MacRuby/trunk/spec/frozen/language/versions/array_1.9.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/versions/array_1.9.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/versions/array_1.9.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -3,6 +3,14 @@
["foo", "bar" => :baz].should == ["foo", {"bar" => :baz}]
[1, 2, 3 => 6, 4 => 24].should == [1, 2, {3 => 6, 4 => 24}]
end
+
+ it "[] treats splatted nil as no element" do
+ [*nil].should == []
+ [1, *nil].should == [1]
+ [1, 2, *nil].should == [1, 2]
+ [1, *nil, 3].should == [1, 3]
+ [*nil, *nil, *nil].should == []
+ end
end
describe "The unpacking splat operator (*)" do
Modified: MacRuby/trunk/spec/frozen/language/versions/regexp_1.9.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/versions/regexp_1.9.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/versions/regexp_1.9.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
+require File.expand_path('../../../spec_helper', __FILE__)
describe "Literal Regexps" do
it 'supports (?<= ) (positive lookbehind)' do
Modified: MacRuby/trunk/spec/frozen/language/while_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/while_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/while_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require File.expand_path('../../spec_helper', __FILE__)
# while bool-expr [do]
# body
Modified: MacRuby/trunk/spec/frozen/language/yield_spec.rb
===================================================================
--- MacRuby/trunk/spec/frozen/language/yield_spec.rb 2010-03-28 19:54:58 UTC (rev 3874)
+++ MacRuby/trunk/spec/frozen/language/yield_spec.rb 2010-03-28 19:55:40 UTC (rev 3875)
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/yield'
+require File.expand_path('../../spec_helper', __FILE__)
+require File.expand_path('../fixtures/yield', __FILE__)
describe "Assignment via yield" do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100328/453bfd2d/attachment-0001.html>
More information about the macruby-changes
mailing list