@@ -1810,22 +1810,30 @@ fn buff_chunk_strategy() -> impl Strategy<Value = Vec<u8>> {
18101810 prop:: collection:: vec ( any :: < u8 > ( ) , 0 ..=32 )
18111811}
18121812
1813+ /// Printable-ASCII bytes (`0x20..=0x7E`) excluding `"` and `\`, which need
1814+ /// escaping in a Clarity string literal.
1815+ ///
1816+ /// Callers sample from this set directly rather than `prop_filter`-ing the full
1817+ /// range: a per-byte filter rejects `"`/`\` ~2% of the time, and with many
1818+ /// bytes per case the cumulative local rejects blow past proptest's cap under
1819+ /// high case counts (aborting the run).
1820+ fn allowed_ascii_bytes ( ) -> Vec < u8 > {
1821+ ( 0x20u8 ..=0x7Eu8 )
1822+ . filter ( |b| * b != b'"' && * b != b'\\' )
1823+ . collect ( )
1824+ }
1825+
18131826/// Random printable-ASCII bytes (no `"` or `\`) for a string-ascii arg.
18141827fn ascii_chunk_strategy ( ) -> impl Strategy < Value = Vec < u8 > > {
1815- prop:: collection:: vec (
1816- ( 0x20u8 ..=0x7Eu8 ) . prop_filter ( "not quote or backslash" , |b| * b != b'"' && * b != b'\\' ) ,
1817- 0 ..=32 ,
1818- )
1828+ prop:: collection:: vec ( prop:: sample:: select ( allowed_ascii_bytes ( ) ) , 0 ..=32 )
18191829}
18201830
18211831/// Random Unicode chars (printable ASCII + BMP + emoji) for a string-utf8 arg.
18221832fn utf8_chunk_strategy ( ) -> impl Strategy < Value = Vec < char > > {
18231833 prop:: collection:: vec (
18241834 prop_oneof ! [
18251835 // Printable ASCII excluding `"` and `\`
1826- ( 0x20u8 ..=0x7Eu8 )
1827- . prop_filter( "not quote or backslash" , |b| * b != b'"' && * b != b'\\' )
1828- . prop_map( |b| b as char ) ,
1836+ prop:: sample:: select( allowed_ascii_bytes( ) ) . prop_map( |b| b as char ) ,
18291837 // BMP non-control non-surrogate codepoints
18301838 ( 0xA1u32 ..=0xD7FF ) . prop_filter_map( "valid bmp char" , |n| {
18311839 char :: from_u32( n) . filter( |c| !c. is_control( ) )
0 commit comments