Skip to content
This repository
Browse code

add some $1 in different scopes tests

  • Loading branch information...
commit ef670945e3d754b8e53b71cc32ac2044f9486c79 1 parent fc0f589
Roger Pack authored June 27, 2012

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  language/predefined_spec.rb
20  language/predefined_spec.rb
@@ -142,6 +142,26 @@ def test(arg)
142 142
     end
143 143
     test("-").should == nil
144 144
   end
  145
+  
  146
+  describe "in different scopes" do
  147
+    def test2
  148
+      $1.should == nil
  149
+      'b' =~ /(c)/
  150
+    end
  151
+    it "only retains match groups for the current scope" do
  152
+      'a' =~ /(b)/ # clear it
  153
+      $1.should == nil
  154
+      'a' =~ /(a)/
  155
+      $1.should == 'a'
  156
+      test2
  157
+    end
  158
+    it "should retain a local match group even if a non match occurs in a different scope" do
  159
+      'a' =~ /(a)/
  160
+      $1.should == 'a'
  161
+      test2
  162
+      $1.should == 'a'
  163
+    end
  164
+  end
145 165
 end
146 166
 
147 167
 describe "Predefined global $stdout" do

0 notes on commit ef67094

Please sign in to comment.
Something went wrong with that request. Please try again.