Skip to content

Commit

Permalink
feat: code refactor and tests improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Feb 1, 2023
1 parent da6a45f commit da01d36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion parser/src/parser/grammar.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ RandomValues: RandomValues = {

RandValuesDecl: RandomValues = {
<name: Identifier> ":" <size: Size> => RandomValues::new(name, size, vec![]),
<_name: Identifier> ":" "[" "]" =>? Err(
<Identifier> ":" "[" "]" =>? Err(
ParseError::User{
error: Error::ParseError(
InvalidRandomValues(
Expand Down
15 changes: 5 additions & 10 deletions parser/src/parser/tests/random_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{
// ================================================================================================

#[test]
fn random_values_fixed_list_default_name() {
fn random_values_fixed_list() {
let source = "
random_values:
rand: [15]";
Expand Down Expand Up @@ -37,18 +37,14 @@ fn random_values_ident_vector() {
}

#[test]
fn random_values_ident_vector_custom_name() {
fn random_values_custom_name() {
let source = "
random_values:
alphas: [a, b[12], c]";
alphas: [14]";
let expected = Source(vec![RandomValues(RandomValues::new(
Identifier("alphas".to_string()),
14,
vec![
RandBinding::new(Identifier("a".to_string()), 1),
RandBinding::new(Identifier("b".to_string()), 12),
RandBinding::new(Identifier("c".to_string()), 1),
],
vec![],
))]);
build_parse_test!(source).expect_ast(expected);
}
Expand All @@ -69,8 +65,7 @@ fn random_values_multiple_declaration_error() {
let source = "
random_values:
rand: [12]
alphas: [a, b[2]]
betas: [c[12], d]";
alphas: [a, b[2]]";
let error = Error::ParseError(ParseError::InvalidRandomValues(
"No more than one set of random values can be declared".to_string(),
));
Expand Down

0 comments on commit da01d36

Please sign in to comment.