Skip to content

Commit

Permalink
Add test and prints
Browse files Browse the repository at this point in the history
  • Loading branch information
minhqdao committed Feb 27, 2024
1 parent 106afb0 commit eb54a69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/version_f.f90
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ subroutine try_satisfy(this, string, is_satisfied, error)
type(version_range_t) :: version_range
integer :: i

str = adjustl(trim(string))
str = trim(adjustl(string))

if (len(str) == 0) then
error = error_t('Do not compare empty expressions.'); return
Expand All @@ -820,6 +820,13 @@ subroutine try_satisfy(this, string, is_satisfied, error)
if (allocated(error)) return

do i = 1, size(version_range%comp_sets)
block
integer :: j
do j = 1, size(version_range%comp_sets(i)%comps)
print *, version_range%comp_sets(i)%comps(j)%op
print *, version_range%comp_sets(i)%comps(j)%version%to_string()
end do
end block
call this%satisfies_comp_set(version_range%comp_sets(i), is_satisfied, error)
if (is_satisfied .or. allocated(error)) return
end do
Expand Down Expand Up @@ -936,7 +943,6 @@ subroutine parse_comp_set(this, string, error)
else
call comp%parse_comp_and_crop_str('', str, error)
end if

if (allocated(error)) return
this%comps = [this%comps, comp]
if (str == '') return
Expand Down
13 changes: 13 additions & 0 deletions test/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,19 @@ program test
if (comp_set%comps(3)%version /= version_t(2)) call fail('parse-comp-set-7: Version does not match.')
if (allocated(e)) call fail('parse-comp-set-7 should not fail.')

call comp_set%parse(' > 1.0.1 < 2.1.0 ', e)
print *, size(comp_set%comps)
print *, comp_set%comps(1)%op
print *, comp_set%comps(1)%version%to_string()
print *, comp_set%comps(2)%op
print *, comp_set%comps(2)%version%to_string()
if (size(comp_set%comps) /= 2) call fail("parse-comp-set-8: Wrong number of comparators.")
if (comp_set%comps(1)%op /= '>') call fail("parse-comp-set-8: Wrong operator parsed.")
if (comp_set%comps(1)%version /= version_t(1, 0, 1)) call fail('parse-comp-set-8: Version does not match.')
if (comp_set%comps(2)%op /= '<') call fail("parse-comp-set-8: Wrong operator parsed.")
if (comp_set%comps(2)%version /= version_t(2, 1, 0)) call fail('parse-comp-set-8: Version does not match.')
if (allocated(e)) call fail('parse-comp-set-8 should not fail.')

!##############################parse_version_range#############################!

call range%parse('', e)
Expand Down

0 comments on commit eb54a69

Please sign in to comment.