@@ -366,28 +366,24 @@ end
366366 @test_throws InexactError convert (BigInt, 2.1 )
367367 @test_throws InexactError convert (BigInt, big (2.1 ))
368368end
369- @testset " issue #13367" begin
370- @test trunc (BigInt,2.1 ) == 2
371- @test round (BigInt,2.1 ) == 2
372- @test floor (BigInt,2.1 ) == 2
373- @test ceil (BigInt,2.1 ) == 3
374-
375- @test trunc (BigInt,2.1f0 ) == 2
376- @test round (BigInt,2.1f0 ) == 2
377- @test floor (BigInt,2.1f0 ) == 2
378- @test ceil (BigInt,2.1f0 ) == 3
379-
380- @test_throws InexactError trunc (BigInt,Inf )
381- @test_throws InexactError round (BigInt,Inf )
382- @test_throws InexactError floor (BigInt,Inf )
383- @test_throws InexactError ceil (BigInt,Inf )
384-
385- @test string (big (3 ), base = 2 ) == " 11"
386- @test string (big (9 ), base = 8 ) == " 11"
387- @test string (- big (9 ), base = 8 ) == " -11"
388- @test string (big (12 ), base = 16 ) == " c"
369+ @testset " truncation" begin
370+ # cf. issue #13367
371+ for T = (Float16, Float32, Float64)
372+ @test trunc (BigInt, T (2.1 )) == 2
373+ @test unsafe_trunc (BigInt, T (2.1 )) == 2
374+ @test round (BigInt, T (2.1 )) == 2
375+ @test floor (BigInt, T (2.1 )) == 2
376+ @test ceil (BigInt, T (2.1 )) == 3
377+
378+ @test_throws InexactError trunc (BigInt, T (Inf ))
379+ @test_throws InexactError round (BigInt, T (Inf ))
380+ @test_throws InexactError floor (BigInt, T (Inf ))
381+ @test_throws InexactError ceil (BigInt, T (Inf ))
382+ end
389383end
390- @testset " Issue #18849" begin
384+
385+ @testset " string(::BigInt)" begin
386+ # cf. issue #18849"
391387 # bin, oct, dec, hex should not call sizeof on BigInts
392388 # when padding is desired
393389 padding = 4
@@ -412,14 +408,19 @@ end
412408 @test string (- high, pad = padding, base = 8 ) == " -4000000"
413409 @test string (- high, pad = padding, base = 10 ) == " -1048576"
414410 @test string (- high, pad = padding, base = 16 ) == " -100000"
415- end
416411
417- # respect 0-padding on big(0)
418- for base in (2 , 8 , 10 , 16 )
419- local base
420- @test string (big (0 ), base= base, pad= 0 ) == " "
412+ # cf. issue #13367
413+ @test string (big (3 ), base = 2 ) == " 11"
414+ @test string (big (9 ), base = 8 ) == " 11"
415+ @test string (- big (9 ), base = 8 ) == " -11"
416+ @test string (big (12 ), base = 16 ) == " c"
417+
418+ # respect 0-padding on big(0)
419+ for base in (2 , 8 , 10 , 16 )
420+ @test string (big (0 ), base= base, pad= 0 ) == " "
421+ end
422+ @test string (big (0 ), base = rand (2 : 62 ), pad = 0 ) == " "
421423end
422- @test string (big (0 ), base = rand (2 : 62 ), pad = 0 ) == " "
423424
424425@test isqrt (big (4 )) == 2
425426@test isqrt (big (5 )) == 2
0 commit comments