Sha256: 6b8601477b6f950f6014e96b24b9913fd48c83fe2fa798b5c37548ec9fa97dce

Contents?: true

Size: 1.37 KB

Versions: 83

Compression:

Stored size: 1.37 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'

describe "String#reverse" do
  it "returns a new string with the characters of self in reverse order" do
    "stressed".reverse.should == "desserts"
    "m".reverse.should == "m"
    "".reverse.should == ""
  end

  it "taints the result if self is tainted" do
    "".taint.reverse.tainted?.should == true
    "m".taint.reverse.tainted?.should == true
  end
end

describe "String#reverse!" do
  it "reverses self in place and always returns self" do
    a = "stressed"
    a.reverse!.should equal(a)
    a.should == "desserts"

    "".reverse!.should == ""
  end

  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
    ruby_bug "[ruby-core:23666]", "1.9.2" do
      it "raises a RuntimeError if self is frozen" do
        lambda { "".freeze.reverse!      }.should raise_error(RuntimeError)
        lambda { "anna".freeze.reverse!  }.should raise_error(RuntimeError)
        lambda { "hello".freeze.reverse! }.should raise_error(RuntimeError)
      end
    end
  end  
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/string/reverse_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/string/reverse_spec.rb