diff options
author | Bernardo <[email protected]> | 2018-12-21 17:51:31 +0000 |
---|---|---|
committer | Bernardo <[email protected]> | 2018-12-25 19:03:14 +0000 |
commit | d6312085a1ac97030fa768366585b9cfb6c955cd (patch) | |
tree | bdd36cd3efd76fc3a1561847ed66ccece7b75303 /crates/ra_text_edit | |
parent | a005d2a614031a18c9a5bf6557789a41f1b25c31 (diff) |
remove slower impl, add benchmarks
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r-- | crates/ra_text_edit/src/test_utils.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crates/ra_text_edit/src/test_utils.rs b/crates/ra_text_edit/src/test_utils.rs index 4a0ebc08e..f150288f6 100644 --- a/crates/ra_text_edit/src/test_utils.rs +++ b/crates/ra_text_edit/src/test_utils.rs | |||
@@ -24,6 +24,10 @@ pub fn arb_offset(text: &str) -> BoxedStrategy<TextUnit> { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> { | 26 | pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> { |
27 | arb_edits_custom(&text, 0, 7) | ||
28 | } | ||
29 | |||
30 | pub fn arb_edits_custom(text: &str, min: usize, max: usize) -> BoxedStrategy<Vec<AtomTextEdit>> { | ||
27 | if text.is_empty() { | 31 | if text.is_empty() { |
28 | // only valid edits | 32 | // only valid edits |
29 | return Just(vec![]) | 33 | return Just(vec![]) |
@@ -37,9 +41,10 @@ pub fn arb_edits(text: &str) -> BoxedStrategy<Vec<AtomTextEdit>> { | |||
37 | } | 41 | } |
38 | 42 | ||
39 | let offsets = text_offsets(text); | 43 | let offsets = text_offsets(text); |
40 | let max_cuts = offsets.len().min(7); | 44 | let max_cuts = max.min(offsets.len()); |
45 | let min_cuts = min.min(offsets.len() - 1); | ||
41 | 46 | ||
42 | proptest::sample::subsequence(offsets, 0..max_cuts) | 47 | proptest::sample::subsequence(offsets, min_cuts..max_cuts) |
43 | .prop_flat_map(|cuts| { | 48 | .prop_flat_map(|cuts| { |
44 | let strategies: Vec<_> = cuts | 49 | let strategies: Vec<_> = cuts |
45 | .chunks(2) | 50 | .chunks(2) |