diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting/tests.rs')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index 949bf59a0..b4d56a7a0 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -43,6 +43,12 @@ def_fn! { | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | macro_rules! noop { | ||
47 | ($expr:expr) => { | ||
48 | $expr | ||
49 | } | ||
50 | } | ||
51 | |||
46 | // comment | 52 | // comment |
47 | fn main() { | 53 | fn main() { |
48 | println!("Hello, {}!", 92); | 54 | println!("Hello, {}!", 92); |
@@ -61,6 +67,8 @@ fn main() { | |||
61 | // Do nothing | 67 | // Do nothing |
62 | } | 68 | } |
63 | 69 | ||
70 | noop!(noop!(1)); | ||
71 | |||
64 | let mut x = 42; | 72 | let mut x = 42; |
65 | let y = &mut x; | 73 | let y = &mut x; |
66 | let z = &y; | 74 | let z = &y; |
@@ -238,6 +246,10 @@ fn main() { | |||
238 | 246 | ||
239 | println!(r"Hello, {}!", "world"); | 247 | println!(r"Hello, {}!", "world"); |
240 | 248 | ||
249 | // escape sequences | ||
250 | println!("Hello\nWorld"); | ||
251 | println!("\u{48}\x65\x6C\x6C\x6F World"); | ||
252 | |||
241 | println!("{\x41}", A = 92); | 253 | println!("{\x41}", A = 92); |
242 | println!("{ничоси}", ничоси = 92); | 254 | println!("{ничоси}", ничоси = 92); |
243 | }"# | 255 | }"# |
@@ -279,7 +291,13 @@ fn main() { | |||
279 | fn test_highlight_doctest() { | 291 | fn test_highlight_doctest() { |
280 | check_highlighting( | 292 | check_highlighting( |
281 | r#" | 293 | r#" |
294 | struct Foo { | ||
295 | bar: bool, | ||
296 | } | ||
297 | |||
282 | impl Foo { | 298 | impl Foo { |
299 | pub const bar: bool = true; | ||
300 | |||
283 | /// Constructs a new `Foo`. | 301 | /// Constructs a new `Foo`. |
284 | /// | 302 | /// |
285 | /// # Examples | 303 | /// # Examples |
@@ -289,7 +307,7 @@ impl Foo { | |||
289 | /// let mut foo: Foo = Foo::new(); | 307 | /// let mut foo: Foo = Foo::new(); |
290 | /// ``` | 308 | /// ``` |
291 | pub const fn new() -> Foo { | 309 | pub const fn new() -> Foo { |
292 | Foo { } | 310 | Foo { bar: true } |
293 | } | 311 | } |
294 | 312 | ||
295 | /// `bar` method on `Foo`. | 313 | /// `bar` method on `Foo`. |
@@ -297,11 +315,15 @@ impl Foo { | |||
297 | /// # Examples | 315 | /// # Examples |
298 | /// | 316 | /// |
299 | /// ``` | 317 | /// ``` |
318 | /// use x::y; | ||
319 | /// | ||
300 | /// let foo = Foo::new(); | 320 | /// let foo = Foo::new(); |
301 | /// | 321 | /// |
302 | /// // calls bar on foo | 322 | /// // calls bar on foo |
303 | /// assert!(foo.bar()); | 323 | /// assert!(foo.bar()); |
304 | /// | 324 | /// |
325 | /// let bar = foo.bar || Foo::bar; | ||
326 | /// | ||
305 | /// /* multi-line | 327 | /// /* multi-line |
306 | /// comment */ | 328 | /// comment */ |
307 | /// | 329 | /// |
@@ -311,9 +333,13 @@ impl Foo { | |||
311 | /// | 333 | /// |
312 | /// ``` | 334 | /// ``` |
313 | /// | 335 | /// |
314 | /// ``` | 336 | /// ```rust,no_run |
315 | /// let foobar = Foo::new().bar(); | 337 | /// let foobar = Foo::new().bar(); |
316 | /// ``` | 338 | /// ``` |
339 | /// | ||
340 | /// ```sh | ||
341 | /// echo 1 | ||
342 | /// ``` | ||
317 | pub fn foo(&self) -> bool { | 343 | pub fn foo(&self) -> bool { |
318 | true | 344 | true |
319 | } | 345 | } |
@@ -322,7 +348,7 @@ impl Foo { | |||
322 | .trim(), | 348 | .trim(), |
323 | "crates/ra_ide/src/snapshots/highlight_doctest.html", | 349 | "crates/ra_ide/src/snapshots/highlight_doctest.html", |
324 | false, | 350 | false, |
325 | ) | 351 | ); |
326 | } | 352 | } |
327 | 353 | ||
328 | /// Highlights the code given by the `ra_fixture` argument, renders the | 354 | /// Highlights the code given by the `ra_fixture` argument, renders the |