diff options
| author | Jędrzej Boczar <yendreij@gmail.com> | 2021-04-22 20:53:30 +0200 |
|---|---|---|
| committer | Kiyan <yazdani.kiyan@protonmail.com> | 2021-04-23 21:21:38 +0200 |
| commit | 63a88c873f3643aad9208488765dc53618edd40e (patch) | |
| tree | fb233a54b0dae8a6af1a12dfecb9cd85cbdb4f64 /tests/indent/rust | |
| parent | ignore Lua indent test files when doing style-check (diff) | |
| download | nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.gz nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.bz2 nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.lz nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.xz nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.tar.zst nvim-treesitter-63a88c873f3643aad9208488765dc53618edd40e.zip | |
move all tests to top-level tests/ directory
Diffstat (limited to 'tests/indent/rust')
| -rw-r--r-- | tests/indent/rust/array.rs | 11 | ||||
| -rw-r--r-- | tests/indent/rust/comment.rs | 7 | ||||
| -rw-r--r-- | tests/indent/rust/cond.rs | 17 | ||||
| -rw-r--r-- | tests/indent/rust/enum.rs | 11 | ||||
| -rw-r--r-- | tests/indent/rust/func.rs | 10 | ||||
| -rw-r--r-- | tests/indent/rust/impl.rs | 7 | ||||
| -rw-r--r-- | tests/indent/rust/loop.rs | 19 | ||||
| -rw-r--r-- | tests/indent/rust/macro.rs | 13 | ||||
| -rw-r--r-- | tests/indent/rust/match.rs | 11 | ||||
| -rw-r--r-- | tests/indent/rust/mod.rs | 8 | ||||
| -rw-r--r-- | tests/indent/rust/string.rs | 12 | ||||
| -rw-r--r-- | tests/indent/rust/struct.rs | 4 | ||||
| -rw-r--r-- | tests/indent/rust/trait.rs | 11 | ||||
| -rw-r--r-- | tests/indent/rust/where.rs | 21 |
14 files changed, 162 insertions, 0 deletions
diff --git a/tests/indent/rust/array.rs b/tests/indent/rust/array.rs new file mode 100644 index 000000000..68344e0ee --- /dev/null +++ b/tests/indent/rust/array.rs @@ -0,0 +1,11 @@ +const X: [i32; 2] = [ + 1, + 2, +]; + +fn foo() { + let _x = [ + 1, + 2, + ]; +} diff --git a/tests/indent/rust/comment.rs b/tests/indent/rust/comment.rs new file mode 100644 index 000000000..334793dfa --- /dev/null +++ b/tests/indent/rust/comment.rs @@ -0,0 +1,7 @@ +/// Function foo +/// +/// Description of +/// function foo. +fn foo(x: i32, y: i32) -> i32 { + x + y +} diff --git a/tests/indent/rust/cond.rs b/tests/indent/rust/cond.rs new file mode 100644 index 000000000..eb96a48f7 --- /dev/null +++ b/tests/indent/rust/cond.rs @@ -0,0 +1,17 @@ +fn foo(mut x: i32) -> i32 { + if x > 10 { + return 10; + } else if x == 10 { + return 9; + } else { + x += 10; + } + + if x < 0 { + if x == -1 { + return 0; + } + } + + 0 +} diff --git a/tests/indent/rust/enum.rs b/tests/indent/rust/enum.rs new file mode 100644 index 000000000..996f07d21 --- /dev/null +++ b/tests/indent/rust/enum.rs @@ -0,0 +1,11 @@ +enum Foo { + X, + Y( + char, + char, + ), + Z { + x: u32, + y: u32, + }, +} diff --git a/tests/indent/rust/func.rs b/tests/indent/rust/func.rs new file mode 100644 index 000000000..4c9d40b26 --- /dev/null +++ b/tests/indent/rust/func.rs @@ -0,0 +1,10 @@ +fn foo() -> i32 { + 1 +} + +fn foo( + x: i32, + y: i32 +) -> i32 { + x + y +} diff --git a/tests/indent/rust/impl.rs b/tests/indent/rust/impl.rs new file mode 100644 index 000000000..2525c2e5b --- /dev/null +++ b/tests/indent/rust/impl.rs @@ -0,0 +1,7 @@ +struct Foo; + +impl Foo { + fn foo() -> i32 { + 1 + } +} diff --git a/tests/indent/rust/loop.rs b/tests/indent/rust/loop.rs new file mode 100644 index 000000000..eb845bc0f --- /dev/null +++ b/tests/indent/rust/loop.rs @@ -0,0 +1,19 @@ +fn foo(mut x: i32) { + while x > 0 { + x -= 1; + } + + for i in 0..3 { + x += 1; + } + + loop { + x += 1; + + if x < 100 { + continue; + } + + break; + } +} diff --git a/tests/indent/rust/macro.rs b/tests/indent/rust/macro.rs new file mode 100644 index 000000000..608e157fc --- /dev/null +++ b/tests/indent/rust/macro.rs @@ -0,0 +1,13 @@ +macro_rules! foo { + ($a:ident, $b:ident, $c:ident) => { + struct $a; + struct $b; + }, + ($a:ident) => { + struct $a; + }, +} + +foo! { + A +} diff --git a/tests/indent/rust/match.rs b/tests/indent/rust/match.rs new file mode 100644 index 000000000..438ba6d5f --- /dev/null +++ b/tests/indent/rust/match.rs @@ -0,0 +1,11 @@ +fn foo(x: i32) -> i32 { + match x { + 0 => 1, + 1 => { + 2 + }, + 2 | 3 => { + 4 + } + } +} diff --git a/tests/indent/rust/mod.rs b/tests/indent/rust/mod.rs new file mode 100644 index 000000000..cc7f2c8e6 --- /dev/null +++ b/tests/indent/rust/mod.rs @@ -0,0 +1,8 @@ +mod foo { + const X: i32 = 1; + + mod bar { + + const Y: i32 = 1; + } +} diff --git a/tests/indent/rust/string.rs b/tests/indent/rust/string.rs new file mode 100644 index 000000000..4d60663dd --- /dev/null +++ b/tests/indent/rust/string.rs @@ -0,0 +1,12 @@ +fn foo() { + let a = "hello +world"; + + let b = "hello\ + world"; + + let c = r#" + hello + world + "#; +} diff --git a/tests/indent/rust/struct.rs b/tests/indent/rust/struct.rs new file mode 100644 index 000000000..f3828977f --- /dev/null +++ b/tests/indent/rust/struct.rs @@ -0,0 +1,4 @@ +struct Foo { + x: u32, + y: u32, +} diff --git a/tests/indent/rust/trait.rs b/tests/indent/rust/trait.rs new file mode 100644 index 000000000..fb5fc7ea8 --- /dev/null +++ b/tests/indent/rust/trait.rs @@ -0,0 +1,11 @@ +struct Foo; + +trait Bar { + fn bar(); +} + +impl Bar for Foo { + fn bar() { + + } +} diff --git a/tests/indent/rust/where.rs b/tests/indent/rust/where.rs new file mode 100644 index 000000000..08c1b196d --- /dev/null +++ b/tests/indent/rust/where.rs @@ -0,0 +1,21 @@ +fn foo<T>(t: T) -> i32 +where + T: Debug, +{ + 1 +} + +fn foo<T>(t: T) -> i32 where + T: Debug, +{ + 1 +} + +struct Foo<T>(T); + +impl<T> Write for Foo<T> +where + T: Debug, +{ + +} |
