Sha256: 24640a62f635e96da81ff1c19ef7e4b7c387849f775c2687dc37f823a292741d

Contents?: true

Size: 1.75 KB

Versions: 83

Compression:

Stored size: 1.75 KB

Contents

# -*- encoding: utf-8 -*-
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes.rb'

describe "String#downcase" do
  it "returns a copy of self with all uppercase letters downcased" do
    "hELLO".downcase.should == "hello"
    "hello".downcase.should == "hello"
  end

  it "is locale insensitive (only replaces A-Z)" do
    "ÄÖÜ".downcase.should == "ÄÖÜ"

    str = Array.new(256) { |c| c.chr }.join
    expected = Array.new(256) do |i|
      c = i.chr
      c.between?("A", "Z") ? c.downcase : c
    end.join

    str.downcase.should == expected
  end

  it "taints result when self is tainted" do
    "".taint.downcase.tainted?.should == true
    "x".taint.downcase.tainted?.should == true
    "X".taint.downcase.tainted?.should == true
  end

  it "returns a subclass instance for subclasses" do
    StringSpecs::MyString.new("FOObar").downcase.class.should == StringSpecs::MyString
  end
end

describe "String#downcase!" do
  it "modifies self in place" do
    a = "HeLlO"
    a.downcase!.should equal(a)
    a.should == "hello"
  end

  it "returns nil if no modifications were made" do
    a = "hello"
    a.downcase!.should == nil
    a.should == "hello"
  end

  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

Version data entries

83 entries across 83 versions & 1 rubygems

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