Created
March 13, 2011 22:40
-
-
Save dwaite/868512 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/spec/ruby/language/regexp/back-references_spec.rb b/spec/ruby/langu | |
index c09a165..fe0d9e0 100644 | |
--- a/spec/ruby/language/regexp/back-references_spec.rb | |
+++ b/spec/ruby/language/regexp/back-references_spec.rb | |
@@ -7,6 +7,13 @@ describe "Regexps with back-references" do | |
$~.to_a.should == ["ll"] | |
end | |
+ it 'allows the $~ pseudo-global varable to be assigned' do | |
+ "hello" =~ /l+/ | |
+ $~ = nil | |
+ $~.should be_nil | |
+ Regexp.last_match.should be_nil | |
+ end | |
+ | |
it 'saves captures in numbered $[1-9] variables' do | |
"1234567890" =~ /(1)(2)(3)(4)(5)(6)(7)(8)(9)(0)/ | |
$~.to_a.should == ["1234567890", "1", "2", "3", "4", "5", "6", "7", "8", "9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment