[macruby-changes] [1687] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Mon Jun 1 13:50:50 PDT 2009
Revision: 1687
http://trac.macosforge.org/projects/ruby/changeset/1687
Author: eloy.de.enige at gmail.com
Date: 2009-06-01 13:50:49 -0700 (Mon, 01 Jun 2009)
Log Message:
-----------
Updated RubySpec to 5d6614b032b1ca4c1e27c9176219628723f3485a
Modified Paths:
--------------
MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb
MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb
MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb
MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/string/chomp_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/delete_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/string/element_set_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/entries_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/index_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/insert_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/lstrip_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/replace_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/reverse_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/rindex_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/rstrip_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/shared/concat.rb
MacRuby/branches/experimental/spec/frozen/core/string/shared/succ.rb
MacRuby/branches/experimental/spec/frozen/core/string/slice_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/string/squeeze_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/strip_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/string/to_a_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/tr_s_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/tr_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/chomp_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/lstrip_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/reverse_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rindex_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rstrip_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/strip_tags.txt
MacRuby/branches/experimental/spec/frozen/upstream
Added Paths:
-----------
MacRuby/branches/experimental/spec/frozen/core/array/combination_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/cycle_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/permutation_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/core/array/product_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/
MacRuby/branches/experimental/spec/frozen/core/fiber/alive_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/current_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/new_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/shared/
MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/transfer_spec.rb
MacRuby/branches/experimental/spec/frozen/core/fiber/yield_spec.rb
MacRuby/branches/experimental/spec/frozen/core/string/bytes_spec_disabled.rb
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/combination_tags.txt
MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/cycle_tags.txt
Removed Paths:
-------------
MacRuby/branches/experimental/spec/frozen/core/array/combination.rb
MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb
MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb
MacRuby/branches/experimental/spec/frozen/core/array/product.rb
MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb
Modified: MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb
===================================================================
--- MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/rakelib/upstream_git_repo_tasks.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -101,25 +101,15 @@
end
namespace :upstream do
- desc "Creates all individual patches in #{@local_dir}/upstream_patches since upstream revision: #{upstream_rev}"
- task :patches do
- create_patches = "git format-patch --numbered --output-directory #{File.join(@local_dir, 'upstream_patches')} #{upstream_rev}"
+ desc "Creates patch since upstream revision `#{upstream_rev}' and applies it"
+ task :patch do
+ patch = File.join(@local_dir, 'upstream_patch.diff')
Dir.chdir(@upstream_dir) do
git_checkout('master')
- sh create_patches
+ sh "git diff #{upstream_rev} > #{patch}"
end
- end
-
- namespace :patches do
- desc "Applies all patches in #{@local_dir}/upstream_patches"
- task :apply do
- Dir.chdir(@local_dir) do
- patches = Dir.glob("upstream_patches/*.patch")
- patches.sort_by { |name| File.basename(name)[0,4] }.each do |patch|
- puts "\nApplying patch: #{File.basename(patch)}"
- sh "/usr/bin/patch -p1 < #{patch}"
- end
- end
+ Dir.chdir(@local_dir) do
+ sh "/usr/bin/patch -p1 < #{patch}"
end
end
Deleted: MacRuby/branches/experimental/spec/frozen/core/array/combination.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/combination.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/combination.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,30 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-
-describe "Array#combination" do
- ruby_version_is "1.8.7" do
- it "returns an enumerator when no block is provided" do
- [1, 2, 3, 4].combination(2).should be_kind_of(enumerator_class)
- end
-
- it "returns self when a block is given" do
- a = [1, 2, 3, 4]
- a.combination(2){}.should equal(a)
- end
-
- it "yields nothing for out of bounds length and return self" do
- a = [1, 2, 3, 4]
- a.combination(5).to_a.should == []
- a.combination(-1).to_a.should == []
- end
-
- it "yields the excepted combinations" do
- a = [1, 2, 3, 4]
- a.combination(3).to_a.sort.should == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
- end
-
- if "yields [] when length is 0"
- [1,2,3].combination(0).to_a.should == [[]] # one combination of length 0
- [].combination(0).to_a.should == [[]] # one combination of length 0
- end
- end
-end
\ No newline at end of file
Copied: MacRuby/branches/experimental/spec/frozen/core/array/combination_spec.rb (from rev 1685, MacRuby/branches/experimental/spec/frozen/core/array/combination.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/combination_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/combination_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,30 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+describe "Array#combination" do
+ ruby_version_is "1.8.7" do
+ it "returns an enumerator when no block is provided" do
+ [1, 2, 3, 4].combination(2).should be_kind_of(enumerator_class)
+ end
+
+ it "returns self when a block is given" do
+ a = [1, 2, 3, 4]
+ a.combination(2){}.should equal(a)
+ end
+
+ it "yields nothing for out of bounds length and return self" do
+ a = [1, 2, 3, 4]
+ a.combination(5).to_a.should == []
+ a.combination(-1).to_a.should == []
+ end
+
+ it "yields the excepted combinations" do
+ a = [1, 2, 3, 4]
+ a.combination(3).to_a.sort.should == [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
+ end
+
+ if "yields [] when length is 0"
+ [1,2,3].combination(0).to_a.should == [[]] # one combination of length 0
+ [].combination(0).to_a.should == [[]] # one combination of length 0
+ end
+ end
+end
\ No newline at end of file
Deleted: MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,21 +0,0 @@
-describe "Enumerable#cycle" do
- ruby_version_is '1.8.7' do
- it "returns nil and does nothing for non positive n or empty arrays" do
- [1,2,3].cycle(0){ throw "ball"}.should be_nil
- [].cycle(0){ throw "ball"}.should be_nil
- end
-
- it "cycle as many times as requested" do
- [1,2,3].cycle(2).to_a.should == [1,2,3,1,2,3]
- end
-
- it "loop indefinitely if no n" do
- bomb = 10
- [1,2,3].cycle do
- bomb -= 1
- break 42 if bomb <= 0
- end.should == 42
- bomb.should == 0
- end
- end
-end
Copied: MacRuby/branches/experimental/spec/frozen/core/array/cycle_spec.rb (from rev 1685, MacRuby/branches/experimental/spec/frozen/core/array/cycle.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/cycle_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/cycle_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,21 @@
+describe "Enumerable#cycle" do
+ ruby_version_is '1.8.7' do
+ it "returns nil and does nothing for non positive n or empty arrays" do
+ [1,2,3].cycle(0){ throw "ball"}.should be_nil
+ [].cycle(0){ throw "ball"}.should be_nil
+ end
+
+ it "cycle as many times as requested" do
+ [1,2,3].cycle(2).to_a.should == [1,2,3,1,2,3]
+ end
+
+ it "loop indefinitely if no n" do
+ bomb = 10
+ [1,2,3].cycle do
+ bomb -= 1
+ break 42 if bomb <= 0
+ end.should == 42
+ bomb.should == 0
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/index_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,7 +1,34 @@
require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
-require File.dirname(__FILE__) + '/shared/index'
describe "Array#index" do
- it_behaves_like :array_index, :index
+ it "returns the index of the first element == to object" do
+ x = mock('3')
+ def x.==(obj) 3 == obj; end
+
+ [2, x, 3, 1, 3, 1].index(3).should == 1
+ [2, 3.0, 3, x, 1, 3, 1].index(x).should == 1
+ end
+
+ it "returns 0 if first element == to object" do
+ [2, 1, 3, 2, 5].index(2).should == 0
+ end
+
+ it "returns size-1 if only last element == to object" do
+ [2, 1, 3, 1, 5].index(5).should == 4
+ end
+
+ it "returns nil if no element == to object" do
+ [2, 1, 1, 1, 1].index(3).should == nil
+ end
+
+ ruby_version_is "1.8.7" do
+ it "accepts a block instead of an argument" do
+ [4, 2, 1, 5, 1, 3].index {|x| x < 2}.should == 2
+ end
+
+ it "ignore the block if there is an argument" do
+ [4, 2, 1, 5, 1, 3].index(5) {|x| x < 2}.should == 3
+ end
+
+ end
end
Deleted: MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/key_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,9 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
-require File.dirname(__FILE__) + '/shared/index'
-
-describe "Array#key" do
- ruby_version_is '1.9' do
- it_behaves_like :array_index, :key
- end
-end
Added: MacRuby/branches/experimental/spec/frozen/core/array/permutation_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/permutation_spec_disabled.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/permutation_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,92 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+
+ruby_version_is "1.8.7" do
+ describe "Array#permutation" do
+
+ before(:each) do
+ @numbers = (1..3).to_a
+ @yielded = []
+ end
+
+ it "returns an Enumerator of all permutations when called without a block or arguments" do
+ enum = @numbers.permutation
+ enum.should be_kind_of(Enumerable)
+ enum.to_a.sort.should == [
+ [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]
+ ].sort
+ end
+
+ it "returns an Enumerator of permutations of given length when called with an argument but no block" do
+ enum = @numbers.permutation(1)
+ enum.should be_kind_of(Enumerable)
+ enum.to_a.sort.should == [[1],[2],[3]]
+ end
+
+ it "yields all permutations to the block then returns self when called with block but no arguments" do
+ array = @numbers.permutation {|n| @yielded << n}
+ array.should be_an_instance_of(Array)
+ array.sort.should == @numbers.sort
+ @yielded.sort.should == [
+ [1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]
+ ].sort
+ end
+
+ it "yields all permutations of given length to the block then returns self when called with block and argument" do
+ array = @numbers.permutation(2) {|n| @yielded << n}
+ array.should be_an_instance_of(Array)
+ array.sort.should == @numbers.sort
+ @yielded.sort.should == [[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]].sort
+ end
+
+ it "returns the empty permutation ([[]]) when the given length is 0" do
+ @numbers.permutation(0).to_a.should == [[]]
+ @numbers.permutation(0) { |n| @yielded << n }
+ @yielded.should == [[]]
+ end
+
+ it "returns the empty permutation([]) when called on an empty Array" do
+ [].permutation.to_a.should == [[]]
+ [].permutation { |n| @yielded << n }
+ @yielded.should == [[]]
+ end
+
+ it "returns no permutations when the given length has no permutations" do
+ @numbers.permutation(9).entries.size == 0
+ @numbers.permutation(9) { |n| @yielded << n }
+ @yielded.should == []
+ end
+
+ it "handles duplicate elements correctly" do
+ @numbers << 1
+ @numbers.permutation(2).sort.should == [
+ [1,1],[1,1],[1,2],[1,2],[1,3],[1,3],
+ [2,1],[2,1],[2,3],
+ [3,1],[3,1],[3,2]
+ ].sort
+ end
+
+ it "handles nested Arrays correctly" do
+ # The ugliness is due to the order of permutations returned by
+ # permutation being undefined combined with #sort croaking on Arrays of
+ # Arrays.
+ @numbers << [4,5]
+ got = @numbers.permutation(2).to_a
+ expected = [
+ [1, 2], [1, 3], [1, [4, 5]],
+ [2, 1], [2, 3], [2, [4, 5]],
+ [3, 1], [3, 2], [3, [4, 5]],
+ [[4, 5], 1], [[4, 5], 2], [[4, 5], 3]
+ ]
+ expected.each {|e| got.include?(e).should be_true}
+ got.size.should == expected.size
+ end
+
+ it "truncates Float arguments" do
+ @numbers.permutation(3.7).to_a.sort.should ==
+ @numbers.permutation(3).to_a.sort
+ end
+
+ end
+end
Deleted: MacRuby/branches/experimental/spec/frozen/core/array/product.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/product.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/product.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,22 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes'
-
-describe "Array#product" do
- ruby_version_is "1.9" do
- it "returns convert arguments using :to_ary" do
- lambda{ [1].product(2..3) }.should raise_error(TypeError)
- ar = ArraySpecs::ArrayConvertable.new(2,3)
- [1].product(ar).should == [[1,2],[1,3]]
- ar.called.should == :to_ary
- end
-
- it "returns the expected result" do
- [1,2].product([3,4,5],[6,8]).should == [[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8],
- [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]]
- end
-
- it "has no required argument" do
- [1,2].product.should == [[1],[2]]
- end
- end
-end
\ No newline at end of file
Copied: MacRuby/branches/experimental/spec/frozen/core/array/product_spec.rb (from rev 1685, MacRuby/branches/experimental/spec/frozen/core/array/product.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/product_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/array/product_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes'
+
+describe "Array#product" do
+ ruby_version_is "1.9" do
+ it "returns convert arguments using :to_ary" do
+ lambda{ [1].product(2..3) }.should raise_error(TypeError)
+ ar = ArraySpecs::ArrayConvertable.new(2,3)
+ [1].product(ar).should == [[1,2],[1,3]]
+ ar.called.should == :to_ary
+ end
+
+ it "returns the expected result" do
+ [1,2].product([3,4,5],[6,8]).should == [[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8],
+ [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]]
+ end
+
+ it "has no required argument" do
+ [1,2].product.should == [[1],[2]]
+ end
+ end
+end
\ No newline at end of file
Deleted: MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/array/shared/index.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,32 +0,0 @@
-describe :array_index, :shared => true do
- it "returns the index of the first element == to object" do
- x = mock('3')
- def x.==(obj) 3 == obj; end
-
- [2, x, 3, 1, 3, 1].send(@method, 3).should == 1
- [2, 3.0, 3, x, 1, 3, 1].send(@method, x).should == 1
- end
-
- it "returns 0 if first element == to object" do
- [2, 1, 3, 2, 5].send(@method, 2).should == 0
- end
-
- it "returns size-1 if only last element == to object" do
- [2, 1, 3, 1, 5].send(@method, 5).should == 4
- end
-
- it "returns nil if no element == to object" do
- [2, 1, 1, 1, 1].send(@method, 3).should == nil
- end
-
- ruby_version_is "1.8.7" do
- it "accepts a block instead of an argument" do
- [4, 2, 1, 5, 1, 3].send(@method){|x| x < 2}.should == 2
- end
-
- it "ignore the block if there is an argument" do
- [4, 2, 1, 5, 1, 3].send(@method, 5){|x| x < 2}.should == 3
- end
-
- end
-end
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/alive_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/alive_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/alive_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,53 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ require 'fiber'
+
+ describe "Fiber#alive?" do
+
+ # 1.9.1 returns 0 for true
+ ruby_bug "#1547", "1.9.2" do
+ it "returns true for a Fiber that hasn't had #resume called" do
+ fiber = Fiber.new { true }
+ fiber.alive?.should be_true
+ end
+
+ # FIXME: Better description?
+ it "returns true for a Fiber that's yielded to the caller" do
+ fiber = Fiber.new { Fiber.yield }
+ fiber.resume
+ fiber.alive?.should be_true
+ end
+
+ it "returns true when called from its Fiber" do
+ fiber = Fiber.new { fiber.alive?.should be_true }
+ fiber.resume
+ end
+ end
+
+ it "doesn't invoke the block associated with the Fiber" do
+ offthehook = mock('do not call')
+ offthehook.should_not_receive(:ring)
+ fiber = Fiber.new { offthehook.ring }
+ fiber.alive?
+ end
+
+ it "returns false for a Fiber that's dead" do
+ fiber = Fiber.new { true }
+ fiber.resume
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ end
+
+ it "always returns false for a dead Fiber" do
+ fiber = Fiber.new { true }
+ fiber.resume
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ lambda { fiber.resume }.should raise_error(FiberError)
+ fiber.alive?.should be_false
+ fiber.alive?.should be_false
+ end
+
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/current_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/current_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/current_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,62 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Fiber.current" do
+
+ require 'fiber'
+
+ it "returns the root Fiber when called outside of a Fiber" do
+ root = Fiber.current
+ root.should be_an_instance_of(Fiber)
+ # We can always transfer to the root Fiber; it will never die
+ 5.times do
+ root.transfer.should be_nil
+ root.alive?.should_not be_false #Workaround for bug #1547
+ end
+ end
+
+ it "returns the current Fiber when called from a Fiber" do
+ fiber = Fiber.new do
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should == fiber
+ this.alive?.should_not be_false # Workaround for bug #1547
+ end
+ fiber.resume
+ end
+
+ it "returns the current Fiber when called from a Fiber that transferred to another" do
+
+ states = []
+ fiber = Fiber.new do
+ states << :fiber
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should === fiber
+ this.alive?.should_not be_false # Workaround for bug #1547
+ end
+
+ fiber2 = Fiber.new do
+ states << :fiber2
+ fiber.transfer
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should === fiber2
+ this.alive?.should_not be_false # Workaround for bug #1547
+ end
+
+ fiber3 = Fiber.new do
+ states << :fiber3
+ fiber2.transfer
+ this = Fiber.current
+ this.should be_an_instance_of(Fiber)
+ this.should === fiber3
+ this.alive?.should_not be_false # Workaround for bug #1547
+ fiber2.transfer
+ end
+
+ fiber3.resume
+ states.should == [:fiber3, :fiber2, :fiber]
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/new_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/new_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/new_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,48 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Fiber.new" do
+ it "creates a fiber from the given block" do
+ fiber = Fiber.new {}
+ fiber.should be_an_instance_of(Fiber)
+ end
+
+ it "raises an ArgumentError if called without a block" do
+ lambda { Fiber.new }.should raise_error(ArgumentError)
+ end
+
+ it "does not invoke the block" do
+ invoked = false
+ fiber = Fiber.new { invoked = true }
+ invoked.should be_false
+ end
+
+ it "closes over lexical environments" do
+ o = Object.new
+ def o.f
+ a = 1
+ f = Fiber.new { a = 2 }
+ f.resume
+ a
+ end
+ o.f.should == 2
+ end
+
+ it "escapes an inner ensure block" do
+ f = Fiber.new do
+ begin
+ :begin
+ rescue
+ :rescue
+ ensure
+ :ensure
+ end
+ end
+ f.resume.should == :begin
+ end
+
+ it "raises a SyntaxError when the block contains a retry statement" do
+ lambda { eval 'Fiber.new { retry; }' }.should raise_error(SyntaxError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/resume_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/resume'
+
+ruby_version_is "1.9" do
+ describe "Fiber#resume" do
+
+ it_behaves_like(:resume, :transfer)
+
+ it "returns control to the calling Fiber if called from one" do
+ fiber1 = Fiber.new { :fiber1 }
+ fiber2 = Fiber.new { fiber1.resume; :fiber2 }
+ fiber2.resume.should == :fiber2
+ end
+
+ it "raises a FiberError if the Fiber has transfered control to another Fiber" do
+ fiber1 = Fiber.new { true }
+ fiber2 = Fiber.new { fiber1.transfer; Fiber.yield }
+ fiber2.resume
+ lambda { fiber2.resume }.should raise_error(FiberError)
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/shared/resume.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,71 @@
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe :resume, :shared => :true do
+
+ it "can be invoked from the root Fiber" do
+ fiber = Fiber.new { :fiber }
+ fiber.send(@method).should == :fiber
+ end
+
+ it "passes control to the beginning of the block on first invocation" do
+ invoked = false
+ fiber = Fiber.new { invoked = true }
+ fiber.send(@method)
+ invoked.should be_true
+ end
+
+ it "returns the last value encountered on first invocation" do
+ fiber = Fiber.new { false; true }
+ fiber.send(@method).should be_true
+ end
+
+ it "runs until the end of the block or Fiber.yield on first invocation" do
+ obj = mock('obj')
+ obj.should_receive(:do).once
+ fiber = Fiber.new { 1 + 2; a = "glark"; obj.do }
+ fiber.send(@method)
+
+ obj = mock('obj')
+ obj.should_not_receive(:do)
+ fiber = Fiber.new { 1 + 2; Fiber.yield; obj.do }
+ fiber.send(@method)
+ end
+
+ it "resumes from the last call to Fiber.yield on subsequent invocations" do
+ fiber = Fiber.new { Fiber.yield :first; :second }
+ fiber.send(@method).should == :first
+ fiber.send(@method).should == :second
+ end
+
+ it "accepts any number of arguments" do
+ fiber = Fiber.new { |a| }
+ lambda { fiber.send(@method, *(1..10).to_a) }.should_not raise_error
+ end
+
+ it "sets the block parameters to its arguments on the first invocation" do
+ first = mock('first')
+ first.should_receive(:arg).with(:first).twice
+ fiber = Fiber.new { |arg| first.arg arg; Fiber.yield; first.arg arg; }
+ fiber.send(@method, :first)
+ fiber.send(@method, :second)
+ end
+
+ it "raises a FiberError if the Fiber is dead" do
+ fiber = Fiber.new { true }
+ fiber.send(@method)
+ lambda { fiber.send(@method) }.should raise_error(FiberError)
+ end
+
+ it "raises a LocalJumpError if the block includes a return statement" do
+ fiber = Fiber.new { return; }
+ lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
+ end
+
+ it "raises a LocalJumpError if the block includes a break statement" do
+ fiber = Fiber.new { break; }
+ lambda { fiber.send(@method) }.should raise_error(LocalJumpError)
+ end
+
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/transfer_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/transfer_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/transfer_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,44 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/shared/resume'
+
+ruby_version_is "1.9" do
+ describe "Fiber#transfer" do
+
+ require 'fiber'
+
+ it_behaves_like(:resume, :transfer)
+
+ it "transfers control from one Fiber to another when called from a Fiber" do
+ fiber1 = Fiber.new { :fiber1 }
+ fiber2 = Fiber.new { fiber1.transfer; :fiber2 }
+ fiber2.resume.should == :fiber1
+ end
+
+ it "can be invoked from the same Fiber it transfers control to" do
+ states = []
+ fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
+ fiber.transfer
+ states.should == [:start, :end]
+
+ states = []
+ fiber = Fiber.new { states << :start; fiber.transfer; states << :end }
+ fiber.resume
+ states.should == [:start, :end]
+ end
+
+ it "can transfer control to a Fiber that has transfered to another Fiber" do
+ states = []
+ fiber1 = Fiber.new { states << :fiber1 }
+ fiber2 = Fiber.new { states << :fiber2_start; fiber1.transfer; states << :fiber2_end}
+ fiber2.resume.should == [:fiber2_start, :fiber1]
+ fiber2.transfer.should == [:fiber2_start, :fiber1, :fiber2_end]
+ end
+
+ ruby_bug "#1548", "1.9.2" do
+ it "raises a FiberError when transferring to a Fiber which resumes itself" do
+ fiber = Fiber.new { fiber.resume }
+ lambda { fiber.transfer }.should raise_error(FiberError)
+ end
+ end
+ end
+end
Added: MacRuby/branches/experimental/spec/frozen/core/fiber/yield_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/fiber/yield_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/fiber/yield_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,35 @@
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.9" do
+ describe "Fiber.yield" do
+
+ it "passes control to the Fiber's caller" do
+ step = 0
+ fiber = Fiber.new { step = 1; Fiber.yield; step = 2; Fiber.yield; step = 3 }
+ fiber.resume
+ step.should == 1
+ fiber.resume
+ step.should == 2
+ end
+
+ it "returns its arguments to the caller" do
+ fiber = Fiber.new { true; Fiber.yield :glark; true }
+ fiber.resume.should == :glark
+ end
+
+ it "returns nil to the caller if given no arguments" do
+ fiber = Fiber.new { true; Fiber.yield; true }
+ fiber.resume.should be_nil
+ end
+
+ it "returns to the Fiber the value of the #resume call that invoked it" do
+ fiber = Fiber.new { Fiber.yield.should == :caller }
+ fiber.resume
+ fiber.resume :caller
+ end
+
+ it "raises a FiberError if called from the root Fiber" do
+ lambda{ Fiber.yield }.should raise_error(FiberError)
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_key_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -17,6 +17,5 @@
keys.should == h.keys
end
- it_behaves_like(:hash_iteration_modifying, :each_key)
it_behaves_like(:hash_iteration_no_block, :each_key)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_pair_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -13,6 +13,5 @@
all_args.sort.should == [[1, 2], [3, 4]]
end
- it_behaves_like(:hash_iteration_modifying, :each_pair)
it_behaves_like(:hash_iteration_no_block, :each_pair)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -30,6 +30,5 @@
values.should == h.values
end
- it_behaves_like(:hash_iteration_modifying, :each)
it_behaves_like(:hash_iteration_no_block, :each)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/each_value_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -17,6 +17,5 @@
values.should == h.values
end
- it_behaves_like(:hash_iteration_modifying, :each_value)
it_behaves_like(:hash_iteration_no_block, :each_value)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/merge_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -53,7 +53,6 @@
merge_pairs.should == each_pairs
end
- it_behaves_like(:hash_iteration_modifying, :merge)
end
describe "Hash#merge!" do
@@ -72,8 +71,4 @@
}.should_not raise_error(RuntimeError)
end
end
-
- compliant_on :rubinius do
- it_behaves_like(:hash_iteration_modifying, :merge!)
- end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/select_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -61,5 +61,4 @@
end
end
- it_behaves_like(:hash_iteration_modifying, :select)
end
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/shared/iteration.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,28 +1,3 @@
-describe :hash_iteration_modifying, :shared => true do
- # TODO: Revise this test as per the outcome of
- # http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/23630
- ruby_bug "ruby-core[#23630]", "1.9.129" do
- it "does not affect yielded items by removing the current element" do
- hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
- big_hash = new_hash
- 100.times { |k| big_hash[k.to_s] = k }
- n = 3
-
- h = Array.new(n) { hsh.dup }
- args = Array.new(n) { |i| @method.to_s[/merge|update/] ? [h[i]] : [] }
- r = Array.new(n) { [] }
-
- h[0].send(@method, *args[0]) { |*x| r[0] << x; true }
- h[1].send(@method, *args[1]) { |*x| r[1] << x; h[1].shift; true }
- h[2].send(@method, *args[2]) { |*x| r[2] << x; h[2].delete(h[2].keys.first); true }
-
- r[1..-1].each do |yielded|
- yielded.should == r[0]
- end
- end
- end
-end
-
describe :hash_iteration_no_block, :shared => true do
before(:each) do
@hsh = new_hash(1 => 2, 3 => 4, 5 => 6)
Modified: MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/hash/update_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,12 +1,7 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/fixtures/classes'
-require File.dirname(__FILE__) + '/shared/iteration'
require File.dirname(__FILE__) + '/shared/update'
describe "Hash#update" do
it_behaves_like(:hash_update, :update)
-
- compliant_on :rubinius do
- it_behaves_like(:hash_iteration_modifying, :update)
- end
end
Added: MacRuby/branches/experimental/spec/frozen/core/string/bytes_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/bytes_spec_disabled.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/bytes_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1,53 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+ruby_version_is "1.8.7" do
+ describe "String#bytes" do
+ before(:each) do
+ @utf8 = "東京"
+ @ascii = 'Tokyo'
+ @utf8_ascii = @utf8 + @ascii
+ end
+
+ it "returns an Enumerator when no block is given" do
+ @utf8.bytes.should be_kind_of(Enumerable)
+ end
+
+ it "yields each byte to a block if one is given, returning self" do
+ bytes = []
+ @utf8.bytes {|b| bytes << b}.should == @utf8
+ bytes.should == @utf8.bytes.to_a
+ end
+
+ it "returns #bytesize bytes" do
+ @utf8_ascii.bytes.to_a.size.should == @utf8_ascii.bytesize
+ end
+
+ it "returns bytes as Fixnums" do
+ @ascii.bytes.to_a.each {|b| b.should be_an_instance_of(Fixnum)}
+ @utf8_ascii.bytes { |b| b.should be_an_instance_of(Fixnum) }
+ end
+
+
+ it "agrees with #unpack('C*')" do
+ @utf8_ascii.bytes.to_a.should == @utf8_ascii.unpack("C*")
+ end
+
+ it "yields/returns no bytes for the empty string" do
+ ''.bytes.to_a.should == []
+ end
+
+ # #getbyte and #force_encoding are 1.9 methods
+ ruby_version_is "1.9" do
+ it "agrees with #getbyte" do
+ @utf8_ascii.bytes.to_a.each_with_index do |byte,index|
+ byte.should == @utf8_ascii.getbyte(index)
+ end
+ end
+
+ it "is unaffected by #force_encoding" do
+ @utf8.force_encoding('ASCII').bytes.to_a.should == @utf8.bytes.to_a
+ end
+ end
+ end
+end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec_disabled.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/capitalize_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -45,10 +45,21 @@
"H".capitalize!.should == nil
end
- it "raises a TypeError when self is frozen" do
- ["", "Hello", "hello"].each do |a|
- a.freeze
- lambda { a.capitalize! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ ["", "Hello", "hello"].each do |a|
+ a.freeze
+ lambda { a.capitalize! }.should raise_error(TypeError)
+ end
end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ ["", "Hello", "hello"].each do |a|
+ a.freeze
+ lambda { a.capitalize! }.should raise_error(RuntimeError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/chomp_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/chomp_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/chomp_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -134,13 +134,27 @@
"hello".chomp!(nil).should == nil
end
- it "raises a TypeError when self is frozen" do
- a = "string\n\r"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "string\n\r"
+ a.freeze
- lambda { a.chomp! }.should raise_error(TypeError)
+ lambda { a.chomp! }.should raise_error(TypeError)
- a.chomp!(nil) # ok, no change
- a.chomp!("x") # ok, no change
+ a.chomp!(nil) # ok, no change
+ a.chomp!("x") # ok, no change
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "string\n\r"
+ a.freeze
+
+ lambda { a.chomp! }.should raise_error(RuntimeError)
+
+ a.chomp!(nil) # ok, no change
+ a.chomp!("x") # ok, no change
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/chop_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -63,13 +63,27 @@
"".chop!.should == nil
end
- it "raises a TypeError when self is frozen" do
- a = "string\n\r"
- a.freeze
- lambda { a.chop! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "string\n\r"
+ a.freeze
+ lambda { a.chop! }.should raise_error(TypeError)
- a = ""
- a.freeze
- a.chop! # ok, no change
+ a = ""
+ a.freeze
+ a.chop! # ok, no change
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "string\n\r"
+ a.freeze
+ lambda { a.chop! }.should raise_error(RuntimeError)
+
+ a = ""
+ a.freeze
+ a.chop! # ok, no change
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/delete_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/delete_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/delete_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -91,11 +91,23 @@
a.should == "hello"
end
- it "raises a TypeError when self is frozen" do
- a = "hello"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "hello"
+ a.freeze
- lambda { a.delete!("") }.should raise_error(TypeError)
- lambda { a.delete!("aeiou", "^e") }.should raise_error(TypeError)
+ lambda { a.delete!("") }.should raise_error(TypeError)
+ lambda { a.delete!("aeiou", "^e") }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "hello"
+ a.freeze
+
+ lambda { a.delete!("") }.should raise_error(RuntimeError)
+ lambda { a.delete!("aeiou", "^e") }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec_disabled.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/downcase_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -44,8 +44,17 @@
a.should == "hello"
end
- it "raises a TypeError when self is frozen" do
- lambda { "HeLlo".freeze.downcase! }.should raise_error(TypeError)
- lambda { "hello".freeze.downcase! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ lambda { "HeLlo".freeze.downcase! }.should raise_error(TypeError)
+ lambda { "hello".freeze.downcase! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ lambda { "HeLlo".freeze.downcase! }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.downcase! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/element_set_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/element_set_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/element_set_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -74,12 +74,23 @@
lambda { "hi"[0] = obj }.should raise_error(TypeError)
end
- it "raises a TypeError when self is frozen" do
- a = "hello"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "hello"
+ a.freeze
- lambda { a[0] = ?b }.should raise_error(TypeError)
+ lambda { a[0] = ?b }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "hello"
+ a.freeze
+
+ lambda { a[0] = ?b }.should raise_error(RuntimeError)
+ end
+ end
end
describe "String#[]= with String" do
@@ -126,13 +137,24 @@
str.should == "hello"
end
- it "raises a TypeError when self is frozen" do
- a = "hello"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "hello"
+ a.freeze
- lambda { a[0] = "bam" }.should raise_error(TypeError)
+ lambda { a[0] = "bam" }.should raise_error(TypeError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "hello"
+ a.freeze
+
+ lambda { a[0] = "bam" }.should raise_error(RuntimeError)
+ end
+ end
+
it "calls to_int on index" do
str = "hello"
str[0.5] = "hi "
Modified: MacRuby/branches/experimental/spec/frozen/core/string/entries_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/entries_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/entries_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,6 +1,8 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/shared/to_a'
-describe "String#entries" do
- it_behaves_like :string_to_a, :entries
+ruby_version_is ""..."1.9" do
+ describe "String#entries" do
+ it_behaves_like :string_to_a, :entries
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/gsub_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -356,14 +356,27 @@
a.should == "hello"
end
- it "raises a TypeError when self is frozen" do
- s = "hello"
- s.freeze
-
- s.gsub!(/ROAR/, "x") # ok
- lambda { s.gsub!(/e/, "e") }.should raise_error(TypeError)
- lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ s = "hello"
+ s.freeze
+
+ s.gsub!(/ROAR/, "x") # ok
+ lambda { s.gsub!(/e/, "e") }.should raise_error(TypeError)
+ lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ s = "hello"
+ s.freeze
+
+ s.gsub!(/ROAR/, "x") # ok
+ lambda { s.gsub!(/e/, "e") }.should raise_error(RuntimeError)
+ lambda { s.gsub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
+ end
+ end
end
describe "String#gsub! with pattern and block" do
Modified: MacRuby/branches/experimental/spec/frozen/core/string/index_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/index_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/index_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -19,78 +19,80 @@
end
end
-describe "String#index with Fixnum" do
- it "returns the index of the first occurrence of the given character" do
- "hello".index(?e).should == 1
- "hello".index(?l).should == 2
- end
-
- it "character values over 255 (256th ASCII character) always result in nil" do
- # A naive implementation could try to use % 256
- "hello".index(?e + 256 * 3).should == nil
- end
+ruby_version_is ""..."1.9" do
+ describe "String#index with Fixnum" do
+ it "returns the index of the first occurrence of the given character" do
+ "hello".index(?e).should == 1
+ "hello".index(?l).should == 2
+ end
+
+ it "character values over 255 (256th ASCII character) always result in nil" do
+ # A naive implementation could try to use % 256
+ "hello".index(?e + 256 * 3).should == nil
+ end
- it "negative character values always result in nil" do
- # A naive implementation could try to use % 256
- "hello".index(-(256 - ?e)).should == nil
- end
-
- it "starts the search at the given offset" do
- "blablabla".index(?b, 0).should == 0
- "blablabla".index(?b, 1).should == 3
- "blablabla".index(?b, 2).should == 3
- "blablabla".index(?b, 3).should == 3
- "blablabla".index(?b, 4).should == 6
- "blablabla".index(?b, 5).should == 6
- "blablabla".index(?b, 6).should == 6
+ it "negative character values always result in nil" do
+ # A naive implementation could try to use % 256
+ "hello".index(-(256 - ?e)).should == nil
+ end
+
+ it "starts the search at the given offset" do
+ "blablabla".index(?b, 0).should == 0
+ "blablabla".index(?b, 1).should == 3
+ "blablabla".index(?b, 2).should == 3
+ "blablabla".index(?b, 3).should == 3
+ "blablabla".index(?b, 4).should == 6
+ "blablabla".index(?b, 5).should == 6
+ "blablabla".index(?b, 6).should == 6
- "blablabla".index(?a, 0).should == 2
- "blablabla".index(?a, 2).should == 2
- "blablabla".index(?a, 3).should == 5
- "blablabla".index(?a, 4).should == 5
- "blablabla".index(?a, 5).should == 5
- "blablabla".index(?a, 6).should == 8
- "blablabla".index(?a, 7).should == 8
- "blablabla".index(?a, 8).should == 8
- end
-
- it "starts the search at offset + self.length if offset is negative" do
- str = "blablabla"
+ "blablabla".index(?a, 0).should == 2
+ "blablabla".index(?a, 2).should == 2
+ "blablabla".index(?a, 3).should == 5
+ "blablabla".index(?a, 4).should == 5
+ "blablabla".index(?a, 5).should == 5
+ "blablabla".index(?a, 6).should == 8
+ "blablabla".index(?a, 7).should == 8
+ "blablabla".index(?a, 8).should == 8
+ end
- [?a, ?b].each do |needle|
- (-str.length .. -1).each do |offset|
- str.index(needle, offset).should ==
- str.index(needle, offset + str.length)
+ it "starts the search at offset + self.length if offset is negative" do
+ str = "blablabla"
+
+ [?a, ?b].each do |needle|
+ (-str.length .. -1).each do |offset|
+ str.index(needle, offset).should ==
+ str.index(needle, offset + str.length)
+ end
end
+
+ "blablabla".index(?b, -9).should == 0
end
-
- "blablabla".index(?b, -9).should == 0
- end
-
- it "returns nil if offset + self.length is < 0 for negative offsets" do
- "blablabla".index(?b, -10).should == nil
- "blablabla".index(?b, -20).should == nil
- end
-
- it "returns nil if the character isn't found" do
- "hello".index(0).should == nil
- "hello".index(?H).should == nil
- "hello".index(?z).should == nil
- "hello".index(?e, 2).should == nil
+ it "returns nil if offset + self.length is < 0 for negative offsets" do
+ "blablabla".index(?b, -10).should == nil
+ "blablabla".index(?b, -20).should == nil
+ end
+
+ it "returns nil if the character isn't found" do
+ "hello".index(0).should == nil
+
+ "hello".index(?H).should == nil
+ "hello".index(?z).should == nil
+ "hello".index(?e, 2).should == nil
- "blablabla".index(?b, 7).should == nil
- "blablabla".index(?b, 10).should == nil
+ "blablabla".index(?b, 7).should == nil
+ "blablabla".index(?b, 10).should == nil
- "blablabla".index(?a, 9).should == nil
- "blablabla".index(?a, 20).should == nil
+ "blablabla".index(?a, 9).should == nil
+ "blablabla".index(?a, 20).should == nil
+ end
+
+ it "converts start_offset to an integer via to_int" do
+ obj = mock('1')
+ obj.should_receive(:to_int).and_return(1)
+ "ROAR".index(?R, obj).should == 3
+ end
end
-
- it "converts start_offset to an integer via to_int" do
- obj = mock('1')
- obj.should_receive(:to_int).and_return(1)
- "ROAR".index(?R, obj).should == 3
- end
end
describe "String#index with String" do
Modified: MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/initialize_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -2,10 +2,18 @@
require File.dirname(__FILE__) + '/fixtures/classes.rb'
describe "String#initialize" do
- it "is a private method" do
- "".private_methods.should include("initialize")
+ ruby_version_is ""..."1.9" do
+ it "is a private method" do
+ "".private_methods.should include("initialize")
+ end
end
+ ruby_version_is "1.9" do
+ it "is a private method" do
+ "".private_methods.should include(:initialize)
+ end
+ end
+
it "replaces contents of self with the passed string" do
s = "some string"
id = s.object_id
@@ -55,10 +63,21 @@
lambda { String.new nil }.should raise_error(TypeError)
end
- it "raises a TypeError if self is frozen" do
- a = "hello".freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ a = "hello".freeze
- a.send :initialize, a
- lambda { a.send :initialize, "world" }.should raise_error(TypeError)
+ a.send :initialize, a
+ lambda { a.send :initialize, "world" }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ a = "hello".freeze
+
+ a.send :initialize, a
+ lambda { a.send :initialize, "world" }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/insert_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/insert_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/insert_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -55,9 +55,19 @@
lambda { "abcd".insert(-6, mock('x')) }.should raise_error(TypeError)
end
- it "raises a TypeError if self is frozen" do
- str = "abcd".freeze
- lambda { str.insert(4, '') }.should raise_error(TypeError)
- lambda { str.insert(4, 'X') }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ str = "abcd".freeze
+ lambda { str.insert(4, '') }.should raise_error(TypeError)
+ lambda { str.insert(4, 'X') }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ str = "abcd".freeze
+ lambda { str.insert(4, '') }.should raise_error(RuntimeError)
+ lambda { str.insert(4, 'X') }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/lstrip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/lstrip_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/lstrip_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -36,10 +36,23 @@
a.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- "hello".freeze.lstrip! # ok, nothing changed
- "".freeze.lstrip! # ok, nothing changed
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ "hello".freeze.lstrip! # ok, nothing changed
+ "".freeze.lstrip! # ok, nothing changed
- lambda { " hello ".freeze.lstrip! }.should raise_error(TypeError)
+ lambda { " hello ".freeze.lstrip! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ ruby_bug "#1550", "1.9.2" do
+ it "raises a RuntimeError if self is frozen" do
+ "hello".freeze.lstrip! # ok, nothing changed
+ "".freeze.lstrip! # ok, nothing changed
+
+ lambda { " hello ".freeze.lstrip! }.should raise_error(RuntimeError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/replace_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/replace_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/replace_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -27,11 +27,22 @@
lambda { "hello".replace(mock('x')) }.should raise_error(TypeError)
end
- it "raises a TypeError if self is frozen" do
- a = "hello".freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ a = "hello".freeze
- a.replace(a) # ok, no change
- lambda { a.replace("") }.should raise_error(TypeError)
- lambda { a.replace("world") }.should raise_error(TypeError)
+ a.replace(a) # ok, no change
+ lambda { a.replace("") }.should raise_error(TypeError)
+ lambda { a.replace("world") }.should raise_error(TypeError)
+ end
end
+ ruby_version_is ""..."1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ a = "hello".freeze
+
+ a.replace(a) # ok, no change
+ lambda { a.replace("") }.should raise_error(RuntimeError)
+ lambda { a.replace("world") }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/reverse_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/reverse_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/reverse_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -23,9 +23,19 @@
"".reverse!.should == ""
end
- it "raises a TypeError if self is frozen" do
- "".freeze.reverse! # ok, no change
- lambda { "anna".freeze.reverse! }.should raise_error(TypeError)
- lambda { "hello".freeze.reverse! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ "".freeze.reverse! # ok, no change
+ lambda { "anna".freeze.reverse! }.should raise_error(TypeError)
+ lambda { "hello".freeze.reverse! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ "".freeze.reverse! # ok, no change
+ lambda { "anna".freeze.reverse! }.should raise_error(RuntimeError)
+ lambda { "hello".freeze.reverse! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/rindex_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/rindex_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/rindex_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -27,84 +27,94 @@
end
end
-describe "String#rindex with Fixnum" do
- it "returns the index of the last occurrence of the given character" do
- "hello".rindex(?e).should == 1
- "hello".rindex(?l).should == 3
- end
-
- it "doesn't use fixnum % 256" do
- "hello".rindex(?e + 256 * 3).should == nil
- "hello".rindex(-(256 - ?e)).should == nil
- end
-
- it "starts the search at the given offset" do
- "blablabla".rindex(?b, 0).should == 0
- "blablabla".rindex(?b, 1).should == 0
- "blablabla".rindex(?b, 2).should == 0
- "blablabla".rindex(?b, 3).should == 3
- "blablabla".rindex(?b, 4).should == 3
- "blablabla".rindex(?b, 5).should == 3
- "blablabla".rindex(?b, 6).should == 6
- "blablabla".rindex(?b, 7).should == 6
- "blablabla".rindex(?b, 8).should == 6
- "blablabla".rindex(?b, 9).should == 6
- "blablabla".rindex(?b, 10).should == 6
+# Ruby 1.9 doesn't support the String#rindex(Fixnum) invocation. However,
+# confusingly, many of the tests in this block pass because it also changes
+# the semantics of ?l, where _l_ is a character, to return the character
+# corresponding to _l_; not the Fixnum. Regardless, it doesn't make sense to
+# have a describe block for "String#rindex with Fixnum" on 1.9 when 1.9
+# doesn't support that invocation. The other tests in this file exercise
+# String#rindex(?l) on 1.9 inadvertently because they test for
+# String#rindex(str).
+ruby_version_is ""..."1.9" do
+ describe "String#rindex with Fixnum" do
+ it "returns the index of the last occurrence of the given character" do
+ "hello".rindex(?e).should == 1
+ "hello".rindex(?l).should == 3
+ end
+
+ it "doesn't use fixnum % 256" do
+ "hello".rindex(?e + 256 * 3).should == nil
+ "hello".rindex(-(256 - ?e)).should == nil
+ end
+
+ it "starts the search at the given offset" do
+ "blablabla".rindex(?b, 0).should == 0
+ "blablabla".rindex(?b, 1).should == 0
+ "blablabla".rindex(?b, 2).should == 0
+ "blablabla".rindex(?b, 3).should == 3
+ "blablabla".rindex(?b, 4).should == 3
+ "blablabla".rindex(?b, 5).should == 3
+ "blablabla".rindex(?b, 6).should == 6
+ "blablabla".rindex(?b, 7).should == 6
+ "blablabla".rindex(?b, 8).should == 6
+ "blablabla".rindex(?b, 9).should == 6
+ "blablabla".rindex(?b, 10).should == 6
- "blablabla".rindex(?a, 2).should == 2
- "blablabla".rindex(?a, 3).should == 2
- "blablabla".rindex(?a, 4).should == 2
- "blablabla".rindex(?a, 5).should == 5
- "blablabla".rindex(?a, 6).should == 5
- "blablabla".rindex(?a, 7).should == 5
- "blablabla".rindex(?a, 8).should == 8
- "blablabla".rindex(?a, 9).should == 8
- "blablabla".rindex(?a, 10).should == 8
- end
-
- it "starts the search at offset + self.length if offset is negative" do
- str = "blablabla"
+ "blablabla".rindex(?a, 2).should == 2
+ "blablabla".rindex(?a, 3).should == 2
+ "blablabla".rindex(?a, 4).should == 2
+ "blablabla".rindex(?a, 5).should == 5
+ "blablabla".rindex(?a, 6).should == 5
+ "blablabla".rindex(?a, 7).should == 5
+ "blablabla".rindex(?a, 8).should == 8
+ "blablabla".rindex(?a, 9).should == 8
+ "blablabla".rindex(?a, 10).should == 8
+ end
- [?a, ?b].each do |needle|
- (-str.length .. -1).each do |offset|
- str.rindex(needle, offset).should ==
- str.rindex(needle, offset + str.length)
+ it "starts the search at offset + self.length if offset is negative" do
+ str = "blablabla"
+
+ [?a, ?b].each do |needle|
+ (-str.length .. -1).each do |offset|
+ str.rindex(needle, offset).should ==
+ str.rindex(needle, offset + str.length)
+ end
end
end
- end
-
- it "returns nil if the character isn't found" do
- "hello".rindex(0).should == nil
- "hello".rindex(?H).should == nil
- "hello".rindex(?z).should == nil
- "hello".rindex(?o, 2).should == nil
+ it "returns nil if the character isn't found" do
+ "hello".rindex(0).should == nil
+
+ "hello".rindex(?H).should == nil
+ "hello".rindex(?z).should == nil
+ "hello".rindex(?o, 2).should == nil
+
+ "blablabla".rindex(?a, 0).should == nil
+ "blablabla".rindex(?a, 1).should == nil
+
+ "blablabla".rindex(?a, -8).should == nil
+ "blablabla".rindex(?a, -9).should == nil
+
+ "blablabla".rindex(?b, -10).should == nil
+ "blablabla".rindex(?b, -20).should == nil
+ end
- "blablabla".rindex(?a, 0).should == nil
- "blablabla".rindex(?a, 1).should == nil
+ it "tries to convert start_offset to an integer via to_int" do
+ obj = mock('5')
+ def obj.to_int() 5 end
+ "str".rindex(?s, obj).should == 0
+
+ obj = mock('5')
+ def obj.respond_to?(arg) true end
+ def obj.method_missing(*args); 5; end
+ "str".rindex(?s, obj).should == 0
+ end
- "blablabla".rindex(?a, -8).should == nil
- "blablabla".rindex(?a, -9).should == nil
-
- "blablabla".rindex(?b, -10).should == nil
- "blablabla".rindex(?b, -20).should == nil
+ it "raises a TypeError when given offset is nil" do
+ lambda { "str".rindex(?s, nil) }.should raise_error(TypeError)
+ lambda { "str".rindex(?t, nil) }.should raise_error(TypeError)
+ end
end
-
- it "tries to convert start_offset to an integer via to_int" do
- obj = mock('5')
- def obj.to_int() 5 end
- "str".rindex(?s, obj).should == 0
-
- obj = mock('5')
- def obj.respond_to?(arg) true end
- def obj.method_missing(*args); 5; end
- "str".rindex(?s, obj).should == 0
- end
-
- it "raises a TypeError when given offset is nil" do
- lambda { "str".rindex(?s, nil) }.should raise_error(TypeError)
- lambda { "str".rindex(?t, nil) }.should raise_error(TypeError)
- end
end
describe "String#rindex with String" do
@@ -125,6 +135,28 @@
end
end
+ # On 1.9 ?chr, where _chr_ is a character returns the character as a string.
+ # The test below repeats the one above but uses the ?l notation for single
+ # characters instead.
+ ruby_version_is "1.9" do
+ it "behaves the same as String#rindex(?char) for one-character strings" do
+ ["blablabla", "hello cruel world...!"].each do |str|
+ str.split("").uniq.each do |str|
+ chr = str[0] =~ / / ? str[0] : eval("?#{str[0]}")
+ str.rindex(str).should == str.rindex(chr)
+
+ 0.upto(str.size + 1) do |start|
+ str.rindex(str, start).should == str.rindex(chr, start)
+ end
+
+ (-str.size - 1).upto(-1) do |start|
+ str.rindex(str, start).should == str.rindex(chr, start)
+ end
+ end
+ end
+ end
+ end
+
it "returns the index of the last occurrence of the given substring" do
"blablabla".rindex("").should == 9
"blablabla".rindex("a").should == 8
Modified: MacRuby/branches/experimental/spec/frozen/core/string/rstrip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/rstrip_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/rstrip_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -30,10 +30,21 @@
a.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- "hello".freeze.rstrip! # ok, nothing changed
- "".freeze.rstrip! # ok, nothing changed
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ "hello".freeze.rstrip! # ok, nothing changed
+ "".freeze.rstrip! # ok, nothing changed
- lambda { " hello ".freeze.rstrip! }.should raise_error(TypeError)
+ lambda { " hello ".freeze.rstrip! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ "hello".freeze.rstrip! # ok, nothing changed
+ "".freeze.rstrip! # ok, nothing changed
+
+ lambda { " hello ".freeze.rstrip! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/shared/concat.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/shared/concat.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/shared/concat.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -17,14 +17,25 @@
lambda { a = 'hello '.send(@method, mock('x')) }.should raise_error(TypeError)
end
- it "raises a TypeError when self is frozen" do
- a = "hello"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "hello"
+ a.freeze
- lambda { a.send(@method, "") }.should raise_error(TypeError)
- lambda { a.send(@method, "test") }.should raise_error(TypeError)
+ lambda { a.send(@method, "") }.should raise_error(TypeError)
+ lambda { a.send(@method, "test") }.should raise_error(TypeError)
+ end
end
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "hello"
+ a.freeze
+ lambda { a.send(@method, "") }.should raise_error(RuntimeError)
+ lambda { a.send(@method, "test") }.should raise_error(RuntimeError)
+ end
+ end
+
it "works when given a subclass instance" do
a = "hello"
a << StringSpecs::MyString.new(" world")
@@ -61,11 +72,23 @@
lambda { "".send(@method, x) }.should raise_error(TypeError)
end
- it "raises a TypeError when self is frozen" do
- a = "hello"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "hello"
+ a.freeze
- lambda { a.send(@method, 0) }.should raise_error(TypeError)
- lambda { a.send(@method, 33) }.should raise_error(TypeError)
+ lambda { a.send(@method, 0) }.should raise_error(TypeError)
+ lambda { a.send(@method, 33) }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "hello"
+ a.freeze
+
+ lambda { a.send(@method, 0) }.should raise_error(RuntimeError)
+ lambda { a.send(@method, 33) }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/shared/succ.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/shared/succ.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/shared/succ.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -79,8 +79,17 @@
end
end
- it "raises a TypeError if self is frozen" do
- lambda { "".freeze.send(@method) }.should raise_error(TypeError)
- lambda { "abcd".freeze.send(@method) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "".freeze.send(@method) }.should raise_error(TypeError)
+ lambda { "abcd".freeze.send(@method) }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "".freeze.send(@method) }.should raise_error(RuntimeError)
+ lambda { "abcd".freeze.send(@method) }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/slice_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/slice_spec_disabled.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/slice_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -43,15 +43,34 @@
a.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- lambda { "hello".freeze.slice!(1) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1) }.should raise_error(TypeError)
+ end
end
- it "doesn't raise a TypeError if self is frozen and idx is outside of self" do
- "hello".freeze.slice!(10).should be_nil
- "".freeze.slice!(0).should be_nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1) }.should raise_error(RuntimeError)
+ end
end
+ ruby_version_is ""..."1.9" do
+ it "doesn't raise a TypeError if self is frozen and idx is outside of self" do
+ "hello".freeze.slice!(10).should be_nil
+ "".freeze.slice!(0).should be_nil
+ end
+ end
+
+ ruby_version_is "1.9" do
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a RuntimeError if self is frozen and idx is outside of self" do
+ "hello".freeze.slice!(10).should be_nil
+ "".freeze.slice!(0).should be_nil
+ end
+ end
+ end
+
it "calls to_int on index" do
"hello".slice!(0.5).should == ?h
@@ -103,17 +122,38 @@
a.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- lambda { "hello".freeze.slice!(1, 2) }.should raise_error(TypeError)
- end
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1, 2) }.should raise_error(TypeError)
+ end
- it "doesn't raise a TypeError if self is frozen but the given position is out of self" do
- "hello".freeze.slice!(10, 3).should be_nil
- "hello".freeze.slice!(-10, 3).should be_nil
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a TypeError if self is frozen but the given position is out of self" do
+ "hello".freeze.slice!(10, 3).should be_nil
+ "hello".freeze.slice!(-10, 3).should be_nil
+ end
+
+ it "doesn't raise a TypeError if self is frozen but length is negative" do
+ "hello".freeze.slice!(4, -3).should be_nil
+ end
+ end
end
- it "doesn't raise a TypeError if self is frozen but length is negative" do
- "hello".freeze.slice!(4, -3).should be_nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1, 2) }.should raise_error(RuntimeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a RuntimeError if self is frozen but the given position is out of self" do
+ "hello".freeze.slice!(10, 3).should be_nil
+ "hello".freeze.slice!(-10, 3).should be_nil
+ end
+
+ it "doesn't raise a RuntimeError if self is frozen but length is negative" do
+ "hello".freeze.slice!(4, -3).should be_nil
+ end
+ end
end
it "calls to_int on idx and length" do
@@ -208,12 +248,28 @@
a.slice!(range_incl).should == "OO"
end
- it "raises a TypeError if self is frozen" do
- lambda { "hello".freeze.slice!(1..3) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1..3) }.should raise_error(TypeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a TypeError if self is frozen but the given range is out of self" do
+ "hello".freeze.slice!(10..20).should == nil
+ end
+ end
end
- it "doesn't raise a TypeError if self is frozen but the given range is out of self" do
- "hello".freeze.slice!(10..20).should == nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello".freeze.slice!(1..3) }.should raise_error(RuntimeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a RuntimeError if self is frozen but the given range is out of self" do
+ "hello".freeze.slice!(10..20).should == nil
+ end
+ end
end
end
@@ -272,12 +328,28 @@
$~.should == nil
end
- it "raises a TypeError if self is frozen" do
- lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(TypeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a TypeError if self is frozen but there is no match" do
+ "this is a string".freeze.slice!(/zzz/).should == nil
+ end
+ end
end
- it "doesn't raise a TypeError if self is frozen but there is no match" do
- "this is a string".freeze.slice!(/zzz/).should == nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a RuntimeError if self is frozen but there is no match" do
+ "this is a string".freeze.slice!(/zzz/).should == nil
+ end
+ end
end
end
@@ -354,16 +426,34 @@
$~.should == nil
end
- it "raises a TypeError if self is frozen" do
- lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(TypeError)
- end
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(TypeError)
+ end
- it "doesn't raise a TypeError if self is frozen but there is no match" do
- "this is a string".freeze.slice!(/zzz/, 0).should == nil
+ it "doesn't raise a TypeError if self is frozen but there is no match" do
+ "this is a string".freeze.slice!(/zzz/, 0).should == nil
+ end
+
+ it "doesn't raise a TypeError if self is frozen but there is no capture for idx" do
+ "this is a string".freeze.slice!(/(.)/, 2).should == nil
+ end
end
- it "doesn't raise a TypeError if self is frozen but there is no capture for idx" do
- "this is a string".freeze.slice!(/(.)/, 2).should == nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "this is a string".freeze.slice!(/s.*t/) }.should raise_error(RuntimeError)
+ end
+
+ ruby_bug "#1551", "1.9.2" do
+ it "doesn't raise a RuntimeError if self is frozen but there is no match" do
+ "this is a string".freeze.slice!(/zzz/, 0).should == nil
+ end
+
+ it "doesn't raise a RuntimeError if self is frozen but there is no capture for idx" do
+ "this is a string".freeze.slice!(/(.)/, 2).should == nil
+ end
+ end
end
end
@@ -416,11 +506,27 @@
r.class.should == StringSpecs::MyString
end
- it "raises a TypeError if self is frozen" do
- lambda { "hello hello".freeze.slice!('llo') }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ lambda { "hello hello".freeze.slice!('llo') }.should raise_error(TypeError)
+ end
+
+ ruby_bug "#1551", "1.9." do
+ it "doesn't raise a TypeError if self is frozen but self does not contain other" do
+ "this is a string".freeze.slice!('zzz').should == nil
+ end
+ end
end
- it "doesn't raise a TypeError if self is frozen but self does not contain other" do
- "this is a string".freeze.slice!('zzz').should == nil
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ lambda { "hello hello".freeze.slice!('llo') }.should raise_error(RuntimeError)
+ end
+
+ ruby_bug "#1551" do
+ it "doesn't raise a RuntimeError if self is frozen but self does not contain other" do
+ "this is a string".freeze.slice!('zzz').should == nil
+ end
+ end
end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/squeeze_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/squeeze_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/squeeze_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -90,11 +90,23 @@
a.should == "squeeze"
end
- it "raises a TypeError when self is frozen" do
- a = "yellow moon"
- a.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ a = "yellow moon"
+ a.freeze
- lambda { a.squeeze!("") }.should raise_error(TypeError)
- lambda { a.squeeze! }.should raise_error(TypeError)
+ lambda { a.squeeze!("") }.should raise_error(TypeError)
+ lambda { a.squeeze! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ a = "yellow moon"
+ a.freeze
+
+ lambda { a.squeeze!("") }.should raise_error(RuntimeError)
+ lambda { a.squeeze! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/strip_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/strip_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/strip_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -29,10 +29,23 @@
a.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- "hello".freeze.strip! # ok, nothing changed
- "".freeze.strip! # ok, nothing changed
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ "hello".freeze.strip! # ok, nothing changed
+ "".freeze.strip! # ok, nothing changed
- lambda { " hello ".freeze.strip! }.should raise_error(TypeError)
+ lambda { " hello ".freeze.strip! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ ruby_bug "#1552", "1.9.2" do
+ it "raises a RuntimeError if self is frozen" do
+ "hello".freeze.strip! # ok, nothing changed
+ "".freeze.strip! # ok, nothing changed
+
+ lambda { " hello ".freeze.strip! }.should raise_error(RuntimeError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/sub_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -324,14 +324,27 @@
a.should == "hello"
end
- it "raises a TypeError when self is frozen" do
- s = "hello"
- s.freeze
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ s = "hello"
+ s.freeze
- s.sub!(/ROAR/, "x") # ok
- lambda { s.sub!(/e/, "e") }.should raise_error(TypeError)
- lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(TypeError)
+ s.sub!(/ROAR/, "x") # ok
+ lambda { s.sub!(/e/, "e") }.should raise_error(TypeError)
+ lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ s = "hello"
+ s.freeze
+
+ s.sub!(/ROAR/, "x") # ok
+ lambda { s.sub!(/e/, "e") }.should raise_error(RuntimeError)
+ lambda { s.sub!(/[aeiou]/, '*') }.should raise_error(RuntimeError)
+ end
+ end
end
describe "String#sub! with pattern and block" do
Modified: MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec_disabled.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/swapcase_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -41,10 +41,21 @@
"".swapcase!.should == nil
end
- it "raises a TypeError when self is frozen" do
- ["", "hello"].each do |a|
- a.freeze
- lambda { a.swapcase! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ ["", "hello"].each do |a|
+ a.freeze
+ lambda { a.swapcase! }.should raise_error(TypeError)
+ end
end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ ["", "hello"].each do |a|
+ a.freeze
+ lambda { a.swapcase! }.should raise_error(RuntimeError)
+ end
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/to_a_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/to_a_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/to_a_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,6 +1,8 @@
require File.dirname(__FILE__) + '/../../spec_helper'
require File.dirname(__FILE__) + '/shared/to_a'
-describe "String#to_a" do
- it_behaves_like :string_to_a, :to_a
+ruby_version_is ""..."1.9" do
+ describe "String#to_a" do
+ it_behaves_like :string_to_a, :to_a
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/tr_s_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/tr_s_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/tr_s_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -82,10 +82,21 @@
s.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- s = "hello".freeze
- lambda { s.tr_s!("el", "ar") }.should raise_error(TypeError)
- lambda { s.tr_s!("l", "r") }.should raise_error(TypeError)
- lambda { s.tr_s!("", "") }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ s = "hello".freeze
+ lambda { s.tr_s!("el", "ar") }.should raise_error(TypeError)
+ lambda { s.tr_s!("l", "r") }.should raise_error(TypeError)
+ lambda { s.tr_s!("", "") }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ s = "hello".freeze
+ lambda { s.tr_s!("el", "ar") }.should raise_error(RuntimeError)
+ lambda { s.tr_s!("l", "r") }.should raise_error(RuntimeError)
+ lambda { s.tr_s!("", "") }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/tr_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/tr_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/tr_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -82,10 +82,21 @@
s.should == "hello"
end
- it "raises a TypeError if self is frozen" do
- s = "abcdefghijklmnopqR".freeze
- lambda { s.tr!("cdefg", "12") }.should raise_error(TypeError)
- lambda { s.tr!("R", "S") }.should raise_error(TypeError)
- lambda { s.tr!("", "") }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError if self is frozen" do
+ s = "abcdefghijklmnopqR".freeze
+ lambda { s.tr!("cdefg", "12") }.should raise_error(TypeError)
+ lambda { s.tr!("R", "S") }.should raise_error(TypeError)
+ lambda { s.tr!("", "") }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError if self is frozen" do
+ s = "abcdefghijklmnopqR".freeze
+ lambda { s.tr!("cdefg", "12") }.should raise_error(RuntimeError)
+ lambda { s.tr!("R", "S") }.should raise_error(RuntimeError)
+ lambda { s.tr!("", "") }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec_disabled.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/core/string/upcase_spec_disabled.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -44,8 +44,17 @@
a.should == "HELLO"
end
- it "raises a TypeError when self is frozen" do
- lambda { "HeLlo".freeze.upcase! }.should raise_error(TypeError)
- lambda { "HELLO".freeze.upcase! }.should raise_error(TypeError)
+ ruby_version_is ""..."1.9" do
+ it "raises a TypeError when self is frozen" do
+ lambda { "HeLlo".freeze.upcase! }.should raise_error(TypeError)
+ lambda { "HELLO".freeze.upcase! }.should raise_error(TypeError)
+ end
end
+
+ ruby_version_is "1.9" do
+ it "raises a RuntimeError when self is frozen" do
+ lambda { "HeLlo".freeze.upcase! }.should raise_error(RuntimeError)
+ lambda { "HELLO".freeze.upcase! }.should raise_error(RuntimeError)
+ end
+ end
end
Modified: MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/library/stringio/readpartial_spec.rb 2009-06-01 20:50:49 UTC (rev 1687)
@@ -31,18 +31,22 @@
@string.readpartial(3).should == ", l"
end
- # it "reads after ungetc without data in the buffer" do
- # @string = StringIO.new
- # @string.write("f")
- # c = @string.getc
- # @string.ungetc(c)
- # @string.readpartial(2).should == "f"
- #
- # # now, also check that the ungot char is cleared and
- # # not returned again
- # @string.write("b")
- # @string.readpartial(2).should == "b"
- # end
+ it "reads after ungetc without data in the buffer" do
+ @string = StringIO.new
+ @string.write("f").should == 1
+ @string.rewind
+ c = @string.getc
+ c.should == 'f'
+ @string.ungetc(c).should == nil
+
+ @string.readpartial(2).should == "f"
+ @string.rewind
+ # now, also check that the ungot char is cleared and
+ # not returned again
+ @string.write("b").should == 1
+ @string.rewind
+ @string.readpartial(2).should == "b"
+ end
it "discards the existing buffer content upon successful read" do
buffer = "existing"
Added: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/combination_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/combination_tags.txt (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/combination_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1 @@
+fails:Array#combination returns an enumerator when no block is provided
\ No newline at end of file
Added: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/cycle_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/cycle_tags.txt (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/array/cycle_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -0,0 +1 @@
+critical:Enumerable#cycle cycle as many times as requested
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/chomp_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/chomp_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/chomp_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -4,4 +4,4 @@
fails:String#chomp with separator raises a TypeError if separator can't be converted to a string
fails:String#chomp with separator returns subclass instances when called on a subclass
fails:String#chomp! with separator modifies self in place and returns self
-fails:String#chomp! with separator raises a TypeError when self is frozen
+fails:String#chomp! with separator raises a RuntimeError when self is frozen
\ No newline at end of file
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/lstrip_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/lstrip_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/lstrip_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,2 +1,2 @@
fails:String#lstrip! modifies self in place and returns self
-fails:String#lstrip! raises a TypeError if self is frozen
+fails:String#lstrip! raises a RuntimeError if self is frozen
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/reverse_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/reverse_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/reverse_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1 +1 @@
-fails:String#reverse! raises a TypeError if self is frozen
+fails:String#reverse! raises a RuntimeError if self is frozen
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rindex_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rindex_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rindex_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -11,3 +11,4 @@
fails:String#rindex with String tries to convert start_offset to an integer via to_int
fails:String#rindex with Regexp behaves the same as String#rindex(string) for escaped string regexps
fails:String#rindex with Regexp tries to convert start_offset to an integer via to_int
+fails:String#rindex with String behaves the same as String#rindex(?char) for one-character strings
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rstrip_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rstrip_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/rstrip_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,2 +1,2 @@
fails:String#rstrip returns a copy of self with trailing whitespace removed
-fails:String#rstrip! raises a TypeError if self is frozen
+fails:String#rstrip! raises a RuntimeError if self is frozen
Modified: MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/strip_tags.txt
===================================================================
--- MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/strip_tags.txt 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/tags/macruby/core/string/strip_tags.txt 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1,2 +1,2 @@
fails:String#strip returns a new string with leading and trailing whitespace removed
-fails:String#strip! raises a TypeError if self is frozen
+fails:String#strip! raises a RuntimeError if self is frozen
Modified: MacRuby/branches/experimental/spec/frozen/upstream
===================================================================
--- MacRuby/branches/experimental/spec/frozen/upstream 2009-06-01 03:26:13 UTC (rev 1686)
+++ MacRuby/branches/experimental/spec/frozen/upstream 2009-06-01 20:50:49 UTC (rev 1687)
@@ -1 +1 @@
-ba2b6ee4825a4950f50c43e9da424431ceb7db54
\ No newline at end of file
+5d6614b032b1ca4c1e27c9176219628723f3485a
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090601/67cfbbc2/attachment-0001.html>
More information about the macruby-changes
mailing list