Skip to content

Instantly share code, notes, and snippets.

@dwaite
Created March 13, 2011 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwaite/868512 to your computer and use it in GitHub Desktop.
Save dwaite/868512 to your computer and use it in GitHub Desktop.
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