mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Fix DNF construction, add proptest
This commit is contained in:
parent
20f3792d10
commit
e6255356d2
5 changed files with 99 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
use arbitrary::{Arbitrary, Unstructured};
|
||||
use expect_test::{expect, Expect};
|
||||
use mbe::syntax_node_to_token_tree;
|
||||
use syntax::{ast, AstNode};
|
||||
|
@ -130,6 +131,18 @@ fn nested() {
|
|||
check_dnf("#![cfg(not(all(all(a, b))))]", expect![[r#"#![cfg(any(not(a), not(b)))]"#]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression() {
|
||||
check_dnf("#![cfg(all(not(not(any(any(any()))))))]", expect![[r##"#![cfg(any())]"##]]);
|
||||
check_dnf("#![cfg(all(any(all(any()))))]", expect![[r##"#![cfg(any())]"##]]);
|
||||
check_dnf("#![cfg(all(all(any())))]", expect![[r##"#![cfg(any())]"##]]);
|
||||
|
||||
check_dnf("#![cfg(all(all(any(), x)))]", expect![[r##"#![cfg(any())]"##]]);
|
||||
check_dnf("#![cfg(all(all(any()), x))]", expect![[r##"#![cfg(any())]"##]]);
|
||||
check_dnf("#![cfg(all(all(any(x))))]", expect![[r##"#![cfg(x)]"##]]);
|
||||
check_dnf("#![cfg(all(all(any(x), x)))]", expect![[r##"#![cfg(all(x, x))]"##]]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hints() {
|
||||
let mut opts = CfgOptions::default();
|
||||
|
@ -191,3 +204,21 @@ fn why_inactive() {
|
|||
expect![["test and test2 are enabled and a is disabled"]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn proptest() {
|
||||
const REPEATS: usize = 512;
|
||||
|
||||
let mut rng = oorandom::Rand32::new(123456789);
|
||||
let mut buf = Vec::new();
|
||||
for _ in 0..REPEATS {
|
||||
buf.clear();
|
||||
while buf.len() < 512 {
|
||||
buf.extend(rng.rand_u32().to_ne_bytes());
|
||||
}
|
||||
|
||||
let mut u = Unstructured::new(&buf);
|
||||
let cfg = CfgExpr::arbitrary(&mut u).unwrap();
|
||||
DnfExpr::new(cfg);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue