Skip to content

Commit 4e4deec

Browse files
committed
move CDDLTestParser to the tests::common mod
1 parent f7dd70c commit 4e4deec

File tree

12 files changed

+24
-57
lines changed

12 files changed

+24
-57
lines changed

rust/cbork-cddl-parser/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
mod parser;
44
mod preprocessor;
55

6-
pub use crate::parser::cddl_test;
7-
86
/// Represents different grammar extensions for handling CDDL specifications.
97
pub enum Extension {
108
/// RFC8610 ONLY limited grammar.

rust/cbork-cddl-parser/src/parser.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ pub(crate) mod cddl {
3535
pub(crate) struct Parser;
3636
}
3737

38-
/// Full CDDL syntax test parser.
39-
/// Parser with DEBUG rules. These rules are only used in tests.
40-
#[allow(missing_docs)]
41-
pub mod cddl_test {
42-
pub use pest::Parser;
43-
/// A Pest test parser for a full CDDL syntax.
44-
#[derive(pest_derive::Parser)]
45-
#[grammar = "grammar/rfc_8610.pest"]
46-
#[grammar = "grammar/rfc_9165.pest"]
47-
#[grammar = "grammar/cddl_modules.pest"]
48-
#[grammar = "grammar/cddl_test.pest"] // Ideally this would only be used in tests.
49-
pub struct CDDLTestParser;
50-
}
51-
5238
/// CDDL Standard Postlude - read from an external file
5339
const POSTLUDE: &str = include_str!("grammar/postlude.cddl");
5440

rust/cbork-cddl-parser/tests/byte_sequences.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// cspell: words hexpair rstuvw abcdefghijklmnopqrstuvwyz rstuvw Xhhb Bhcm
22

3-
use cbork_cddl_parser::cddl_test::Rule;
4-
53
mod common;
6-
use common::byte_sequences::*;
4+
use common::{byte_sequences::*, Rule};
75

86
#[test]
97
/// Test if the `HEX_PAIR` rule passes properly.

rust/cbork-cddl-parser/tests/character_sets.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// cspell: words PCHAR pchar BCHAR bchar SESC sesc SCHAR schar fffd fffe
22

3-
use cbork_cddl_parser::{
4-
self,
5-
cddl_test::{CDDLTestParser, Parser, Rule},
6-
};
3+
mod common;
4+
use common::{CDDLTestParser, Rule};
5+
use pest::Parser;
76

87
#[test]
98
/// Test if the `WHITESPACE` rule passes properly.

rust/cbork-cddl-parser/tests/comments.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
use cbork_cddl_parser::{self, cddl_test::Rule};
2-
31
mod common;
4-
use common::comments::*;
2+
use common::{comments::*, Rule};
53

64
#[test]
75
/// Test if the `COMMENT` rule passes properly.

rust/cbork-cddl-parser/tests/common/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
use cbork_cddl_parser::{
2-
self,
3-
cddl_test::{CDDLTestParser, Parser, Rule},
4-
};
1+
use pest::Parser;
52

63
pub(crate) mod byte_sequences;
74
pub(crate) mod comments;
@@ -12,7 +9,16 @@ pub(crate) mod rules;
129
pub(crate) mod text_sequences;
1310
pub(crate) mod type_declarations;
1411

12+
/// A Pest test parser for a full CDDL syntax.
13+
#[derive(pest_derive::Parser)]
14+
#[grammar = "grammar/rfc_8610.pest"]
15+
#[grammar = "grammar/rfc_9165.pest"]
16+
#[grammar = "grammar/cddl_modules.pest"]
17+
#[grammar = "grammar/cddl_test.pest"] // Ideally this would only be used in tests.
18+
pub struct CDDLTestParser;
19+
1520
/// # Panics
21+
#[allow(dead_code)]
1622
pub(crate) fn check_tests_rule(rule_type: Rule, passes: &[&str], fails: &[&str]) {
1723
for test in passes {
1824
let parse = CDDLTestParser::parse(rule_type, test);

rust/cbork-cddl-parser/tests/group_elements.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// cspell: words OPTCOM MEMBERKEY bareword tstr GRPENT GRPCHOICE
22
// cspell: words optcom memberkey grpent grpchoice
33

4-
use cbork_cddl_parser::{self, cddl_test::Rule};
5-
64
mod common;
7-
use common::{group_elements::*, identifiers::*};
5+
use common::{group_elements::*, identifiers::*, Rule};
86

97
#[test]
108
/// Test if the `occur` rule passes properly.

rust/cbork-cddl-parser/tests/identifiers.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// cspell: words aname groupsocket typesocket groupsocket
22

3-
use cbork_cddl_parser::{
4-
self,
5-
cddl_test::{CDDLTestParser, Parser, Rule},
6-
};
7-
83
mod common;
9-
use common::identifiers::*;
4+
use common::{identifiers::*, CDDLTestParser, Rule};
5+
use pest::Parser;
106

117
#[test]
128
/// Check if the name components pass properly.

rust/cbork-cddl-parser/tests/literal_values.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
use std::ops::Deref;
44

5-
use cbork_cddl_parser::{self, cddl_test::Rule};
6-
75
mod common;
8-
use common::{byte_sequences::*, literal_values::*, text_sequences::*};
6+
use common::{byte_sequences::*, literal_values::*, text_sequences::*, Rule};
97

108
#[test]
119
/// Test if the `uint` rule passes properly.

rust/cbork-cddl-parser/tests/rules.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
// cspell: words GENERICARG bigfloat ASSIGNG GROUPNAME tstr genericarg GENERICARG
22
// cspell: words assigng assignt ASSIGNT GENERICPARM genericparm
33

4-
use cbork_cddl_parser::{
5-
self,
6-
cddl_test::{CDDLTestParser, Parser, Rule},
7-
};
8-
94
mod common;
10-
use common::{rules::*, type_declarations::*};
5+
use common::{rules::*, type_declarations::*, CDDLTestParser, Rule};
6+
use pest::Parser;
117

128
#[test]
139
/// Test if the `genericarg` rule passes properly.

0 commit comments

Comments
 (0)