@@ -37,6 +37,7 @@ is min(:by({ $^a.abs }), @array), 0,
37
37
" subroutine form of min taking a comparison block works" ;
38
38
39
39
# ?rakudo 2 skip "Range.min not fully implemented yet (RT #105118)"
40
+ # ?niecza 2 skip "Range.min not fully implemented yet"
40
41
is ((-10 .. 10 ). min : { abs $ ^ a <= > abs $ ^ b }), 0 ,
41
42
" method form of min on Ranges taking a comparison block works" ;
42
43
@@ -53,6 +54,7 @@ is (@array.max: { $^a <=> $^b }), 7,
53
54
is max (@ array ), 7 , ' sub form of max' ;
54
55
55
56
# ?rakudo skip "Range.max not fully implemented yet (RT #105118)"
57
+ # ?niecza 2 skip "Range.max not fully implemented yet"
56
58
is ((-10 .. 9 ). max : { abs $ ^ a <= > abs $ ^ b }), -10 ,
57
59
" method form of max on Ranges taking a comparison block works" ;
58
60
@@ -73,6 +75,7 @@ is max(:by({ $^a.abs }), @array), -9,
73
75
" subroutine form of max taking a modifier block works" ;
74
76
75
77
# ?rakudo skip "Range.max not fully implemented yet (RT #105118)"
78
+ # ?niecza skip "Range.min not fully implemented yet"
76
79
is ((1 .. 10 ). max : { ($ _ -3) * ($ _ -5) }), 10 ,
77
80
" method form of max taking an arity-1 comparison block works" ;
78
81
@@ -104,32 +107,40 @@ is ((1..10).minmax: { ($_-3) * ($_-5) }), 4..10,
104
107
105
108
# Error cases:
106
109
# ?pugs 2 todo 'bug'
110
+ # ?niecza 2 skip "Unable to resolve method min/max in class Int"
107
111
is 42 . min , 42 , " .min should work on scalars" ;
108
112
is 42 . max , 42 , " .max should work on scalars" ;
113
+ # ?niecza 2 skip "Unable to resolve method min/max in class Parcel"
109
114
is (42 ,). min , 42 , " .min should work on one-elem arrays" ;
110
115
is (42 ,). max , 42 , " .max should work on one-elem arrays" ;
111
116
112
117
# Tests with literals:
118
+ # ?niecza 2 skip "Unable to resolve method min/max in class Parcel"
113
119
is (1 ,2 ,3 ). max , 3 , " method form of max with literals works" ;
114
120
is (1 ,2 ,3 ). min , 1 , " method form of min with literals works" ;
115
121
is max (: by({$ ^ a <= > $ ^ b }), 1 ,2 ,3 ), 3 , " subroutine form of max with literals works" ;
116
122
is min (: by({$ ^ a <= > $ ^ b }), 1 ,2 ,3 ), 1 , " subroutine form of min with literals works" ;
117
123
118
124
# Try to read numbers from a file
119
- @ array = lines (" t/spec/S32-list/numbers.data" );
120
- # ?rakudo todo 'nom regression'
121
- is @ array . max , 5 , " max of strings read from a file works" ;
122
- # ?rakudo todo 'nom regression'
123
- is @ array . min , -1 , " min of strings read from a file works" ;
124
-
125
- # Same, but numifying the numbers first
126
- # ?rakudo skip 'nom regression'
127
125
{
128
- @ array = map { + $ _ }, @ array ;
129
- is @ array . max , 28 , " max of strings read from a file works" ;
130
- is @ array . min , -80 , " min of strings read from a file works" ;
126
+ my $ fh = open " t/spec/S32-list/numbers.data" ;
127
+ @ array = $ fh . lines ();
128
+ # ?rakudo todo 'nom regression'
129
+ is @ array . max , 5 , " max of strings read from a file works" ;
130
+ # ?rakudo todo 'nom regression'
131
+ is @ array . min , -1 , " min of strings read from a file works" ;
132
+
133
+ # Same, but numifying the numbers first
134
+ # ?rakudo skip 'nom regression'
135
+ {
136
+ @ array = map { + $ _ }, @ array ;
137
+ is @ array . max , 28 , " max of strings read from a file works" ;
138
+ is @ array . min , -80 , " min of strings read from a file works" ;
139
+ }
140
+
131
141
}
132
142
143
+ # ?niecza 4 skip 'Unable to resolve method max in class Parcel'
133
144
is (1 , Inf ). max , Inf ," Inf is greater than 1" ;
134
145
is (-1 , -Inf ). min , -Inf ," -Inf is less than -1" ;
135
146
is (-Inf , Inf ). min , -Inf ," -Inf is less than Inf" ;
@@ -150,6 +161,7 @@ is (-Inf, Inf).max, Inf,"Inf is greater than -Inf";
150
161
# is (0, NaN).max, NaN, "max(0,NaN)=NaN";
151
162
# is (Inf, NaN).max, NaN, "max(Inf,NaN)=NaN";
152
163
164
+ # ?niecza 4 skip "Excess arguments to infix:<min>"
153
165
is ([min ] (5 ,10 ,-15 ,20 )), -15 , ' reduce min int' ;
154
166
is ([max ] (5 ,10 ,-15 ,20 )), 20 , ' reduce max int' ;
155
167
0 commit comments