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

Remove dependency on quickcheck_macros #245

Merged
merged 3 commits into from
Sep 12, 2023
Merged
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
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ path = []
[dev-dependencies]
# Property testing for interner getters and setters.
quickcheck = { version = "1.0.3", default-features = false }
quickcheck_macros = "1.0.0"

# Check that crate versions are properly updated in documentation and code when
# bumping the version.
[dev-dependencies.version-sync]
version = "0.9.3"
default-features = false
features = ["markdown_deps_updated", "html_root_url_updated"]

[package.metadata.docs.rs]
# This sets the default target to `x86_64-unknown-linux-gnu` and only builds
Expand Down
68 changes: 32 additions & 36 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ where
#[cfg(test)]
#[allow(clippy::needless_pass_by_value)]
mod tests {
use quickcheck_macros::quickcheck;
use quickcheck::quickcheck;

use super::SymbolTable;

Expand Down Expand Up @@ -960,45 +960,41 @@ mod tests {
assert_eq!(sym, table.intern(&b"abc"[..]).unwrap());
}

#[quickcheck]
fn intern_twice_symbol_equality(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes.clone()).unwrap();
let sym_again = table.intern(bytes).unwrap();
sym == sym_again
}
quickcheck! {
fn intern_twice_symbol_equality(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes.clone()).unwrap();
let sym_again = table.intern(bytes).unwrap();
sym == sym_again
}

#[quickcheck]
fn intern_get_roundtrip(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes.clone()).unwrap();
let retrieved_bytes = table.get(sym).unwrap();
bytes == retrieved_bytes
}
fn intern_get_roundtrip(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes.clone()).unwrap();
let retrieved_bytes = table.get(sym).unwrap();
bytes == retrieved_bytes
}

#[quickcheck]
fn table_contains_sym(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes).unwrap();
table.contains(sym)
}
fn table_contains_sym(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(bytes).unwrap();
table.contains(sym)
}

#[quickcheck]
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}

#[quickcheck]
fn empty_table_does_not_report_any_interned_byte_strings(bytes: Vec<u8>) -> bool {
let table = SymbolTable::new();
!table.is_interned(bytes.as_slice())
}
fn empty_table_does_not_report_any_interned_byte_strings(bytes: Vec<u8>) -> bool {
let table = SymbolTable::new();
!table.is_interned(bytes.as_slice())
}

#[quickcheck]
fn table_reports_interned_byte_strings_as_interned(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
table.intern(bytes.clone()).unwrap();
table.is_interned(bytes.as_slice())
fn table_reports_interned_byte_strings_as_interned(bytes: Vec<u8>) -> bool {
let mut table = SymbolTable::new();
table.intern(bytes.clone()).unwrap();
table.is_interned(bytes.as_slice())
}
}
}
68 changes: 32 additions & 36 deletions src/cstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ where
mod tests {
use std::ffi::{CStr, CString};

use quickcheck_macros::quickcheck;
use quickcheck::quickcheck;

use super::SymbolTable;

Expand Down Expand Up @@ -1012,45 +1012,41 @@ mod tests {
);
}

#[quickcheck]
fn intern_twice_symbol_equality(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring.clone()).unwrap();
let sym_again = table.intern(cstring).unwrap();
sym == sym_again
}
quickcheck! {
fn intern_twice_symbol_equality(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring.clone()).unwrap();
let sym_again = table.intern(cstring).unwrap();
sym == sym_again
}

#[quickcheck]
fn intern_get_roundtrip(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring.clone()).unwrap();
let retrieved_c_string = table.get(sym).unwrap();
&*cstring == retrieved_c_string
}
fn intern_get_roundtrip(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring.clone()).unwrap();
let retrieved_c_string = table.get(sym).unwrap();
&*cstring == retrieved_c_string
}

#[quickcheck]
fn table_contains_sym(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring).unwrap();
table.contains(sym)
}
fn table_contains_sym(cstring: CString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(cstring).unwrap();
table.contains(sym)
}

#[quickcheck]
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}

#[quickcheck]
fn empty_table_does_not_report_any_interned_c_strings(cstring: CString) -> bool {
let table = SymbolTable::new();
!table.is_interned(cstring.as_c_str())
}
fn empty_table_does_not_report_any_interned_c_strings(cstring: CString) -> bool {
let table = SymbolTable::new();
!table.is_interned(cstring.as_c_str())
}

#[quickcheck]
fn table_reports_interned_c_strings_as_interned(cstring: CString) -> bool {
let mut table = SymbolTable::new();
table.intern(cstring.clone()).unwrap();
table.is_interned(cstring.as_c_str())
fn table_reports_interned_c_strings_as_interned(cstring: CString) -> bool {
let mut table = SymbolTable::new();
table.intern(cstring.clone()).unwrap();
table.is_interned(cstring.as_c_str())
}
}
}
68 changes: 32 additions & 36 deletions src/osstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ where
mod tests {
use std::ffi::{OsStr, OsString};

use quickcheck_macros::quickcheck;
use quickcheck::quickcheck;

use super::SymbolTable;

Expand Down Expand Up @@ -990,45 +990,41 @@ mod tests {
assert_eq!(sym, table.intern(OsStr::new("abc")).unwrap());
}

#[quickcheck]
fn intern_twice_symbol_equality(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string.clone()).unwrap();
let sym_again = table.intern(os_string).unwrap();
sym == sym_again
}
quickcheck! {
fn intern_twice_symbol_equality(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string.clone()).unwrap();
let sym_again = table.intern(os_string).unwrap();
sym == sym_again
}

#[quickcheck]
fn intern_get_roundtrip(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string.clone()).unwrap();
let retrieved_os_string = table.get(sym).unwrap();
&*os_string == retrieved_os_string
}
fn intern_get_roundtrip(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string.clone()).unwrap();
let retrieved_os_string = table.get(sym).unwrap();
&*os_string == retrieved_os_string
}

#[quickcheck]
fn table_contains_sym(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string).unwrap();
table.contains(sym)
}
fn table_contains_sym(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(os_string).unwrap();
table.contains(sym)
}

#[quickcheck]
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}

#[quickcheck]
fn empty_table_does_not_report_any_interned_os_strings(os_string: OsString) -> bool {
let table = SymbolTable::new();
!table.is_interned(os_string.as_os_str())
}
fn empty_table_does_not_report_any_interned_os_strings(os_string: OsString) -> bool {
let table = SymbolTable::new();
!table.is_interned(os_string.as_os_str())
}

#[quickcheck]
fn table_reports_interned_os_strs_as_interned(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
table.intern(os_string.clone()).unwrap();
table.is_interned(os_string.as_os_str())
fn table_reports_interned_os_strs_as_interned(os_string: OsString) -> bool {
let mut table = SymbolTable::new();
table.intern(os_string.clone()).unwrap();
table.is_interned(os_string.as_os_str())
}
}
}
68 changes: 32 additions & 36 deletions src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ where
mod tests {
use std::path::{Path, PathBuf};

use quickcheck_macros::quickcheck;
use quickcheck::quickcheck;

use super::SymbolTable;

Expand Down Expand Up @@ -990,45 +990,41 @@ mod tests {
assert_eq!(sym, table.intern(Path::new("abc")).unwrap());
}

#[quickcheck]
fn intern_twice_symbol_equality(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path.clone()).unwrap();
let sym_again = table.intern(path).unwrap();
sym == sym_again
}
quickcheck! {
fn intern_twice_symbol_equality(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path.clone()).unwrap();
let sym_again = table.intern(path).unwrap();
sym == sym_again
}

#[quickcheck]
fn intern_get_roundtrip(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path.clone()).unwrap();
let retrieved_path = table.get(sym).unwrap();
&*path == retrieved_path
}
fn intern_get_roundtrip(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path.clone()).unwrap();
let retrieved_path = table.get(sym).unwrap();
&*path == retrieved_path
}

#[quickcheck]
fn table_contains_sym(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path).unwrap();
table.contains(sym)
}
fn table_contains_sym(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
let sym = table.intern(path).unwrap();
table.contains(sym)
}

#[quickcheck]
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}
fn table_does_not_contain_missing_symbol_ids(sym: u32) -> bool {
let table = SymbolTable::new();
!table.contains(sym.into())
}

#[quickcheck]
fn empty_table_does_not_report_any_interned_paths(path: PathBuf) -> bool {
let table = SymbolTable::new();
!table.is_interned(path.as_path())
}
fn empty_table_does_not_report_any_interned_paths(path: PathBuf) -> bool {
let table = SymbolTable::new();
!table.is_interned(path.as_path())
}

#[quickcheck]
fn table_reports_interned_paths_as_interned(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
table.intern(path.clone()).unwrap();
table.is_interned(path.as_path())
fn table_reports_interned_paths_as_interned(path: PathBuf) -> bool {
let mut table = SymbolTable::new();
table.intern(path.clone()).unwrap();
table.is_interned(path.as_path())
}
}
}
Loading