about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-01-01 17:04:29 +0000
committerGitHub <noreply@github.com>2022-01-01 17:04:29 +0000
commit0e5d8883ccbe4a125e8da07a4be6c791838e9134 (patch)
treee61f96a038ccb5ff658ca36e32dabcdad1683258
parent3f2edc72cd80d3c2f85705d499d7416690782611 (diff)
parente36f557e4d0f591888dab84c9b5d5d47b0ea6c83 (diff)
downloadrust-0e5d8883ccbe4a125e8da07a4be6c791838e9134.tar.gz
rust-0e5d8883ccbe4a125e8da07a4be6c791838e9134.zip
Merge #11153
11153: internal: add more prefix entry point tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
-rw-r--r--crates/parser/src/tests/entries.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/parser/src/tests/entries.rs b/crates/parser/src/tests/entries.rs
index 1174e33f5f8..d52c6fbb16f 100644
--- a/crates/parser/src/tests/entries.rs
+++ b/crates/parser/src/tests/entries.rs
@@ -59,10 +59,30 @@ fn path() {
     check_prefix(PrefixEntryPoint::Path, "foo::<> baz", "foo::<>");
     check_prefix(PrefixEntryPoint::Path, "foo<> baz", "foo<>");
     check_prefix(PrefixEntryPoint::Path, "Fn() -> i32?", "Fn() -> i32");
-    // FIXME: this shouldn't be accepted as path actually.
+    // FIXME: This shouldn't be accepted as path actually.
     check_prefix(PrefixEntryPoint::Path, "<_>::foo", "<_>::foo");
 }
 
+#[test]
+fn item() {
+    // FIXME: This shouldn't consume the semicolon.
+    check_prefix(PrefixEntryPoint::Item, "fn foo() {};", "fn foo() {};");
+    check_prefix(PrefixEntryPoint::Item, "#[attr] pub struct S {} 92", "#[attr] pub struct S {}");
+    check_prefix(PrefixEntryPoint::Item, "item!{}?", "item!{}");
+    check_prefix(PrefixEntryPoint::Item, "????", "?");
+}
+
+#[test]
+fn meta_item() {
+    check_prefix(PrefixEntryPoint::MetaItem, "attr, ", "attr");
+    check_prefix(
+        PrefixEntryPoint::MetaItem,
+        "attr(some token {stream});",
+        "attr(some token {stream})",
+    );
+    check_prefix(PrefixEntryPoint::MetaItem, "path::attr = 2 * 2!", "path::attr = 2 * 2");
+}
+
 fn check_prefix(entry: PrefixEntryPoint, input: &str, prefix: &str) {
     let lexed = LexedStr::new(input);
     let input = lexed.to_input();