@@ -67,26 +67,63 @@ function test_NCRing_interface(R::AbstractAlgebra.NCRing; reps = 50)
67
67
end
68
68
end
69
69
70
- @testset " Basic functions " begin
70
+ @testset " Basic properties " begin
71
71
@test iszero (R ()) # R() is supposed to construct 0 ?
72
72
@test iszero (zero (R))
73
73
@test isone (one (R))
74
74
@test iszero (R (0 ))
75
75
@test isone (R (1 ))
76
- @test isone ( R ( 0 )) || ! is_unit ( R ( 0 ))
76
+
77
77
@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
78
113
for i in 1 : reps
79
114
a = generate_element (R):: T
80
115
@test hash (a) isa UInt
81
116
A = deepcopy (a)
82
117
@test ! ismutable (a) || a != = A
83
118
@test equality (a, A)
84
119
@test hash (a) == hash (A)
85
- @test parent (a) === parent (A)
120
+ @test parent (a) === R
86
121
@test sprint (show, " text/plain" , a) isa String
87
122
end
88
123
@test sprint (show, " text/plain" , R) isa String
124
+ end
89
125
126
+ @testset " Basic arithmetic" begin
90
127
for i in 1 : reps
91
128
a = generate_element (R):: T
92
129
b = generate_element (R):: T
0 commit comments