|
218 | 218 | @test mean(prevfloat(Inf):prevfloat(Inf)) === prevfloat(Inf) |
219 | 219 | end |
220 | 220 |
|
| 221 | +@testset "means (etc) of ranges; issue #120" begin |
| 222 | + @test (@inferred mean(Int8(123):Int8(123))) === 123.0 |
| 223 | + @test (@inferred median(Int8(123):Int8(123))) === 123.0 |
| 224 | + @test (@inferred mean(Int8(126):Int8(127))) === 126.5 |
| 225 | + @test (@inferred median(Int8(126):Int8(127))) === 126.5 |
| 226 | + @test (@inferred mean(typemax(Int):typemax(Int))) === typemax(Int)/1 |
| 227 | + @test (@inferred median(typemax(Int):typemax(Int))) === typemax(Int)/1 |
| 228 | + @test (@inferred mean(UInt8(255):UInt8(255))) === 255.0 |
| 229 | + @test (@inferred median(UInt8(255):UInt8(255))) === 255.0 |
| 230 | + @test (@inferred mean(Float16(12345):Float16(12345))) === Float16(12345) |
| 231 | + @test (@inferred median(Float16(12345):Float16(12345))) === Float16(12345) |
| 232 | + @test (@inferred mean(Float16(12345):Float16(54321))) === Float16(33333) |
| 233 | + @test (@inferred median(Float16(12345):Float16(54321))) === Float16(33333) |
| 234 | + |
| 235 | + for T in (Int8, UInt8, Int32, UInt32, Int64, UInt64) |
| 236 | + @test (@inferred mean(typemin(T):typemin(T))) === typemin(T)/1 |
| 237 | + @test (@inferred median(typemin(T):typemin(T))) === typemin(T)/1 |
| 238 | + @test (@inferred mean(typemax(T):typemax(T))) === typemax(T)/1 |
| 239 | + @test (@inferred median(typemax(T):typemax(T))) === typemax(T)/1 |
| 240 | + @test (@inferred mean(typemin(T):typemin(T))) === typemin(T)/1 |
| 241 | + @test (@inferred median(typemin(T):typemin(T))) === typemin(T)/1 |
| 242 | + end |
| 243 | +end |
| 244 | + |
221 | 245 | @testset "var & std" begin |
222 | 246 | # edge case: empty vector |
223 | 247 | # iterable; this has to throw for type stability |
|
0 commit comments