Sha256: 2fbc0cbc173331bcd6167afacc16b67214b09a0b46d93ecb934478d37d709e75

Contents?: true

Size: 576 Bytes

Versions: 23

Compression:

Stored size: 576 Bytes

Contents

describe "String#=~" do
  it "sets $~ to MatchData when there is a match and nil then there's none" do
    'hello' =~ /./
    $~[0].should == 'h'

    'hello' =~ /not/
    $~.should == nil
  end
end

describe "String#match" do
  it "matches the pattern against self" do
    'hello'.match(/(.)\1/)[0].should == "ll"
  end

  it "returns nil if there's no match" do
    'hello'.match('xx').should == nil
  end

  it "sets $~ to MatchData of match or nil when there is none" do
    'hello'.match(/./)
    $~[0].should == 'h'

    'hello'.match(/X/)
    $~.should == nil
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
opal-0.3.43 spec/rubyspec/core/string/match_spec.rb
opal-0.3.42 spec/core/string/match_spec.rb
opal-0.3.41 spec/core/string/match_spec.rb
opal-0.3.40 spec/core/string/match_spec.rb
opal-0.3.39 spec/core/string/match_spec.rb
opal-0.3.38 spec/core/string/match_spec.rb
opal-0.3.37 spec/core/string/match_spec.rb
opal-0.3.36 spec/core/string/match_spec.rb
opal-0.3.35 spec/core/string/match_spec.rb
opal-0.3.34 spec/core/string/match_spec.rb
opal-0.3.33 spec/core/string/match_spec.rb
opal-0.3.32 spec/core/string/match_spec.rb
opal-0.3.31 spec/core/string/match_spec.rb
opal-0.3.30 spec/core/string/match_spec.rb
opal-0.3.29 spec/core/string/match_spec.rb
opal-0.3.28 spec/core/string/match_spec.rb
opal-0.3.27 spec/core/string/match_spec.rb
opal-0.3.26 spec/core/string/match_spec.rb
opal-0.3.25 spec/core/string/match_spec.rb
opal-0.3.22 spec/core/string/match_spec.rb