1 // Licensed under the Apache License, Version 2.0 2 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT 3 // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 4 // option. All files in the project carrying such notice may not be copied, 5 // modified, or distributed except according to those terms. 6 7 #![cfg_attr(not(feature = "std"), no_std)] 8 extern crate alloc; 9 extern crate pest; 10 extern crate pest_derive; 11 12 #[cfg(feature = "grammar-extras")] 13 use pest::Parser; 14 use pest_derive::Parser; 15 16 #[derive(Parser)] 17 #[grammar = "../tests/implicit.pest"] 18 struct TestImplicitParser; 19 20 #[test] 21 #[cfg(feature = "grammar-extras")] test_implicit_whitespace()22fn test_implicit_whitespace() { 23 // this failed to parse due to a bug in the optimizer 24 // see: https://github.com/pest-parser/pest/issues/762#issuecomment-1375374868 25 let successful_parse = TestImplicitParser::parse(Rule::program, "a a"); 26 assert!(successful_parse.is_ok()); 27 // dbg!(&successful_parse); 28 let pairs = successful_parse.unwrap(); 29 assert!(pairs.find_first_tagged("head").is_some()); 30 assert!(pairs.find_first_tagged("tail").is_some()); 31 assert!(pairs.find_first_tagged("more_and").is_none()); 32 assert!(pairs.find_first_tagged("more_comp").is_none()); 33 assert!(pairs.find_first_tagged("more_array").is_none()); 34 assert_eq!(pairs.clone().find_tagged("one_and").count(), 2); 35 assert_eq!(pairs.clone().find_tagged("one_comp").count(), 2); 36 assert_eq!(pairs.find_tagged("one_array").count(), 2); 37 } 38