aboutsummaryrefslogtreecommitdiff
path: root/libeditor/tests/test.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-09 14:03:21 +0100
committerAleksey Kladov <[email protected]>2018-08-09 14:03:21 +0100
commit36bd28633baf6015b767e9e70d2d53185271db50 (patch)
tree8b660150cf128c0fdee4cd8734215a4116a520e4 /libeditor/tests/test.rs
parente847a1b7a6b53d5663aae7396ea0f65485f1283e (diff)
Extract runnables
Diffstat (limited to 'libeditor/tests/test.rs')
-rw-r--r--libeditor/tests/test.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/libeditor/tests/test.rs b/libeditor/tests/test.rs
index e1c8aee4b..ab8254d16 100644
--- a/libeditor/tests/test.rs
+++ b/libeditor/tests/test.rs
@@ -37,11 +37,33 @@ fn main() {}
37 ); 37 );
38} 38}
39 39
40#[test]
41fn test_runnables() {
42 let file = file(r#"
43fn main() {}
44
45#[test]
46fn test_foo() {}
47
48#[test]
49#[ignore]
50fn test_foo() {}
51"#);
52 let runnables = file.runnables();
53 dbg_eq(
54 &runnables,
55 r#"[Runnable { range: [1; 13), kind: Bin },
56 Runnable { range: [15; 39), kind: Test { name: "test_foo" } },
57 Runnable { range: [41; 75), kind: Test { name: "test_foo" } }]"#,
58 )
59}
60
40fn file(text: &str) -> File { 61fn file(text: &str) -> File {
41 File::new(text) 62 File::new(text)
42} 63}
43 64
44fn dbg_eq(actual: &impl fmt::Debug, expected: &str) { 65fn dbg_eq(actual: &impl fmt::Debug, expected: &str) {
66 let actual = format!("{:?}", actual);
45 let expected = expected.lines().map(|l| l.trim()).join(" "); 67 let expected = expected.lines().map(|l| l.trim()).join(" ");
46 assert_eq!(actual, expected); 68 assert_eq!(actual, expected);
47} 69}