1 // pest. The Elegant Parser
2 // Copyright (c) 2018 Dragoș Tiselice
3 //
4 // Licensed under the Apache License, Version 2.0
5 // <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
6 // license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. All files in the project carrying such notice may not be copied,
8 // modified, or distributed except according to those terms.
9 
10 #[macro_use]
11 extern crate pest;
12 #[macro_use]
13 extern crate pest_derive;
14 
15 #[derive(Parser)]
16 #[grammar = "../tests/reporting.pest"]
17 struct ReportingParser;
18 
19 #[test]
choices()20 fn choices() {
21     fails_with! {
22         parser: ReportingParser,
23         input: "x",
24         rule: Rule::choices,
25         positives: vec![Rule::a, Rule::b, Rule::c],
26         negatives: vec![],
27         pos: 0
28     };
29 }
30 
31 #[test]
choices_no_progress()32 fn choices_no_progress() {
33     fails_with! {
34         parser: ReportingParser,
35         input: "x",
36         rule: Rule::choices_no_progress,
37         positives: vec![Rule::choices_no_progress],
38         negatives: vec![],
39         pos: 0
40     };
41 }
42 
43 #[test]
choices_a_progress()44 fn choices_a_progress() {
45     fails_with! {
46         parser: ReportingParser,
47         input: "a",
48         rule: Rule::choices_a_progress,
49         positives: vec![Rule::a],
50         negatives: vec![],
51         pos: 1
52     };
53 }
54 
55 #[test]
choices_b_progress()56 fn choices_b_progress() {
57     fails_with! {
58         parser: ReportingParser,
59         input: "b",
60         rule: Rule::choices_b_progress,
61         positives: vec![Rule::b],
62         negatives: vec![],
63         pos: 1
64     };
65 }
66 
67 #[test]
nested()68 fn nested() {
69     fails_with! {
70         parser: ReportingParser,
71         input: "x",
72         rule: Rule::level1,
73         positives: vec![Rule::a, Rule::b, Rule::c],
74         negatives: vec![],
75         pos: 0
76     };
77 }
78 
79 #[test]
negative()80 fn negative() {
81     fails_with! {
82         parser: ReportingParser,
83         input: "x",
84         rule: Rule::negative,
85         positives: vec![],
86         negatives: vec![Rule::d],
87         pos: 0
88     };
89 }
90 
91 #[test]
negative_match()92 fn negative_match() {
93     fails_with! {
94         parser: ReportingParser,
95         input: "x",
96         rule: Rule::negative_match,
97         positives: vec![Rule::b],
98         negatives: vec![],
99         pos: 0
100     };
101 }
102 
103 #[test]
mixed()104 fn mixed() {
105     fails_with! {
106         parser: ReportingParser,
107         input: "x",
108         rule: Rule::mixed,
109         positives: vec![Rule::a],
110         negatives: vec![Rule::d],
111         pos: 0
112     };
113 }
114 
115 #[test]
mixed_progress()116 fn mixed_progress() {
117     fails_with! {
118         parser: ReportingParser,
119         input: "b",
120         rule: Rule::mixed_progress,
121         positives: vec![Rule::a],
122         negatives: vec![],
123         pos: 1
124     };
125 }
126