|
1 | | -using Test: @test, @inferred |
| 1 | +using Test: @test, @testset, @inferred |
2 | 2 | using BaseType: base_numeric_type |
3 | 3 | using DualNumbers: DualNumbers |
4 | 4 | using DynamicQuantities: DynamicQuantities |
5 | 5 | using Measurements: ± |
6 | 6 | using Unitful: Unitful |
7 | 7 |
|
8 | | -expected_type_pairs = [ |
9 | | - Float32 => Float32, |
10 | | - ComplexF64 => Float64, |
11 | | - DualNumbers.Dual{Int64} => Int64, |
12 | | - DynamicQuantities.Quantity{Float32} => Float32, |
13 | | - typeof(1.5DynamicQuantities.u"km/s") => Float64, |
14 | | - typeof(1.5f0Unitful.u"km/s") => Float32, |
15 | | - BigFloat => BigFloat, |
16 | | - typeof(1.5 ± 0.2) => Float64, |
17 | | - typeof(1.5f0 ± 0.2f0) => Float32, |
18 | | -] |
| 8 | +@testset "Basic usage" begin |
| 9 | + expected_type_pairs = [ |
| 10 | + Float32 => Float32, |
| 11 | + ComplexF64 => Float64, |
| 12 | + DualNumbers.Dual{Int64} => Int64, |
| 13 | + DynamicQuantities.Quantity{Float32} => Float32, |
| 14 | + typeof(1.5DynamicQuantities.u"km/s") => Float64, |
| 15 | + typeof(1.5f0Unitful.u"km/s") => Float32, |
| 16 | + BigFloat => BigFloat, |
| 17 | + typeof(1.5 ± 0.2) => Float64, |
| 18 | + typeof(1.5f0 ± 0.2f0) => Float32, |
| 19 | + ] |
19 | 20 |
|
20 | | -for (x, y) in expected_type_pairs |
21 | | - @eval @test base_numeric_type($x) == $y |
22 | | - # Make sure compiler can inline it: |
23 | | - @eval @inferred $y base_numeric_type($x) |
| 21 | + for (x, y) in expected_type_pairs |
| 22 | + @eval @test base_numeric_type($x) == $y |
| 23 | + # Make sure compiler can inline it: |
| 24 | + @eval @inferred $y base_numeric_type($x) |
| 25 | + end |
| 26 | + |
| 27 | + @test base_numeric_type(1.5DynamicQuantities.u"km/s") == base_numeric_type(typeof(1.5DynamicQuantities.u"km/s")) |
| 28 | + @inferred base_numeric_type(1.5DynamicQuantities.u"km/s") |
24 | 29 | end |
25 | 30 |
|
26 | 31 | @test base_numeric_type(1.5DynamicQuantities.u"km/s") == base_numeric_type(typeof(1.5DynamicQuantities.u"km/s")) |
|
0 commit comments