Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 109 lines (91 sloc) 4.964 kb
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
1 use v6;
2
3 use Test;
4
83aa430 @lizmat Some more :exists tests
lizmat authored
5 plan 52;
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
6
7 # L<S02/Names and Variables/:exists>
e739aea @lizmat Merge @a:exists tests into a single file
lizmat authored
8 # L<S32::Containers/"Array"/=item exists>
9
83aa430 @lizmat Some more :exists tests
lizmat authored
10 #?niecza skip "no adverbials"
11 {
12 my @array = <a b c d>;
13 ok @array[0]:exists, "exists(positive index) on arrays (1)";
14 ok @array[1]:exists, "exists(positive index) on arrays (2)";
15 ok @array[2]:exists, "exists(positive index) on arrays (3)";
16 ok @array[3]:exists, "exists(positive index) on arrays (4)";
17 ok @array[4]:!exists, "exists(positive index) on arrays (5)";
18 nok @array[42]:exists, "exists(positive index) on arrays (6)";
19 }
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
20
21 #-------------------------------------------------------------------------------
22 # initialisations
23
24 my $default = Any;
25 my $dont = False;
26 sub gen_array { (1..10).list }
27
28 #-------------------------------------------------------------------------------
29 # Array
30
31 {
32 my @a = gen_array;
33 is @a.elems, 10, "basic sanity";
34
35 #?niecza 4 skip "no adverbials"
bb0a8fa @lizmat Use isa-ok instead of isa_ok
lizmat authored
36 isa-ok @a[ 3]:exists, Bool, "Bool test for exists single element";
37 isa-ok @a[ 3]:!exists, Bool, "!Bool test for exists single element";
38 isa-ok @a[10]:exists, Bool, "Bool test for non-exists single element";
39 isa-ok @a[10]:!exists, Bool, "!Bool test for non-exists single element";
83aa430 @lizmat Some more :exists tests
lizmat authored
40 ok @a[ 3]:exists, "Test for exists single element";
41 ok !(@a[10]:exists), "Test for non-exists single element";
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
42
43 #?niecza 10 skip "no adverbials"
44 ok !(@a[ 9]:!exists), "Test non-exists with ! single elem 9";
45 ok @a[10]:!exists, "Test non-exists with ! single elem 10";
46 ok !(@a[ 9]:exists(0)), "Test non-exists with (0) single elem 9";
47 ok @a[10]:exists(0), "Test non-exists with (0) single elem 10";
48 ok !(@a[ 9]:exists(False)), "Test non-exists with (False) single elem 9";
49 ok @a[10]:exists(False), "Test non-exists with (False) single elem 10";
50 ok !(@a[ 9]:exists($dont)), "Test non-exists with (\$dont) single elem 9";
51 ok @a[10]:exists($dont), "Test non-exists with (\$dont) single elem 10";
52 ok @a[ 9]:exists(1), "Test exists with (1) single elem 9";
53 ok !(@a[10]:exists(1)), "Test exists with (1) single elem 10";
54
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
55 is-deeply @a[1,2, 4]:exists, (True, True, True), "Test exists TTT";
56 is-deeply @a[1,2,10]:exists, (True, True, False), "Test exists TTF";
57 is-deeply (@a[]:exists), True xx 10, "Test non-exists T[]";
58 is-deeply (@a[*]:exists), True xx 10, "Test non-exists T[*]";
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
59 #?niezca 3 todo "adverbial pairs only used as True"
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
60 is-deeply @a[1,2, 4]:!exists, (False,False,False), "Test non-exists FFF";
61 is-deeply @a[1,2,10]:!exists, (False,False,True), "Test non-exists FFT";
62 is-deeply (@a[]:!exists), False xx 10, "Test non-exists F[]";
63 is-deeply (@a[*]:!exists), False xx 10, "Test non-exists F[*]";
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
64
65 #?niezca 6 todo "no combined adverbial pairs"
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
66 is-deeply @a[1,2, 4]:exists:kv,
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
67 (1,True,2,True,4,True), "Test exists:kv TTT";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
68 is-deeply @a[1,2,10]:exists:kv,
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
69 (1,True,2,True), "Test exists:kv TT.";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
70 is-deeply @a[1,2,10]:exists:!kv,
83aa430 @lizmat Some more :exists tests
lizmat authored
71 (1,True,2,True,10,False), "Test exists:!kv TTF";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
72 is-deeply @a[1,2, 4]:!exists:kv,
83aa430 @lizmat Some more :exists tests
lizmat authored
73 (1,False,2,False,4,False), "Test !exists:kv FFF";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
74 is-deeply @a[1,2,10]:!exists:kv,
83aa430 @lizmat Some more :exists tests
lizmat authored
75 (1,False,2,False), "Test !exists:kv FF.";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
76 is-deeply @a[1,2,10]:!exists:!kv,
83aa430 @lizmat Some more :exists tests
lizmat authored
77 (1,False,2,False,10,True), "Test !exists:kv FFT";
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
78
79 #?niezca 6 todo "no combined adverbial pairs"
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
80 is-deeply @a[1,2, 4]:exists:p,
83aa430 @lizmat Some more :exists tests
lizmat authored
81 (1=>True,2=>True,4=>True), "Test exists:p TTT";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
82 is-deeply @a[1,2,10]:exists:p,
83aa430 @lizmat Some more :exists tests
lizmat authored
83 (1=>True,2=>True), "Test exists:p TT.";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
84 is-deeply @a[1,2,10]:exists:!p,
83aa430 @lizmat Some more :exists tests
lizmat authored
85 (1=>True,2=>True,10=>False), "Test exists:!p TTF";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
86 is-deeply @a[1,2, 4]:!exists:p,
83aa430 @lizmat Some more :exists tests
lizmat authored
87 (1=>False,2=>False,4=>False), "Test !exists:p FFF";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
88 is-deeply @a[1,2,10]:!exists:p,
83aa430 @lizmat Some more :exists tests
lizmat authored
89 (1=>False,2=>False), "Test !exists:p FF.";
a87fde4 @lizmat s/is_deeply/is-deeply/g
lizmat authored
90 is-deeply @a[1,2,10]:!exists:!p,
83aa430 @lizmat Some more :exists tests
lizmat authored
91 (1=>False,2=>False,10=>True), "Test !exists:!p FFT";
92
93 #?niezca 6 todo "no combined adverbial pairs"
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
94 dies-ok { @a[1]:exists:k }, "Test exists:k, invalid combo";
95 dies-ok { @a[1]:exists:!k }, "Test exists:!k, invalid combo";
96 dies-ok { @a[1]:!exists:k }, "Test !exists:k, invalid combo";
97 dies-ok { @a[1]:!exists:!k }, "Test !exists:!k, invalid combo";
83aa430 @lizmat Some more :exists tests
lizmat authored
98
99 #?niezca 6 todo "no combined adverbial pairs"
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
100 dies-ok { @a[1]:exists:v }, "Test exists:v, invalid combo";
101 dies-ok { @a[1]:exists:!v }, "Test exists:!v, invalid combo";
102 dies-ok { @a[1]:!exists:v }, "Test !exists:v, invalid combo";
103 dies-ok { @a[1]:!exists:!v }, "Test !exists:!v, invalid combo";
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
104
105 is @a.elems, 10, "should be untouched";
83aa430 @lizmat Some more :exists tests
lizmat authored
106 } #46
7536e9c @lizmat Split off @a:exists tests into separate file
lizmat authored
107
108 # vim: ft=perl6
Something went wrong with that request. Please try again.