diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/pest_derive/tests | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+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/oneormore.pest | 5 | ||||
-rw-r--r-- | vendor/pest_derive/tests/oneormore.rs | 29 |
2 files changed, 34 insertions, 0 deletions
diff --git a/vendor/pest_derive/tests/oneormore.pest b/vendor/pest_derive/tests/oneormore.pest new file mode 100644 index 000000000..4655101f6 --- /dev/null +++ b/vendor/pest_derive/tests/oneormore.pest @@ -0,0 +1,5 @@ +WHITESPACE = _{ " " | "\r" | "\n" | "\t" } + + +identifier = { (ASCII_ALPHA | "_")+ } +assign = { identifier ~ "<-" ~ identifier } diff --git a/vendor/pest_derive/tests/oneormore.rs b/vendor/pest_derive/tests/oneormore.rs new file mode 100644 index 000000000..6bdb3c597 --- /dev/null +++ b/vendor/pest_derive/tests/oneormore.rs @@ -0,0 +1,29 @@ +#![cfg_attr(not(feature = "std"), no_std)] +extern crate alloc; +#[cfg(not(feature = "std"))] +use alloc::{format, vec::Vec}; + +#[cfg(feature = "grammar-extras")] +use pest::Parser; +use pest_derive::Parser; + +#[derive(Parser)] +#[grammar = "../tests/oneormore.pest"] +pub struct OneOrMoreParser; + +#[test] +#[cfg(feature = "grammar-extras")] +pub fn test_one_or_more() { + let result = OneOrMoreParser::parse(Rule::assign, "k <- b\n"); + assert!(result.is_ok()); + let mut pairs = result.unwrap(); + let pair = pairs.next().unwrap(); + assert_eq!(pair.as_rule(), Rule::assign); + let mut inner = pair.into_inner(); + let lhs = inner.next().unwrap(); + assert_eq!(lhs.as_rule(), Rule::identifier); + assert_eq!(lhs.as_str(), "k"); + let rhs = inner.next().unwrap(); + assert_eq!(rhs.as_rule(), Rule::identifier); + assert_eq!(rhs.as_str(), "b"); +} |