diff --git a/doc/specs/stdlib_bitsets.md b/doc/specs/stdlib_bitsets.md index 77da22b9b..7cbca1175 100644 --- a/doc/specs/stdlib_bitsets.md +++ b/doc/specs/stdlib_bitsets.md @@ -194,8 +194,8 @@ undefined. These procedures are summarized in the following table: ### Assignments -The module defines an assignment operation, `=`, that creates a -duplicate of an original bitset. It also defines assignments to and +The module uses the intrinsic assignment operation, `=`, to create a +duplicate of an original bitset. It additionally defines assignments to and from rank one arrays of logical type of kinds `int8`, `int16`, `int32`, and `int64`. In the assignment to and from logical arrays array index, `i`, is mapped to bit position, `pos=i-1`, and `.true.` diff --git a/src/stdlib_bitsets.fypp b/src/stdlib_bitsets.fypp index 0605f2792..5c9ffc0e5 100644 --- a/src/stdlib_bitsets.fypp +++ b/src/stdlib_bitsets.fypp @@ -1166,13 +1166,6 @@ module stdlib_bitsets !! end program example_assignment !!``` - pure module subroutine assign_large( set1, set2 ) -!! Version: experimental -!! -!! Used to define assignment for `bitset_large`. - type(bitset_large), intent(out) :: set1 - type(bitset_large), intent(in) :: set2 - end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) @@ -1510,13 +1503,6 @@ module stdlib_bitsets interface assignment(=) - pure module subroutine assign_64( set1, set2 ) -!! Version: experimental -!! -!! Used to define assignment for `bitset_64`. - type(bitset_64), intent(out) :: set1 - type(bitset_64), intent(in) :: set2 - end subroutine assign_64 #:for k1 in INT_KINDS module subroutine assign_log${k1}$_64( self, logical_vector ) diff --git a/src/stdlib_bitsets_64.fypp b/src/stdlib_bitsets_64.fypp index 82ad1397c..f4b25c9b9 100644 --- a/src/stdlib_bitsets_64.fypp +++ b/src/stdlib_bitsets_64.fypp @@ -72,15 +72,6 @@ contains end function any_64 - pure module subroutine assign_64( set1, set2 ) -! Used to define assignment for bitset_64 - type(bitset_64), intent(out) :: set1 - type(bitset_64), intent(in) :: set2 - - set1 % num_bits = set2 % num_bits - set1 % block = set2 % block - - end subroutine assign_64 #:for k1 in INT_KINDS diff --git a/src/stdlib_bitsets_large.fypp b/src/stdlib_bitsets_large.fypp index 324f19741..fef726525 100644 --- a/src/stdlib_bitsets_large.fypp +++ b/src/stdlib_bitsets_large.fypp @@ -89,16 +89,6 @@ contains end function any_large - pure module subroutine assign_large( set1, set2 ) -! Used to define assignment for bitset_large - type(bitset_large), intent(out) :: set1 - type(bitset_large), intent(in) :: set2 - - set1 % num_bits = set2 % num_bits - allocate( set1 % blocks( size( set2 % blocks, kind=bits_kind ) ) ) - set1 % blocks(:) = set2 % blocks(:) - - end subroutine assign_large #:for k1 in INT_KINDS pure module subroutine assign_log${k1}$_large( self, logical_vector ) diff --git a/test/bitsets/test_stdlib_bitset_large.f90 b/test/bitsets/test_stdlib_bitset_large.f90 index 7d268b86f..cd3204697 100644 --- a/test/bitsets/test_stdlib_bitset_large.f90 +++ b/test/bitsets/test_stdlib_bitset_large.f90 @@ -1,7 +1,15 @@ module test_stdlib_bitset_large use testdrive, only : new_unittest, unittest_type, error_type, check use :: stdlib_kinds, only : int8, int16, int32, int64 - use stdlib_bitsets + use stdlib_bitsets, only: bitset_large, bits_kind& + , bits & + , success & + , and, and_not, or, xor& + , extract& + , assignment(=)& + , operator(<), operator(<=)& + , operator(>), operator(>=)& + , operator(/=), operator(==) implicit none character(*), parameter :: & bitstring_0 = '000000000000000000000000000000000', & @@ -20,6 +28,7 @@ subroutine collect_stdlib_bitset_large(testsuite) new_unittest("string-operations", test_string_operations), & new_unittest("io", test_io), & new_unittest("initialization", test_initialization), & + new_unittest("bitset-assignment-array", test_assignment_array), & new_unittest("bitset-inquiry", test_bitset_inquiry), & new_unittest("bit-operations", test_bit_operations), & new_unittest("bitset-comparisons", test_bitset_comparisons), & @@ -550,6 +559,36 @@ subroutine test_initialization(error) end subroutine test_initialization + subroutine test_assignment_array(error) + !> Error handling + type(error_type), allocatable, intent(out) :: error + + logical(int8) :: log1(64) = .true. + + integer :: i + type(bitset_large) :: set1(0:4) + + do i = 0, size(set1) - 1 + set1(i) = log1 + enddo + + do i = 0, size(set1) - 1 + call check(error, set1(i) % bits(), 64, & + ' initialization with logical(int8) failed to set' // & + ' the right size in a bitset array.') + if (allocated(error)) return + enddo + + !Test added following issue https://github.com/fortran-lang/stdlib/issues/726 + set1(0) = set1(0) + + call check(error, set1(0) % bits(), 64, & + ' initialization from bitset_large failed to set' // & + ' the right size in a bitset array.') + if (allocated(error)) return + + end subroutine test_assignment_array + subroutine test_bitset_inquiry(error) !> Error handling type(error_type), allocatable, intent(out) :: error