summaryrefslogtreecommitdiffstats
path: root/vendor/pest_derive/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/pest_derive/tests
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/pest_derive/tests')
-rw-r--r--vendor/pest_derive/tests/grammar.pest2
-rw-r--r--vendor/pest_derive/tests/grammar.rs14
-rw-r--r--vendor/pest_derive/tests/implicit.pest8
-rw-r--r--vendor/pest_derive/tests/implicit.rs12
4 files changed, 32 insertions, 4 deletions
diff --git a/vendor/pest_derive/tests/grammar.pest b/vendor/pest_derive/tests/grammar.pest
index b24d47747..5d64d5d0d 100644
--- a/vendor/pest_derive/tests/grammar.pest
+++ b/vendor/pest_derive/tests/grammar.pest
@@ -21,6 +21,7 @@ sequence_non_atomic = @{ sequence }
sequence_atomic_compound = @{ sequence_compound }
sequence_nested = { string ~ string }
sequence_compound_nested = ${ sequence_nested }
+node_tag = { #string = string }
choice = { string | range }
choice_prefix = { | string | range }
optional = { string? }
@@ -67,6 +68,7 @@ han = { HAN+ }
hangul = { HANGUL+ }
hiragana = { HIRAGANA+ }
arabic = { ARABIC+ }
+emoji = { EMOJI+ }
WHITESPACE = _{ " " }
COMMENT = _{ "$"+ }
diff --git a/vendor/pest_derive/tests/grammar.rs b/vendor/pest_derive/tests/grammar.rs
index cf5a4a60c..30ef99d63 100644
--- a/vendor/pest_derive/tests/grammar.rs
+++ b/vendor/pest_derive/tests/grammar.rs
@@ -263,6 +263,20 @@ fn choice_prefix() {
}
#[test]
+fn node_tag() {
+ parses_to! {
+ parser: GrammarParser,
+ input: "abc",
+ rule: Rule::node_tag,
+ tokens: [
+ node_tag(0, 3, [
+ string(0, 3)
+ ])
+ ]
+ };
+}
+
+#[test]
fn optional_string() {
parses_to! {
parser: GrammarParser,
diff --git a/vendor/pest_derive/tests/implicit.pest b/vendor/pest_derive/tests/implicit.pest
index 18ebf7eaf..4d26b66d6 100644
--- a/vendor/pest_derive/tests/implicit.pest
+++ b/vendor/pest_derive/tests/implicit.pest
@@ -1,9 +1,9 @@
program = _{ SOI ~ implicit ~ EOI }
-implicit= ${ or ~ (WHITESPACE+ ~ or )* }
+implicit= ${ #head = or ~ #tail = (WHITESPACE+ ~ or)* }
-or = !{ and ~ (or_op ~ and)+ | and }
-and = { comp ~ (and_op ~ comp)+ | comp }
-comp = { array ~ eq_op ~ array | array }
+or = !{ #more_and = and ~ (or_op ~ and)+ | #one_and = and }
+and = { #more_comp = comp ~ (and_op ~ comp)+ | #one_comp = comp }
+comp = { #more_array = array ~ eq_op ~ array | #one_array = array }
array = ${ term }
diff --git a/vendor/pest_derive/tests/implicit.rs b/vendor/pest_derive/tests/implicit.rs
index 8ad5a7e6a..48c880210 100644
--- a/vendor/pest_derive/tests/implicit.rs
+++ b/vendor/pest_derive/tests/implicit.rs
@@ -9,6 +9,7 @@ extern crate alloc;
extern crate pest;
extern crate pest_derive;
+#[cfg(feature = "grammar-extras")]
use pest::Parser;
use pest_derive::Parser;
@@ -17,9 +18,20 @@ use pest_derive::Parser;
struct TestImplicitParser;
#[test]
+#[cfg(feature = "grammar-extras")]
fn test_implicit_whitespace() {
// this failed to parse due to a bug in the optimizer
// see: https://github.com/pest-parser/pest/issues/762#issuecomment-1375374868
let successful_parse = TestImplicitParser::parse(Rule::program, "a a");
assert!(successful_parse.is_ok());
+ // dbg!(&successful_parse);
+ let pairs = successful_parse.unwrap();
+ assert!(pairs.find_first_tagged("head").is_some());
+ assert!(pairs.find_first_tagged("tail").is_some());
+ assert!(pairs.find_first_tagged("more_and").is_none());
+ assert!(pairs.find_first_tagged("more_comp").is_none());
+ assert!(pairs.find_first_tagged("more_array").is_none());
+ assert_eq!(pairs.clone().find_tagged("one_and").count(), 2);
+ assert_eq!(pairs.clone().find_tagged("one_comp").count(), 2);
+ assert_eq!(pairs.find_tagged("one_array").count(), 2);
}