@@ -253,6 +253,102 @@ end
253253 end
254254end
255255
256+ @testset " equality between types" begin
257+ @test FD {Int8, 0} (1 ) == FD {Int8, 2} (1 )
258+ @test FD {Int8, 0} (0 ) != FD {Int8, 2} (1 )
259+ # Note: this doesn't throw inexact error
260+ @test FD {Int8, 0} (2 ) != FD {Int8, 2} (1 ) # FD{Int8,2}(2) doesn't fit
261+
262+ @test FD {Int8, 0} (1 ) == FD {Int16, 1} (1 )
263+ @test FD {Int8, 0} (2 ) != FD {Int16, 1} (1 )
264+ # Note: this doesn't throw inexact error
265+ @test FD {Int8, 0} (4 ) != FD {Int16, 4} (1 ) # FD{Int16,4}(4) doesn't fit
266+
267+ # Integer == FD
268+ @test 1 == FD {Int8, 2} (1 )
269+ @test 2 != FD {Int8, 2} (1 )
270+ @test FD {Int8, 2} (1 ) == 1
271+ @test FD {Int8, 2} (1 ) != 2
272+ @test 1 == FD {Int8, 0} (1 ) != 2
273+
274+ @test typemax (Int16) != = FD {Int8, 0} (1 )
275+ @test typemax (Int16) != = FD {Int8, 2} (1 )
276+ @test typemin (Int16) != = FD {Int8, 0} (1 )
277+ @test typemin (Int16) != = FD {Int8, 2} (1 )
278+ @test FD {Int8, 0} (1 ) != typemax (Int16)
279+ @test FD {Int8, 2} (1 ) != typemax (Int16)
280+ @test FD {Int8, 0} (1 ) != typemin (Int16)
281+ @test FD {Int8, 2} (1 ) != typemin (Int16)
282+
283+ @test typemax (Int16) != = FD {Int8, 0} (- 1 )
284+ @test typemax (Int16) != = FD {Int8, 2} (- 1 )
285+ @test typemin (Int16) != = FD {Int8, 0} (- 1 )
286+ @test typemin (Int16) != = FD {Int8, 2} (- 1 )
287+ @test FD {Int8, 0} (- 1 ) != typemax (Int16)
288+ @test FD {Int8, 2} (- 1 ) != typemax (Int16)
289+ @test FD {Int8, 0} (- 1 ) != typemin (Int16)
290+ @test FD {Int8, 2} (- 1 ) != typemin (Int16)
291+
292+ @test typemax (Int16) != = FD {Int8, 0} (0 )
293+ @test typemax (Int16) != = FD {Int8, 2} (0 )
294+ @test typemin (Int16) != = FD {Int8, 0} (0 )
295+ @test typemin (Int16) != = FD {Int8, 2} (0 )
296+ @test FD {Int8, 0} (0 ) != typemax (Int16)
297+ @test FD {Int8, 2} (0 ) != typemax (Int16)
298+ @test FD {Int8, 0} (0 ) != typemin (Int16)
299+ @test FD {Int8, 2} (0 ) != typemin (Int16)
300+ end
301+ @testset " inequality between types" begin
302+ @test FD {Int8, 0} (1 ) <= FD {Int8, 2} (1 )
303+ @test FD {Int8, 0} (0 ) < FD {Int8, 2} (1 )
304+ # Note: this doesn't throw inexact error
305+ @test FD {Int8, 0} (2 ) >= FD {Int8, 2} (1 ) # FD{Int8,2}(2) doesn't fit
306+ @test FD {Int8, 2} (1 ) < FD {Int8, 0} (2 ) # FD{Int8,2}(2) doesn't fit
307+
308+ @test FD {Int8, 0} (1 ) <= FD {Int16, 1} (1 )
309+ @test FD {Int8, 0} (2 ) > FD {Int16, 1} (1 )
310+ # Note: this doesn't throw inexact error
311+ @test FD {Int8, 0} (4 ) > FD {Int16, 4} (1 ) # FD{Int16,4}(4) doesn't fit
312+ @test FD {Int8, 0} (4 ) >= FD {Int16, 4} (1 ) # FD{Int16,4}(4) doesn't fit
313+ @test FD {Int16, 4} (1 ) < FD {Int8, 0} (4 ) # FD{Int16,4}(4) doesn't fit
314+
315+ # Integer == FD
316+ @test 1 <= FD {Int8, 2} (1 ) <= 1
317+ @test 1 >= FD {Int8, 2} (1 ) >= 1
318+ @test 2 > FD {Int8, 2} (1 )
319+ @test FD {Int8, 2} (1 ) < 2
320+ @test 2 >= FD {Int8, 2} (1 )
321+ @test FD {Int8, 2} (1 ) <= 2
322+ @test 1 <= FD {Int8, 0} (1 ) < 2
323+
324+ @test typemax (Int16) > FD {Int8, 0} (1 ) > typemin (Int16)
325+ @test typemax (Int16) > FD {Int8, 2} (1 ) > typemin (Int16)
326+ @test typemin (Int16) < FD {Int8, 0} (1 ) < typemax (Int16)
327+ @test typemin (Int16) < FD {Int8, 2} (1 ) < typemax (Int16)
328+ @test ! (typemax (Int16) < FD {Int8, 0} (1 ) < typemin (Int16))
329+ @test ! (typemax (Int16) < FD {Int8, 2} (1 ) < typemin (Int16))
330+ @test ! (typemin (Int16) > FD {Int8, 0} (1 ) > typemax (Int16))
331+ @test ! (typemin (Int16) > FD {Int8, 2} (1 ) > typemax (Int16))
332+
333+ @test typemax (Int16) > FD {Int8, 0} (- 1 ) > typemin (Int16)
334+ @test typemax (Int16) > FD {Int8, 2} (- 1 ) > typemin (Int16)
335+ @test typemin (Int16) < FD {Int8, 0} (- 1 ) < typemax (Int16)
336+ @test typemin (Int16) < FD {Int8, 2} (- 1 ) < typemax (Int16)
337+ @test ! (typemax (Int16) < FD {Int8, 0} (- 1 ) < typemin (Int16))
338+ @test ! (typemax (Int16) < FD {Int8, 2} (- 1 ) < typemin (Int16))
339+ @test ! (typemin (Int16) > FD {Int8, 0} (- 1 ) > typemax (Int16))
340+ @test ! (typemin (Int16) > FD {Int8, 2} (- 1 ) > typemax (Int16))
341+
342+ @test typemax (Int16) >= FD {Int8, 0} (0 ) >= typemin (Int16)
343+ @test typemax (Int16) >= FD {Int8, 2} (0 ) >= typemin (Int16)
344+ @test typemin (Int16) <= FD {Int8, 0} (0 ) <= typemax (Int16)
345+ @test typemin (Int16) <= FD {Int8, 2} (0 ) <= typemax (Int16)
346+ @test ! (typemax (Int16) <= FD {Int8, 0} (- 1 ) <= typemin (Int16))
347+ @test ! (typemax (Int16) <= FD {Int8, 2} (- 1 ) <= typemin (Int16))
348+ @test ! (typemin (Int16) >= FD {Int8, 0} (- 1 ) >= typemax (Int16))
349+ @test ! (typemin (Int16) >= FD {Int8, 2} (- 1 ) >= typemax (Int16))
350+ end
351+
256352@testset " 128-bit conversion correctness" begin
257353 # Force the bits for these tests
258354 F64D2 = FixedDecimal{Int64, 2 }
0 commit comments