Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: proptest Type validation and substitution #1744

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci-rs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Build with no features
run: cargo test --verbose --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --no-default-features
run: RUST_MIN_STACK=10485760 cargo test --verbose --no-default-features

# Run tests on Rust stable
tests-stable-all-features:
Expand All @@ -140,7 +140,7 @@ jobs:
- name: Build with all features
run: cargo test --verbose --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --all-features
run: RUST_MIN_STACK=10485760 cargo test --verbose --all-features
- name: Build HUGR binary
run: cargo build -p hugr-cli
- name: Upload the binary to the artifacts
Expand Down Expand Up @@ -175,11 +175,11 @@ jobs:
- name: Build with no features
run: cargo test --verbose --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --no-default-features
run: RUST_MIN_STACK=10485760 cargo test --verbose --no-default-features
- name: Build with all features
run: cargo test --verbose --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --all-features
run: RUST_MIN_STACK=10485760 cargo test --verbose --all-features

# Ensure that serialized extensions match rust implementation
std-extensions:
Expand Down Expand Up @@ -277,7 +277,7 @@ jobs:
- name: Build
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }} --no-run
- name: Tests with no features
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }}
run: cargo test -p hugr-llvm --verbose --features llvm${{ matrix.llvm-version[1] }} --exclude test_type_substitution

# This is a meta job to mark successful completion of the required checks,
# even if they are skipped due to no changes in the relevant files.
Expand Down
8 changes: 6 additions & 2 deletions hugr-core/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,14 +878,18 @@ impl ExtensionSet {
self.0.iter()
}

/// Iterate over the indices of all contained type variables (of kind [TypeParam::Extensions])
pub fn typevars(&self) -> impl Iterator<Item = usize> + '_ {
self.0.iter().filter_map(as_typevar)
}

/// True if this set contains no [ExtensionId]s
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}

pub(crate) fn validate(&self, params: &[TypeParam]) -> Result<(), SignatureError> {
self.iter()
.filter_map(as_typevar)
self.typevars()
.try_for_each(|var_idx| check_typevar_decl(params, var_idx, &TypeParam::Extensions))
}

Expand Down
Loading
Loading