Skip to main content

Crate proptest_semver

Crate proptest_semver 

Source
Expand description

SPDX-License-Identifier: Apache-2.0 Copyright 2025 canardleteer

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

This crate generally provides out of the box proptest implementations for doing Property Testing of Semantic Version values with the semver crate.

The Regex from the spec is available here: https://semver.org/, and where most of these come from.

Enums§

ComparatorOp
ComparatorOp is just a re-implementation of semver::Op.
ComparatorVec
ComparatorVec captures the odd case that your semver::VersionReq, can basically only be one of two things.
FullComparator
Describes various types of semver::Comparator as String.

Constants§

ALWAYS_BUILD_METADATA_REGEX
Regex to build a Build Metadata string, always, without the prefix +.
ALWAYS_PRERELEASE_REGEX
Regex to build a Pre-Release string, always, without the -.
ANY_MAJOR_MINOR_PATH_COMPONENT
Regex for any single Major, Minor, Patch component.
MAJOR_MINOR_PATCH_REGEX
Regex for the “Major.Minor.Patch” component of SemVer.
MAX_COMPARATORS_IN_VERSION_REQ_STRING
Describes the a hard limit set in semver::VersionReq (32). This limit isn’t exposed, so we re-encode it here, and then we test that it’s the right version.
SEMVER_REGEX
Regex for Semantic Version 2.0.0, directly from the spec, with 2 changes:
SOMETIMES_BUILD_METADATA_REGEX
Regex to build a Build Metadata string, sometimes, with the prefix +.
SOMETIMES_PRERELEASE_REGEX
Regex to build a Pre-Release string, sometimes, with the prefix -.

Functions§

arb_build_metadata_string
Arbitrary Build Metadata String (no + prefix)
arb_comparator_list
Provides a valid Vec<semver::Comparator> that can be fed to [semver:VersionReq::parse] after being run through .join(',')
arb_comparator_string
Creates a String that can be parsed as a valid semver::Comparator when building a semver::VersionReq.
arb_full_comparator
Provides some kind of semver::Comparator “thing”, sidestepping the FullComparator::Wildcard case.
arb_full_comparator_vec
Provides a weighted list of ComparatorVec, for use in arb_version_req, but you may want to use it for your own means.
arb_option_build_metadata_string
Arbitrary Optional Build Metadata String (no + prefix)
arb_option_pre_release_string
Arbitrary Optional Pre-Release String (no - prefix)
arb_option_semver_build_metadata
arb_option_semver_prerelease
arb_optional_semver_version_req
arb_optional_version_req
Creates an Option<semver::VersionReq> of some maximum number of Comparators.
arb_pre_release_string
Arbitrary Pre-Release String (no - prefix)
arb_semver
Arbitrary Semantic Versioning 2.0.0 String.
arb_semver_build_metadata
arb_semver_comparator
arb_semver_op
Implement a generic strategy around semver:Op.
arb_semver_prerelease
arb_semver_version
Creates a valid semver::Version via the struct itself.
arb_semver_version_req
arb_semver_version_weighted
Creates a valid semver::Version via the struct itself.
arb_vec_comparator_string
Creates a Vec<String> that can be parsed as a valid semver::Comparator’s when building a semver::VersionReq.
arb_vec_semver_comparator
arb_vec_semver_versions
Creates a list of semver::Version, with some specified length.
arb_vec_versions
Creates a list of semver::Version, with some specified length.
arb_version
Creates a valid semver::Version via String.
arb_version_req
Creates a semver::VersionReq of some maximum number of Comparators.
arb_version_weighted
Creates a semver::Version from a String based on explicit weighting of Pre-Release & Build Metadata probability.