Skip to content

Commit 57d45e4

Browse files
committed
Move assign tests into a module.
1 parent 6ba29f7 commit 57d45e4

File tree

1 file changed

+36
-32
lines changed

1 file changed

+36
-32
lines changed

parser/src/command/assign.rs

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,40 +79,44 @@ impl AssignCommand {
7979
}
8080

8181
#[cfg(test)]
82-
fn parse<'a>(input: &'a str) -> Result<Option<AssignCommand>, Error<'a>> {
83-
let mut toks = Tokenizer::new(input);
84-
Ok(AssignCommand::parse(&mut toks)?)
85-
}
82+
mod tests {
83+
use super::*;
8684

87-
#[test]
88-
fn test_1() {
89-
assert_eq!(parse("claim."), Ok(Some(AssignCommand::Own)),);
90-
}
85+
fn parse<'a>(input: &'a str) -> Result<Option<AssignCommand>, Error<'a>> {
86+
let mut toks = Tokenizer::new(input);
87+
Ok(AssignCommand::parse(&mut toks)?)
88+
}
9189

92-
#[test]
93-
fn test_2() {
94-
assert_eq!(parse("claim"), Ok(Some(AssignCommand::Own)),);
95-
}
90+
#[test]
91+
fn test_1() {
92+
assert_eq!(parse("claim."), Ok(Some(AssignCommand::Own)),);
93+
}
9694

97-
#[test]
98-
fn test_3() {
99-
assert_eq!(
100-
parse("assign @user"),
101-
Ok(Some(AssignCommand::User {
102-
username: "user".to_owned()
103-
})),
104-
);
105-
}
95+
#[test]
96+
fn test_2() {
97+
assert_eq!(parse("claim"), Ok(Some(AssignCommand::Own)),);
98+
}
10699

107-
#[test]
108-
fn test_4() {
109-
use std::error::Error;
110-
assert_eq!(
111-
parse("assign @")
112-
.unwrap_err()
113-
.source()
114-
.unwrap()
115-
.downcast_ref(),
116-
Some(&ParseError::MentionUser),
117-
);
100+
#[test]
101+
fn test_3() {
102+
assert_eq!(
103+
parse("assign @user"),
104+
Ok(Some(AssignCommand::User {
105+
username: "user".to_owned()
106+
})),
107+
);
108+
}
109+
110+
#[test]
111+
fn test_4() {
112+
use std::error::Error;
113+
assert_eq!(
114+
parse("assign @")
115+
.unwrap_err()
116+
.source()
117+
.unwrap()
118+
.downcast_ref(),
119+
Some(&ParseError::MentionUser),
120+
);
121+
}
118122
}

0 commit comments

Comments
 (0)