diff --git a/lib/ring.gi b/lib/ring.gi index 4b5b411ad7..ca631d6fe8 100644 --- a/lib/ring.gi +++ b/lib/ring.gi @@ -702,7 +702,7 @@ InstallMethod( IsIntegralRing, zero := Zero( R ); for i in [1..Length(elms)] do if elms[i] = zero then continue; fi; - for k in [i+1..Length(elms)] do + for k in [i..Length(elms)] do if elms[k] = zero then continue; fi; if elms[i] * elms[k] = zero then return false; diff --git a/tst/testinstall/ring.tst b/tst/testinstall/ring.tst new file mode 100644 index 0000000000..a1beb16362 --- /dev/null +++ b/tst/testinstall/ring.tst @@ -0,0 +1,30 @@ +gap> START_TEST("ring.tst"); + +##################################################################### +# +# Tests for IsIntegralRing +# +# Trivial ring +gap> IsIntegralRing( SmallRing(1,1) ); +false + +# Non-commutative ring +gap> IsIntegralRing( SmallRing(4,7) ); +false + +# Zero divisors on the diagonal +gap> IsIntegralRing( SmallRing(4,3) ); +false + +# Integral rings +gap> IsIntegralRing( GF(5) ); +true +gap> IsIntegralRing( Integers ); +true +gap> IsIntegralRing( Rationals ); +true +gap> IsIntegralRing( CF(4) ); +true + +# +gap> STOP_TEST( "ring.tst" );