Skip to content

Commit 6515af3

Browse files
committed
Add support for proptests
1 parent 65f9f8f commit 6515af3

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ builds/
1717
*venv*/
1818
.python-version
1919
*.ipynb
20+
21+
proptest-regressions

Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ siphasher = { version = "0.3.10", default-features = false }
3636
# BENCH: oorandom = { version = "11.1.3" }
3737
# BENCH: lazy_static = { version = "1" }
3838

39+
# Only required for property testing - incompatible with older versions of rust
40+
# PROPERTY-TESTS: proptest = "1"
41+
3942
[features]
4043
default = ["std"]
4144
string-only = []

scripts/bigdecimal-property-tests

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
#
3+
# Run commands with property-tests enabled for bigdecimal crate
4+
#
5+
# Tests are defined in src/lib.tests.property-test.rs
6+
#
7+
8+
# enable property-test dependencies in Cargo
9+
sed -i.bak -e 's|# PROPERTY-TESTS: ||' Cargo.toml
10+
11+
# include the property-test file in lib.rs
12+
sed -i.bak -e 's|// ::PROPERTY-TESTS:: ||' src/lib.rs
13+
14+
# Run commands
15+
"$@"
16+
17+
# Restore Cargo.toml with backup
18+
mv Cargo.toml.bak Cargo.toml
19+
mv src/lib.rs.bak src/lib.rs

src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,7 @@ impl One for BigDecimal {
11161116
}
11171117
}
11181118

1119+
11191120
impl Add<BigDecimal> for BigDecimal {
11201121
type Output = BigDecimal;
11211122

@@ -3254,3 +3255,9 @@ mod test_with_scale_round {
32543255

32553256
include!("lib.tests.with_scale_round.rs");
32563257
}
3258+
3259+
// enable these tests with scripts/bigdecimal-property-tests
3260+
// ::PROPERTY-TESTS:: #[cfg(test)] #[macro_use] extern crate proptest;
3261+
// ::PROPERTY-TESTS:: #[cfg(test)] mod property_tests {
3262+
// ::PROPERTY-TESTS:: use super::*; use paste::paste;
3263+
// ::PROPERTY-TESTS:: include!("lib.tests.property-tests.rs"); }

src/lib.tests.property-tests.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)