Jira (PUP-11240) SemVerRange(min, max, false) is not exclusive

4 views
Skip to first unread message

Josh Cooper (Jira)

unread,
Sep 9, 2021, 12:23:02 PM9/9/21
to puppe...@googlegroups.com
Josh Cooper created an issue
 
Puppet / Bug PUP-11240
SemVerRange(min, max, false) is not exclusive
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2021/09/09 9:22 AM
Priority: Normal Normal
Reporter: Josh Cooper

Puppet Version: 7.10

The SemVerRange.new provides different signatures for defining an inclusive or exclusive semantic version range. The method that accepts min and max is inclusive by default, but it accepts a third parameter to make it exclusive. However, it doesn't work as specified (DOCUMENT-956)

Desired Behavior:

The following should print false:

notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0"), false))

Actual Behavior:

It prints true, just like if the parameter was omitted:

$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0"), false))'
Notice: Scope(Class[main]): true
$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0")))'       
Notice: Scope(Class[main]): true

A workaround is to use the signature that takes a non-empty string:

$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(">= 1.2.3 < 2.0.0"))' 
Notice: Scope(Class[main]): false

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Sep 10, 2021, 12:55:03 AM9/10/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
*Puppet Version:* 7.10

The {{SemVerRange.new}} provides different method signatures for defining an inclusive or exclusive semantic version range. The method signature that accepts {{min}} and {{max}} is inclusive by default, but it accepts a third parameter to make it exclusive. However, it  doesn't work as specified (DOCUMENT-956)

*Desired Behavior:*


The following should print {{false}}:

{code:puppet}

notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0"), false))
{code}

*Actual Behavior:*

It prints {{true}}, just like if the parameter was omitted:

{noformat}

$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0"), false))'
Notice: Scope(Class[main]): true
$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(SemVer("1.2.3"), SemVer("2.0.0")))'       
Notice: Scope(Class[main]): true
{noformat}


A workaround is to use the signature that takes a non-empty string:

{noformat}

$ bx puppet apply -e 'notice(SemVer("2.0.0") =~ SemVerRange(">= 1.2.3 < 2.0.0"))'
Notice: Scope(Class[main]): false
{noformat}
Reply all
Reply to author
Forward
0 new messages