@@ -29,6 +29,7 @@ using Test
2929
3030 @test PiTimes (pi ) === PiExpTimes {2} (1 )
3131 @test PiExpTimes {2} (pi ) === PiExpTimes {3} (1 )
32+ @test PiExpTimes {2,Irrational{:π}} (π) == PiExpTimes {3} (1 )
3233
3334 @test PiExpTimes {2} (π) == PiExpTimes {3} (1 )
3435
101102 @test Pi² != Pi³
102103 @test Pi³ != Pi²
103104
104- @test Pi² != π
105- @test π != Pi²
105+ @test ! ( Pi² == π)
106+ @test ! (π == Pi²)
106107
107108 @test z² == z³
108109 @test z² == 0
@@ -215,45 +216,76 @@ end
215216 end
216217 @testset " PiExpTimes{2} and PiExpTimes{2}" begin
217218 for t in (Int8, Int16, Int32, Int64, Int128, Bool, UInt8, UInt16, UInt32, UInt64, UInt128)
219+ @test promote_rule (PiExpTimes{2 ,Float16},PiExpTimes{2 ,t}) === PiExpTimes{2 ,Float16}
220+ @test promote_rule (PiExpTimes{2 ,t},PiExpTimes{2 ,Float16}) === PiExpTimes{2 ,Float16}
218221 @test promote_type (PiExpTimes{2 ,Float16},PiExpTimes{2 ,t}) === PiExpTimes{2 ,Float16}
219222 @test promote_type (PiExpTimes{2 ,t},PiExpTimes{2 ,Float16}) === PiExpTimes{2 ,Float16}
220223 end
221224 for t1 in (Float32, Float64)
222225 for t2 in (Int8, Int16, Int32, Int64, Bool, UInt8, UInt16, UInt32, UInt64)
226+ @test promote_rule (PiExpTimes{2 ,t1},PiExpTimes{2 ,t2}) === PiExpTimes{2 ,t1}
227+ @test promote_rule (PiExpTimes{2 ,t2},PiExpTimes{2 ,t1}) === PiExpTimes{2 ,t1}
223228 @test promote_type (PiExpTimes{2 ,t1},PiExpTimes{2 ,t2}) === PiExpTimes{2 ,t1}
224229 @test promote_type (PiExpTimes{2 ,t2},PiExpTimes{2 ,t1}) === PiExpTimes{2 ,t1}
225230 end
226231 end
227232 end
228233 @testset " PiExpTimes{2} and PiTimes" begin
229234 for t in (Int8, Int16, Int32, Int64, Int128, Bool, UInt8, UInt16, UInt32, UInt64, UInt128)
235+ @test promote_rule (PiExpTimes{2 ,Float16},PiTimes{t}) === Float64
236+ @test promote_rule (PiTimes{t},PiExpTimes{2 ,Float16}) === Float64
230237 @test promote_type (PiExpTimes{2 ,Float16},PiTimes{t}) === Float64
231238 @test promote_type (PiTimes{t},PiExpTimes{2 ,Float16}) === Float64
232239 end
233240 for t1 in (Float32, Float64)
234241 for t2 in (Int8, Int16, Int32, Int64, Bool, UInt8, UInt16, UInt32, UInt64)
235- @test promote_type (PiExpTimes{2 ,t1},PiTimes{t2}) === Float64
242+ @test promote_rule (PiExpTimes{2 ,t1},PiTimes{t2}) === Float64
243+ @test promote_rule (PiTimes{t2},PiExpTimes{2 ,t1}) === Float64
244+ @test promote_type (PiTimes{t2},PiExpTimes{2 ,t1}) === Float64
236245 @test promote_type (PiTimes{t2},PiExpTimes{2 ,t1}) === Float64
237246 end
238247 end
239248 end
240249 end
241250
242251 @testset " PiExpTimes and Irrational" begin
252+ @test promote_rule (PiTimes{Int},Irrational{:π }) === PiTimes{Int}
253+ @test promote_rule (Irrational{:π },PiTimes{Int}) === PiTimes{Int}
243254 @test promote_type (PiTimes{Int},Irrational{:π }) === PiTimes{Int}
244255 @test promote_type (Irrational{:π },PiTimes{Int}) === PiTimes{Int}
256+
257+ @test promote_rule (PiTimes{Float64},Irrational{:π }) === PiTimes{Float64}
258+ @test promote_rule (Irrational{:π },PiTimes{Float64}) === PiTimes{Float64}
245259 @test promote_type (PiTimes{Float64},Irrational{:π }) === PiTimes{Float64}
246260 @test promote_type (Irrational{:π },PiTimes{Float64}) === PiTimes{Float64}
261+
262+ @test promote_rule (PiExpTimes{2 ,Int},Irrational{:π }) === Float64
263+ @test promote_rule (Irrational{:π },PiExpTimes{2 ,Int}) === Float64
264+ @test promote_type (PiExpTimes{2 ,Int},Irrational{:π }) === Float64
265+ @test promote_type (Irrational{:π },PiExpTimes{2 ,Int}) === Float64
266+
267+ @test promote_rule (PiExpTimes{2 ,Float64},Irrational{:π }) === Float64
268+ @test promote_rule (Irrational{:π },PiExpTimes{2 ,Float64}) === Float64
269+ @test promote_type (PiExpTimes{2 ,Float64},Irrational{:π }) === Float64
270+ @test promote_type (Irrational{:π },PiExpTimes{2 ,Float64}) === Float64
247271 end
248272
249273 @testset " Complex{PiExpTimes}" begin
250274 @testset " Complex{PiTimes} and Irrational{:π}" begin
275+ @test promote_rule (Complex{PiTimes{Int}},Irrational{:π }) === Complex{PiTimes{Int}}
276+ @test promote_rule (Irrational{:π },Complex{PiTimes{Int}}) === Complex{PiTimes{Int}}
277+ @test promote_rule (Complex{PiTimes{Float64}},Irrational{:π }) === Complex{PiTimes{Float64}}
278+ @test promote_rule (Irrational{:π },Complex{PiTimes{Float64}}) === Complex{PiTimes{Float64}}
251279 @test promote_type (Complex{PiTimes{Int}},Irrational{:π }) === Complex{PiTimes{Int}}
252280 @test promote_type (Irrational{:π },Complex{PiTimes{Int}}) === Complex{PiTimes{Int}}
253281 @test promote_type (Complex{PiTimes{Float64}},Irrational{:π }) === Complex{PiTimes{Float64}}
254282 @test promote_type (Irrational{:π },Complex{PiTimes{Float64}}) === Complex{PiTimes{Float64}}
255283 end
256284 @testset " Complex{PiExpTimes} and Irrational{:π}" begin
285+ @test promote_rule (Complex{PiExpTimes{2 ,Int}},Irrational{:π }) === Complex{Float64}
286+ @test promote_rule (Irrational{:π },Complex{PiExpTimes{2 ,Int}}) === Complex{Float64}
287+ @test promote_rule (Complex{PiExpTimes{2 ,Float64}},Irrational{:π }) === Complex{Float64}
288+ @test promote_rule (Irrational{:π },Complex{PiExpTimes{2 ,Float64}}) === Complex{Float64}
257289 @test promote_type (Complex{PiExpTimes{2 ,Int}},Irrational{:π }) === Complex{Float64}
258290 @test promote_type (Irrational{:π },Complex{PiExpTimes{2 ,Int}}) === Complex{Float64}
259291 @test promote_type (Complex{PiExpTimes{2 ,Float64}},Irrational{:π }) === Complex{Float64}
@@ -276,16 +308,29 @@ end
276308 @test Float16 (PiTimes (1 )) === Float16 (1 )* π
277309 end
278310 @testset " PiExpTimes" begin
279- @test convert (Float64,PiExpTimes {2} (1 )) === Float64 (π^ 2 )
280- @test Float64 (PiExpTimes {2} (1 )) === Float64 (1 )* π^ 2
281- @test convert (Float64,PiExpTimes {2} (2 )) === Float64 (2 π^ 2 )
282- @test Float64 (PiExpTimes {2} (2 )) === Float64 (2 )* π^ 2
311+ @test convert (Float64,PiExpTimes {2} (1 )) === Float64 (π* π )
312+ @test Float64 (PiExpTimes {2} (1 )) === Float64 (1 )* π* π
313+ @test convert (Float64,PiExpTimes {2} (2 )) === Float64 (2 π* π )
314+ @test Float64 (PiExpTimes {2} (2 )) === Float64 (2 )* π* π
283315 @test convert (BigFloat,PiExpTimes {2} (1 )) == BigFloat (1 )* π* π
284316 @test BigFloat (PiExpTimes {2} (1 )) == BigFloat (1 )* π* π
285317 @test convert (Float32,PiExpTimes {2} (1 )) === Float32 (1 )* π* π
286318 @test Float32 (PiExpTimes {2} (1 )) === Float32 (1 )* π* π
287319 @test convert (Float16,PiExpTimes {2} (1 )) === Float16 (1 )* π* π
288320 @test Float16 (PiExpTimes {2} (1 )) === Float16 (1 )* π* π
321+
322+ @test AbstractFloat (PiExpTimes {2} (1 )) === Float64 (π* π)
323+ @test float (PiExpTimes {2} (1 )) === Float64 (π* π)
324+
325+ @test Float64 (PiExpTimes {0,Int} (1 )) === Float64 (1 )
326+ @test Float32 (PiExpTimes {0,Int} (1 )) === Float32 (1 )
327+ @test Float16 (PiExpTimes {0,Int} (1 )) === Float16 (1 )
328+ @test convert (Float64,PiExpTimes {0,Int} (1 )) === Float64 (1 )
329+ @test convert (Float32,PiExpTimes {0,Int} (1 )) === Float32 (1 )
330+ @test convert (Float16,PiExpTimes {0,Int} (1 )) === Float16 (1 )
331+
332+ @test AbstractFloat (PiExpTimes {0,Int} (1 )) === Float64 (1 )
333+ @test float (PiExpTimes {0,Int} (1 )) === Float64 (1 )
289334 end
290335 end
291336 @testset " Real to PiExpTimes" begin
336381 @test convert (PiExpTimes{2 },Pi^ 2 ) === Pi^ 2
337382 @test convert (PiExpTimes{2 ,Float64},Pi^ 2 ) === 1.0 * Pi^ 2
338383 @test convert (PiExpTimes{2 ,Int},Pi^ 2 ) === Pi^ 2
384+ @test convert (PiExpTimes{2 ,Int},PiExpTimes {2,Int} (2 )) === PiExpTimes {2,Int} (2 )
339385 @test convert (PiExpTimes{2 },Pi^ 3 ) === PiExpTimes {2} (float (π))
340386 @test convert (PiExpTimes{2 ,Float64},Pi) === PiExpTimes {2} (1 / π)
341387 @test convert (PiExpTimes{2 ,Float64},Pi^ 2 ) === PiExpTimes {2} (1.0 )
@@ -356,26 +402,30 @@ end
356402 p = PiTimes (3 )
357403 q = PiTimes (4 )
358404 r = PiExpTimes {2} (4 )
405+ z = PiExpTimes {0,Int} (3 )
359406
360407 @testset " negation" begin
361408 @test - p isa PiTimes{Int}
362409 @test - r isa PiExpTimes{2 ,Int}
363410 @test - p === PiTimes (- p. x)
364411 @test - r === PiExpTimes {2} (- r. x)
412+ @test - z === - z. x
365413 end
366414
367415 @testset " addition" begin
368416 @test p + p === PiTimes (2 p. x)
369417 @test p + q === PiTimes (p. x + q. x)
370418 @test r + r === PiExpTimes {2} (2 r. x)
371419 @test p + r === float (p) + float (r)
420+ @test z + z === 2 z. x
372421 end
373422
374423 @testset " subtraction" begin
375424 @test p - p === PiTimes (0 ) == 0
376425 @test p - q === PiTimes (p. x - q. x)
377426 @test r - r === PiExpTimes {2} (zero (r. x)) == 0
378427 @test p - r === float (p) - float (r)
428+ @test z - z === zero (z. x)
379429 end
380430
381431 @testset " multiplication" begin
0 commit comments