1+ // use core::panicking::panic;
12use std:: collections:: HashMap ;
23
34use pest:: iterators:: { Pair , Pairs } ;
@@ -13,14 +14,7 @@ pub struct FklParser;
1314pub fn parse ( code : & str ) -> ParseResult < Vec < FklDeclaration > > {
1415 match FklParser :: parse ( Rule :: declarations, code) {
1516 Err ( e) => {
16- let fancy_e = e. renamed_rules ( |rule| {
17- match * rule {
18- _ => {
19- format ! ( "{:?}" , rule)
20- }
21- }
22- } ) ;
23- return Err ( ParseError :: msg ( fancy_e) ) ;
17+ return Err ( ParseError :: msg ( e. to_string ( ) ) ) ;
2418 }
2519 Ok ( pairs) => {
2620 Ok ( consume_declarations ( pairs) )
@@ -1002,4 +996,47 @@ struct Cinema {
1002996 ] ,
1003997 } ) ) ;
1004998 }
999+
1000+ #[ test]
1001+ fn impl_flow ( ) {
1002+ let result = parse ( r#"
1003+ imple CinemaCreatedEvent {
1004+
1005+ }"# ) ;
1006+ match result {
1007+ Err ( e) => {
1008+ let string = format ! ( "{}" , e) ;
1009+ assert_eq ! ( string, r#" --> 2:1
1010+ |
1011+ 2 | imple CinemaCreatedEvent {
1012+ | ^---
1013+ |
1014+ = expected EOI or declaration"# ) ;
1015+ } ,
1016+ _ => assert ! ( false ) ,
1017+ } ;
1018+
1019+ // assert_eq!(result[0], FklDeclaration::Implementation(ImplementationDecl {
1020+ // name: "CinemaCreatedEvent".to_string(),
1021+ // inline_doc: "".to_string(),
1022+ // qualified_name: "".to_string(),
1023+ // endpoints: vec![
1024+ // EndpointDecl {
1025+ // name: "".to_string(),
1026+ // method: "GET".to_string(),
1027+ // uri: "/book/{id}".to_string(),
1028+ // authorization: Some(AuthorizationDecl {
1029+ // authorization_type: "Basic".to_string(),
1030+ // username: Some("admin".to_string()),
1031+ // password: Some("admin".to_string()),
1032+ // }),
1033+ // request: None,
1034+ // response: Some(HttpResponseDecl {
1035+ // name: "Cinema".to_string()
1036+ // }),
1037+ // }],
1038+ // }));
1039+
1040+ }
10051041}
1042+
0 commit comments