File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
ruby/core/enumerator/lazy
tags/core/enumerator/lazy Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 33
33
Enumerator ::Lazy . new ( Object . new , 100 ) { } . grep ( Object ) . size . should == nil
34
34
end
35
35
36
+ it "sets $~ in the block" do
37
+ "z" =~ /z/ # Reset $~
38
+ [ "abc" , "def" ] . lazy . grep ( /b/ ) { |e |
39
+ e . should == "abc"
40
+ $&. should == "b"
41
+ } . force
42
+
43
+ # Set by the failed match of "def"
44
+ $~. should == nil
45
+ end
46
+
47
+ it "sets $~ in the next block with each" do
48
+ "z" =~ /z/ # Reset $~
49
+ [ "abc" , "def" ] . lazy . grep ( /b/ ) . each { |e |
50
+ e . should == "abc"
51
+ $&. should == "b"
52
+ }
53
+
54
+ # Set by the failed match of "def"
55
+ $~. should == nil
56
+ end
57
+
58
+ it "sets $~ in the next block with map" do
59
+ "z" =~ /z/ # Reset $~
60
+ [ "abc" , "def" ] . lazy . grep ( /b/ ) . map { |e |
61
+ e . should == "abc"
62
+ $&. should == "b"
63
+ } . force
64
+
65
+ # Set by the failed match of "def"
66
+ $~. should == nil
67
+ end
68
+
36
69
describe "when the returned lazy enumerator is evaluated by Enumerable#first" do
37
70
it "stops after specified times when not given a block" do
38
71
( 0 ..Float ::INFINITY ) . lazy . grep ( Integer ) . first ( 3 ) . should == [ 0 , 1 , 2 ]
Original file line number Diff line number Diff line change
1
+ fails:Enumerator::Lazy#grep sets $~ in the next block with each
2
+ fails:Enumerator::Lazy#grep sets $~ in the next block with map
3
+ fails:Enumerator::Lazy#grep sets $~ in the block
You can’t perform that action at this time.
0 commit comments