Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (89 sloc) 3.04 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
5b7f1a91 »
2009-05-19 [t/spec] grep with non-Code matcher
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
3e50cafb »
2009-01-29 [t] added named arg test for grep
26 #?rakudo skip 'named args'
27 {
28 my @result = grep({ ($_ % 2) }, :values(@list));
29 is(+@result, 5, 'we got a list back');
30 is(@result[0], 1, 'got the value we expected');
31 is(@result[1], 3, 'got the value we expected');
32 is(@result[2], 5, 'got the value we expected');
33 is(@result[3], 7, 'got the value we expected');
34 is(@result[4], 9, 'got the value we expected');
35 }
36
0960758f »
2008-07-02 Some updates to S29-list.
37 #?rakudo skip "adverbial block"
53330f86 »
2008-01-21 Test suite refactoring.
38 {
39 my @result = @list.grep():{ ($_ % 2) };
40 is(+@result, 5, 'we got a list back');
41 is(@result[0], 1, 'got the value we expected');
42 is(@result[1], 3, 'got the value we expected');
43 is(@result[2], 5, 'got the value we expected');
44 is(@result[3], 7, 'got the value we expected');
45 is(@result[4], 9, 'got the value we expected');
46 }
47
0960758f »
2008-07-02 Some updates to S29-list.
48 #?rakudo skip "adverbial block"
53330f86 »
2008-01-21 Test suite refactoring.
49 {
345293a2 »
2008-07-01 [spec] S29-list/grep.t fixed adverbial closure test
50 my @result = @list.grep :{ ($_ % 2) };
53330f86 »
2008-01-21 Test suite refactoring.
51 is(+@result, 5, 'we got a list back');
52 is(@result[0], 1, 'got the value we expected');
53 is(@result[1], 3, 'got the value we expected');
54 is(@result[2], 5, 'got the value we expected');
55 is(@result[3], 7, 'got the value we expected');
56 is(@result[4], 9, 'got the value we expected');
57 }
58
0960758f »
2008-07-02 Some updates to S29-list.
59 #?rakudo skip "closure as non-final argument"
53330f86 »
2008-01-21 Test suite refactoring.
60 {
61 my @result = grep { ($_ % 2) }: @list;
0960758f »
2008-07-02 Some updates to S29-list.
62 is(+@result, 5, 'we got a list back');
63 is(@result[0], 1, 'got the value we expected');
64 is(@result[1], 3, 'got the value we expected');
65 is(@result[2], 5, 'got the value we expected');
66 is(@result[3], 7, 'got the value we expected');
67 is(@result[4], 9, 'got the value we expected');
53330f86 »
2008-01-21 Test suite refactoring.
68 }
69
70 {
a20c69c2 »
2008-02-10 [t/spec/*.t] :todo whackage
71 #?pugs 2 todo 'bug'
5caad32c »
2008-12-24 [t/spec]: Update map/grep/reduce/kv tests to work with scalar invocants.
72 is(42.grep({ 1 }), "42", "method form of grep works on numbers");
73 is('str'.grep({ 1 }), 'str', "method form of grep works on strings");
53330f86 »
2008-01-21 Test suite refactoring.
74 }
75
76 #
77 # Grep with mutating block
78 #
94ca56cd »
2008-06-08 [spec] removed "unspecced" marking of grep tests that mutate $_
79 # L<S02/Names/"$_, $!, and $/ are context<rw> by default">
53330f86 »
2008-01-21 Test suite refactoring.
80
81 {
82 my @array = <a b c d>;
b9269407 »
2008-05-07 [t/spec] more disambiguation whitespaces for S29-list/
83 is ~(try { @array.grep: { $_ ~= "c"; 1 } }), "ac bc cc dc",
53330f86 »
2008-01-21 Test suite refactoring.
84 'mutating $_ in grep works (1)';
85 is ~@array, "ac bc cc dc",
86 'mutating $_ in grep works (2)';
87 }
88
5d12fd9a »
2009-03-08 [t/spec] tests for last and next in grep
89 # grep with last, next etc.
90
91 {
92 is (1..16).grep({last if $_ % 5 == 0; $_ % 2 == 0}).join('|'),
93 '2|4', 'last works in grep';
94 is (1..12).grep({next if $_ % 5 == 0; $_ % 2 == 0}).join('|'),
95 '2|4|6|8|12', 'next works in grep';
96 }
97
5b7f1a91 »
2009-05-19 [t/spec] grep with non-Code matcher
98 # since the test argument to .grep is a Matcher, we can also
99 # check type constraints:
100
101 {
102 is (2, [], 4, [], 5).grep(Int).join(','),
103 '2,4,5', ".grep with non-Code matcher";
104
105 is grep(Int, 2, [], 4, [], 5).join(','),
106 '2,4,5', "grep() with non-Code matcher";
107 }
108
109 # vim: ft=perl6
Something went wrong with that request. Please try again.