Skip to content

Commit

Permalink
Merge pull request #1181 from Barsik-sus/wca_arguments_with_spaces
Browse files Browse the repository at this point in the history
READY(wca): Add tests for handling spaces in command arguments
  • Loading branch information
Wandalen committed Mar 22, 2024
2 parents 4da4623 + 54bc658 commit 42b24a1
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
24 changes: 24 additions & 0 deletions module/move/wca/tests/inc/commands_aggregator/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,29 @@ tests_impls!

a_id!( (), executor.command( dictionary, grammar_command ).unwrap() );
}

// qqq : make the following test work
// fn subject_with_spaces()
// {
// let query = "SELECT title, links, MIN( published ) FROM Frames";
// let ca = CommandsAggregator::former()
// .grammar(
// [
// wca::Command::former()
// .hint( "hint" )
// .long_hint( "long_hint" )
// .phrase( "query.execute" )
// .subject( "SQL query", Type::String, false )
// .form(),
// ])
// .executor(
// [
// ( "query.execute".to_owned(), Routine::new( move |( args, _ )| { assert_eq!( query, args.get_owned::< &str >( 0 ).unwrap() ); Ok( () ) } ) ),
// ])
// .build();

// a_id!( (), ca.perform( vec![ ".query.execute".to_string(), query.into() ] ).unwrap() );
// }
}

//
Expand All @@ -257,4 +280,5 @@ tests_index!
string_subject_with_colon,
no_prop_subject_with_colon,
optional_prop_subject_with_colon,
// subject_with_spaces,
}
51 changes: 51 additions & 0 deletions module/move/wca/tests/inc/parser/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,56 @@ tests_impls!
);
}

// qqq : the parser must be able to accept a list of arguments(std::env::args())
// fn with_spaces_in_value()
// {
// let parser = Parser::former().form();

// a_id!
// (
// ParsedCommand
// {
// name : "command".into(),
// subjects : vec![ "value with spaces".into() ],
// properties : HashMap::new(),
// },
// parser.command( vec![ ".command".to_string(), "value with spaces".into() ] ).unwrap()
// );

// a_id!
// (
// ParsedCommand
// {
// name : "command".into(),
// subjects : vec![],
// properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]),
// },
// parser.command( vec![ ".command".to_string(), "prop:value with spaces".into() ] ).unwrap()
// );

// a_id!
// (
// ParsedCommand
// {
// name : "command".into(),
// subjects : vec![],
// properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]),
// },
// parser.command( vec![ ".command".to_string(), "prop:".into(), "value with spaces".into() ] ).unwrap()
// );

// a_id!
// (
// ParsedCommand
// {
// name : "command".into(),
// subjects : vec![],
// properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]),
// },
// parser.command( vec![ ".command".to_string(), "prop".into(), ":".into(), "value with spaces".into() ] ).unwrap()
// );
// }

fn not_only_alphanumeric_symbols()
{
let parser = Parser::former().form();
Expand Down Expand Up @@ -387,6 +437,7 @@ tests_index!
{
basic,
with_spaces,
// with_spaces_in_value,
not_only_alphanumeric_symbols,
same_command_and_prop_delimeter,
path_in_subject,
Expand Down

0 comments on commit 42b24a1

Please sign in to comment.