Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 144 lines (119 sloc) 4.158 kb
d198f6b2 »
2008-04-16 [t/spec] s/use v6-alpha;/use v6;/
1 use v6;
53330f86 »
2008-01-21 Test suite refactoring.
2 use Test;
3
ccace729 »
2009-04-26 [t/spec] fix smartlinks in S32-list
4 # L<S32::Containers/"List"/"=item grep">
53330f86 »
2008-01-21 Test suite refactoring.
5
8313f3f6 »
2008-01-28 [t/spec] Converted pod markers to pod6
6 =begin pod
53330f86 »
2008-01-21 Test suite refactoring.
7
8 built-in grep tests
9
8313f3f6 »
2008-01-28 [t/spec] Converted pod markers to pod6
10 =end pod
53330f86 »
2008-01-21 Test suite refactoring.
11
c5fa27b8 »
2011-05-23 [S32] remove more tests for now-gone calling-positionals-by-named tests
12 plan 38;
53330f86 »
2008-01-21 Test suite refactoring.
13
14 my @list = (1 .. 10);
15
16 {
17 my @result = grep { ($_ % 2) }, @list;
18 is(+@result, 5, 'we got a list back');
19 is(@result[0], 1, 'got the value we expected');
20 is(@result[1], 3, 'got the value we expected');
21 is(@result[2], 5, 'got the value we expected');
22 is(@result[3], 7, 'got the value we expected');
23 is(@result[4], 9, 'got the value we expected');
24 }
25
0960758f »
2008-07-02 Some updates to S29-list.
26 #?rakudo skip "adverbial block"
03b1456a »
2011-12-24 Fudge for niecza.
27 #?niecza skip 'No value for parameter Mu $sm in Any.grep'
53330f86 »
2008-01-21 Test suite refactoring.
28 {
29 my @result = @list.grep():{ ($_ % 2) };
30 is(+@result, 5, 'we got a list back');
31 is(@result[0], 1, 'got the value we expected');
32 is(@result[1], 3, 'got the value we expected');
33 is(@result[2], 5, 'got the value we expected');
34 is(@result[3], 7, 'got the value we expected');
35 is(@result[4], 9, 'got the value we expected');
36 }
37
0960758f »
2008-07-02 Some updates to S29-list.
38 #?rakudo skip "adverbial block"
9dac81d1 »
2012-03-02 pugs fudge
39 #?pugs skip "adverbial block"
03b1456a »
2011-12-24 Fudge for niecza.
40 #?niecza skip 'No value for parameter Mu $sm in Any.grep'
53330f86 »
2008-01-21 Test suite refactoring.
41 {
345293a2 »
2008-07-01 [spec] S29-list/grep.t fixed adverbial closure test
42 my @result = @list.grep :{ ($_ % 2) };
53330f86 »
2008-01-21 Test suite refactoring.
43 is(+@result, 5, 'we got a list back');
44 is(@result[0], 1, 'got the value we expected');
45 is(@result[1], 3, 'got the value we expected');
46 is(@result[2], 5, 'got the value we expected');
47 is(@result[3], 7, 'got the value we expected');
48 is(@result[4], 9, 'got the value we expected');
49 }
50
0960758f »
2008-07-02 Some updates to S29-list.
51 #?rakudo skip "closure as non-final argument"
03b1456a »
2011-12-24 Fudge for niecza.
52 #?niecza skip 'Invocant handling is NYI'
53330f86 »
2008-01-21 Test suite refactoring.
53 {
54 my @result = grep { ($_ % 2) }: @list;
0960758f »
2008-07-02 Some updates to S29-list.
55 is(+@result, 5, 'we got a list back');
56 is(@result[0], 1, 'got the value we expected');
57 is(@result[1], 3, 'got the value we expected');
58 is(@result[2], 5, 'got the value we expected');
59 is(@result[3], 7, 'got the value we expected');
60 is(@result[4], 9, 'got the value we expected');
53330f86 »
2008-01-21 Test suite refactoring.
61 }
62
63 {
5caad32c »
2008-12-24 [t/spec]: Update map/grep/reduce/kv tests to work with scalar invocants.
64 is(42.grep({ 1 }), "42", "method form of grep works on numbers");
65 is('str'.grep({ 1 }), 'str', "method form of grep works on strings");
53330f86 »
2008-01-21 Test suite refactoring.
66 }
67
68 #
69 # Grep with mutating block
70 #
94ca56cd »
2008-06-08 [spec] removed "unspecced" marking of grep tests that mutate $_
71 # L<S02/Names/"$_, $!, and $/ are context<rw> by default">
9dac81d1 »
2012-03-02 pugs fudge
72 #?pugs skip "Can't modify constant item: VStr 'a'"
53330f86 »
2008-01-21 Test suite refactoring.
73 {
74 my @array = <a b c d>;
dae7348f »
2009-07-28 [t/spec]: Refudge test in S32-list/grep.t .
75 #?rakudo 2 skip 'test error -- is $_ rw here?'
76 is ~(@array.grep({ $_ ~= "c"; 1 })), "ac bc cc dc",
53330f86 »
2008-01-21 Test suite refactoring.
77 'mutating $_ in grep works (1)';
78 is ~@array, "ac bc cc dc",
79 'mutating $_ in grep works (2)';
80 }
81
5d12fd9a »
2009-03-08 [t/spec] tests for last and next in grep
82 # grep with last, next etc.
9dac81d1 »
2012-03-02 pugs fudge
83 #?pugs skip "last/next in grep"
5d12fd9a »
2009-03-08 [t/spec] tests for last and next in grep
84 {
85 is (1..16).grep({last if $_ % 5 == 0; $_ % 2 == 0}).join('|'),
86 '2|4', 'last works in grep';
87 is (1..12).grep({next if $_ % 5 == 0; $_ % 2 == 0}).join('|'),
88 '2|4|6|8|12', 'next works in grep';
89 }
90
5b7f1a91 »
2009-05-19 [t/spec] grep with non-Code matcher
91 # since the test argument to .grep is a Matcher, we can also
92 # check type constraints:
9dac81d1 »
2012-03-02 pugs fudge
93 #?pugs skip "Int"
5b7f1a91 »
2009-05-19 [t/spec] grep with non-Code matcher
94 {
95 is (2, [], 4, [], 5).grep(Int).join(','),
96 '2,4,5', ".grep with non-Code matcher";
97
98 is grep(Int, 2, [], 4, [], 5).join(','),
99 '2,4,5', "grep() with non-Code matcher";
100 }
101
2f8a8f9b »
2010-01-11 [t/spec] Test for RT 71754: grep arity sensitivity different from map
102 # RT 71544
03b1456a »
2011-12-24 Fudge for niecza.
103 #?niecza skip 'No value for parameter $b in ANON'
2f8a8f9b »
2010-01-11 [t/spec] Test for RT 71754: grep arity sensitivity different from map
104 {
105 my @in = ( 1, 1, 2, 3, 4, 4 );
106
107 # This test passes, but it's disabled because it doesn't belong here.
108 # It just kind of clarifies the test that follows.
109 # is (map { $^a == $^b }, @in), (?1, ?0, ?1), 'map takes two at a time';
110
3ba1e506 »
2010-01-11 [t/spec] fix mislabeled fudge
111 #?rakudo skip 'RT 71544: grep arity sensitivity different from map'
9dac81d1 »
2012-03-02 pugs fudge
112 #?pugs todo
2f8a8f9b »
2010-01-11 [t/spec] Test for RT 71754: grep arity sensitivity different from map
113 is (grep { $^a == $^b }, @in), (1, 1, 4, 4), 'grep takes two at a time';
114 }
115
9dac81d1 »
2012-03-02 pugs fudge
116 #?pugs skip 'Cannot cast from VList to VCode'
6939ae53 »
2010-04-05 [t/spec] test Junction matchers with .grep
117 {
118 my @a = <a b c>;
119 my @b = <b c d>;
120 is @a.grep(any(@b)).join('|'), 'b|c', 'Junction matcher';
121
122 }
123
9dac81d1 »
2012-03-02 pugs fudge
124 # sensible boolification
861910ad »
2010-04-05 [t/spec] test that the return value from .grep Boolifies sensibly (RT…
125 # RT #74056
126 # since rakudo returns an iterator (and not a list) and some internals leaked,
127 # a zero item list/iterator would return True, which is obviously wrong
9dac81d1 »
2012-03-02 pugs fudge
128 #?pugs skip 'Cannot cast from VList to VCode'
861910ad »
2010-04-05 [t/spec] test that the return value from .grep Boolifies sensibly (RT…
129 {
130 ok <0 1 2>.grep(1), 'Non-empty return value from grep is true (1)';
131 ok <0 1 2>.grep(0), 'Non-empty return value from grep is true (2)';
132 nok <0 1 2>.grep(3), 'Empty return value from grep is false';
133 }
134
09e8944c »
2010-07-21 [t/spec] Add some tests for doubled gathers.
135 # chained greps
9dac81d1 »
2012-03-02 pugs fudge
136 #?pugs skip "..."
09e8944c »
2010-07-21 [t/spec] Add some tests for doubled gathers.
137 {
c3f4ab28 »
2010-09-11 fix another series misuse
138 is ~(1...100).grep(* %% 2).grep(* %% 3), ~(6, 12 ... 96), "chained greps work";
09e8944c »
2010-07-21 [t/spec] Add some tests for doubled gathers.
139 }
140
e76dd4c7 »
2010-12-31 s/done_testing/done/ as per recent S24 changes
141 done;
2f8a8f9b »
2010-01-11 [t/spec] Test for RT 71754: grep arity sensitivity different from map
142
5b7f1a91 »
2009-05-19 [t/spec] grep with non-Code matcher
143 # vim: ft=perl6
Something went wrong with that request. Please try again.