use slash_lang::parser::parse;
use slash_lang::parser::suffixes::strip_verbosity;

#[test]
fn strip_verbosity_plus() {
    assert_eq!(strip_verbosity("/build+"), ("/build", 1));
    assert_eq!(strip_verbosity("/build++"), ("/build", 2));
    assert_eq!(strip_verbosity("/build+++"), ("/build", 3));
}

#[test]
fn strip_verbosity_minus() {
    assert_eq!(strip_verbosity("/build-"), ("/build", -1));
    assert_eq!(strip_verbosity("/build--"), ("/build", -2));
}

#[test]
fn strip_verbosity_none() {
    assert_eq!(strip_verbosity("/build"), ("/build", 0));
}

#[test]
fn parses_verbose_command() {
    let prog = parse("/build+").unwrap();
    let cmd = &prog.pipelines[0].commands[0];
    assert_eq!(cmd.verbosity, 1);
    assert_eq!(cmd.name, "build");
}

#[test]
fn parses_quiet_command() {
    let prog = parse("/build--").unwrap();
    let cmd = &prog.pipelines[0].commands[0];
    assert_eq!(cmd.verbosity, -2);
}

#[test]
fn verbosity_with_urgency_and_optional() {
    let prog = parse("/build.flag(val)?+!!").unwrap();
    let cmd = &prog.pipelines[0].commands[0];
    assert_eq!(cmd.name, "build");
    assert!(cmd.optional);
    assert_eq!(cmd.verbosity, 1);
    assert_eq!(cmd.urgency, slash_lang::parser::ast::Urgency::Medium);
}
