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