|
760 | 760 | @test quadgk(cos, 0,0.7,1, norm=abs)[1] ≈ sin(1) |
761 | 761 | end |
762 | 762 |
|
| 763 | +module Test19626 |
| 764 | + using Base.Test |
| 765 | + |
| 766 | + # Define a mock physical quantity type |
| 767 | + immutable MockQuantity <: Number |
| 768 | + val::Float64 |
| 769 | + end |
| 770 | + |
| 771 | + # Following definitions needed for quadgk to work with MockQuantity |
| 772 | + import Base: +, -, *, abs, isnan, isinf, isless |
| 773 | + +(a::MockQuantity, b::MockQuantity) = MockQuantity(a.val+b.val) |
| 774 | + -(a::MockQuantity, b::MockQuantity) = MockQuantity(a.val-b.val) |
| 775 | + *(a::MockQuantity, b::Number) = MockQuantity(a.val*b) |
| 776 | + abs(a::MockQuantity) = MockQuantity(abs(a.val)) |
| 777 | + isnan(a::MockQuantity) = isnan(a.val) |
| 778 | + isinf(a::MockQuantity) = isinf(a.val) |
| 779 | + isless(a::MockQuantity, b::MockQuantity) = isless(a.val, b.val) |
| 780 | + |
| 781 | + # isapprox only needed for test purposes |
| 782 | + Base.isapprox(a::MockQuantity, b::MockQuantity) = isapprox(a.val, b.val) |
| 783 | + |
| 784 | + # Test physical quantity-valued functions |
| 785 | + @test quadgk(x->MockQuantity(x), 0.0, 1.0, abstol=MockQuantity(0.0))[1] ≈ |
| 786 | + MockQuantity(0.5) |
| 787 | +end |
| 788 | + |
763 | 789 | @testset "subnormal flags" begin |
764 | 790 | # Ensure subnormal flags functions don't segfault |
765 | 791 | @test any(set_zero_subnormals(true) .== [false,true]) |
|
0 commit comments