Skip to content

Commit 608c152

Browse files
committed
Rust: Add a few tests for modeled flow for Option
1 parent 7644012 commit 608c152

File tree

1 file changed

+24
-0
lines changed
  • rust/ql/test/library-tests/dataflow/modeled

1 file changed

+24
-0
lines changed

rust/ql/test/library-tests/dataflow/modeled/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ mod my_clone {
5050
}
5151
}
5252

53+
mod flow_throug_option {
54+
use super::{source, sink};
55+
// Test the auto generated flow summaries for `Option`
56+
57+
fn zip_flow() {
58+
let a = Some(2);
59+
let b = Some(source(38));
60+
let z = a.zip(b);
61+
match z {
62+
Some((n, m)) => {
63+
sink(n);
64+
sink(m); // $ MISSING: hasValueFlow=38
65+
},
66+
None => ()
67+
}
68+
}
69+
70+
fn higher_order_flow() {
71+
let a = Some(0);
72+
let b = a.map_or(3, |n| n + source(63));
73+
sink(b); // $ MISSING: hasTaintFlow=63
74+
}
75+
}
76+
5377
fn main() {
5478
option_clone();
5579
result_clone();

0 commit comments

Comments
 (0)