@@ -67,26 +67,63 @@ function test_NCRing_interface(R::AbstractAlgebra.NCRing; reps = 50)
6767 end
6868 end
6969
70- @testset " Basic functions " begin
70+ @testset " Basic properties " begin
7171 @test iszero (R ()) # R() is supposed to construct 0 ?
7272 @test iszero (zero (R))
7373 @test isone (one (R))
7474 @test iszero (R (0 ))
7575 @test isone (R (1 ))
76- @test isone ( R ( 0 )) || ! is_unit ( R ( 0 ))
76+
7777 @test is_unit (R (1 ))
78+ if is_trivial (R)
79+ @test isone (R (0 ))
80+ @test iszero (R (1 ))
81+ @test R (0 ) == R (1 )
82+ else
83+ @test ! is_unit (R (0 ))
84+ for i in 1 : reps
85+ a = generate_element (R):: T
86+ @test is_unit (a) == is_unit (a^ 2 )
87+ end
88+ end
89+
90+ # test is_nilpotent if it is supported
91+ try
92+ f = is_nilpotent (R (1 ))
93+ @test is_nilpotent (R (0 ))
94+ if is_trivial (R)
95+ @test is_nilpotent (R (1 ))
96+ else
97+ @test ! is_unit (R (0 ))
98+ @test ! is_nilpotent (R (1 ))
99+ for i in 1 : reps
100+ a = generate_element (R):: T
101+ @test ! (is_unit (a) && is_nilpotent (a))
102+ @test is_nilpotent (a) == is_nilpotent (a^ 2 )
103+ if is_domain_type (typeof (a))
104+ @test is_nilpotent (a) == is_zero (a)
105+ end
106+ end
107+ end
108+ catch
109+ end
110+ end
111+
112+ @testset " hash, deepcopy, equality, printing, parent" begin
78113 for i in 1 : reps
79114 a = generate_element (R):: T
80115 @test hash (a) isa UInt
81116 A = deepcopy (a)
82117 @test ! ismutable (a) || a != = A
83118 @test equality (a, A)
84119 @test hash (a) == hash (A)
85- @test parent (a) === parent (A)
120+ @test parent (a) === R
86121 @test sprint (show, " text/plain" , a) isa String
87122 end
88123 @test sprint (show, " text/plain" , R) isa String
124+ end
89125
126+ @testset " Basic arithmetic" begin
90127 for i in 1 : reps
91128 a = generate_element (R):: T
92129 b = generate_element (R):: T
0 commit comments