diff options
| author | Federico Igne <git@federicoigne.com> | 2021-11-08 18:06:56 +0000 |
|---|---|---|
| committer | Federico Igne <git@federicoigne.com> | 2021-11-08 18:06:56 +0000 |
| commit | cd067503a7546eaee904a9b5c6ae30eb0175d376 (patch) | |
| tree | 2f625fc40314fa2abbe60da496b6f0993af8a779 /rust/macros/tests/invalid | |
| parent | b6d7705471f0a583f1d115472ddbc8c4f8a420a9 (diff) | |
| download | exercism-cd067503a7546eaee904a9b5c6ae30eb0175d376.tar.gz exercism-cd067503a7546eaee904a9b5c6ae30eb0175d376.zip | |
[rust] Macros
Diffstat (limited to 'rust/macros/tests/invalid')
| -rw-r--r-- | rust/macros/tests/invalid/Cargo.toml | 55 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/comma-sep.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/double-commas.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/leading-comma.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/missing-argument.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/no-comma.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/only-arrow.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/only-comma.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/single-argument.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/triple-arguments.rs | 7 | ||||
| -rw-r--r-- | rust/macros/tests/invalid/two-arrows.rs | 7 |
11 files changed, 125 insertions, 0 deletions
diff --git a/rust/macros/tests/invalid/Cargo.toml b/rust/macros/tests/invalid/Cargo.toml new file mode 100644 index 0000000..b096d99 --- /dev/null +++ b/rust/macros/tests/invalid/Cargo.toml | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | # | ||
| 2 | # This Cargo.toml file is used by the simple-trybuild module. | ||
| 3 | # When adding a new file, please name the [[bin]] name to match the file | ||
| 4 | # it is used to produce an error message | ||
| 5 | # | ||
| 6 | |||
| 7 | [package] | ||
| 8 | name = "macros-tests" | ||
| 9 | version = "0.0.0" | ||
| 10 | edition = "2018" | ||
| 11 | publish = false | ||
| 12 | |||
| 13 | [dependencies.macros] | ||
| 14 | path = "../../" | ||
| 15 | default-features = false | ||
| 16 | |||
| 17 | [[bin]] | ||
| 18 | name = "comma-sep-rs" | ||
| 19 | path = "comma-sep.rs" | ||
| 20 | |||
| 21 | [[bin]] | ||
| 22 | name = "double-commas-rs" | ||
| 23 | path = "double-commas.rs" | ||
| 24 | |||
| 25 | [[bin]] | ||
| 26 | name = "only-arrow-rs" | ||
| 27 | path = "only-arrow.rs" | ||
| 28 | |||
| 29 | [[bin]] | ||
| 30 | name = "only-comma-rs" | ||
| 31 | path = "only-comma.rs" | ||
| 32 | |||
| 33 | [[bin]] | ||
| 34 | name = "single-argument-rs" | ||
| 35 | path = "single-argument.rs" | ||
| 36 | |||
| 37 | [[bin]] | ||
| 38 | name = "triple-arguments-rs" | ||
| 39 | path = "triple-arguments.rs" | ||
| 40 | |||
| 41 | [[bin]] | ||
| 42 | name = "two-arrows-rs" | ||
| 43 | path = "two-arrows.rs" | ||
| 44 | |||
| 45 | [[bin]] | ||
| 46 | name = "leading-comma-rs" | ||
| 47 | path = "leading-comma.rs" | ||
| 48 | |||
| 49 | [[bin]] | ||
| 50 | name = "no-comma-rs" | ||
| 51 | path = "no-comma.rs" | ||
| 52 | |||
| 53 | [[bin]] | ||
| 54 | name = "missing-argument-rs" | ||
| 55 | path = "missing-argument.rs" | ||
diff --git a/rust/macros/tests/invalid/comma-sep.rs b/rust/macros/tests/invalid/comma-sep.rs new file mode 100644 index 0000000..c9b6f44 --- /dev/null +++ b/rust/macros/tests/invalid/comma-sep.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // using only commas is invalid | ||
| 6 | let _hm: HashMap<_, _> = hashmap!('a', 1); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/double-commas.rs b/rust/macros/tests/invalid/double-commas.rs new file mode 100644 index 0000000..d52dec6 --- /dev/null +++ b/rust/macros/tests/invalid/double-commas.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // a single trailing comma is okay, but two is not | ||
| 6 | let _hm: HashMap<_, _> = hashmap!('a' => 2, ,); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/leading-comma.rs b/rust/macros/tests/invalid/leading-comma.rs new file mode 100644 index 0000000..bc03666 --- /dev/null +++ b/rust/macros/tests/invalid/leading-comma.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // leading commas are not valid | ||
| 6 | let _hm: HashMap<_, _> = hashmap!(, 'a' => 2); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/missing-argument.rs b/rust/macros/tests/invalid/missing-argument.rs new file mode 100644 index 0000000..893d609 --- /dev/null +++ b/rust/macros/tests/invalid/missing-argument.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // an argument should come between each pair of commas | ||
| 6 | let _hm: HashMap<_, _> = hashmap!('a' => 1, , 'b' => 2); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/no-comma.rs b/rust/macros/tests/invalid/no-comma.rs new file mode 100644 index 0000000..c4e6a92 --- /dev/null +++ b/rust/macros/tests/invalid/no-comma.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // Key value pairs must be separated by commas | ||
| 6 | let _hm: HashMap<_, _> = hashmap!('a' => 1 'b' => 2); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/only-arrow.rs b/rust/macros/tests/invalid/only-arrow.rs new file mode 100644 index 0000000..7f7d730 --- /dev/null +++ b/rust/macros/tests/invalid/only-arrow.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // a single random arrow is not valid | ||
| 6 | let _hm: HashMap<(), ()> = hashmap!(=>); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/only-comma.rs b/rust/macros/tests/invalid/only-comma.rs new file mode 100644 index 0000000..3b863b3 --- /dev/null +++ b/rust/macros/tests/invalid/only-comma.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // a single random comma is not valid | ||
| 6 | let _hm: HashMap<(), ()> = hashmap!(,); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/single-argument.rs b/rust/macros/tests/invalid/single-argument.rs new file mode 100644 index 0000000..f8ac092 --- /dev/null +++ b/rust/macros/tests/invalid/single-argument.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // a single argument is invalid | ||
| 6 | let _hm: HashMap<_, _> = hashmap!('a'); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/triple-arguments.rs b/rust/macros/tests/invalid/triple-arguments.rs new file mode 100644 index 0000000..54351ae --- /dev/null +++ b/rust/macros/tests/invalid/triple-arguments.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // three arguments are invalid | ||
| 6 | hashmap!('a' => 1, 'b'); | ||
| 7 | } | ||
diff --git a/rust/macros/tests/invalid/two-arrows.rs b/rust/macros/tests/invalid/two-arrows.rs new file mode 100644 index 0000000..254a82e --- /dev/null +++ b/rust/macros/tests/invalid/two-arrows.rs | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | use macros::hashmap; | ||
| 2 | use std::collections::HashMap; | ||
| 3 | |||
| 4 | fn main() { | ||
| 5 | // a trailing => isn't valid either | ||
| 6 | hashmap!('a' => 2, =>); | ||
| 7 | } | ||
