<commit_before>import ceylon.build.runner {
    goalDefinition
}
import ceylon.build.task {
    goal,
    dependsOn
}
import ceylon.test {
    test
}

goal
shared void standAloneGoal() {}

goal("named-goal")
shared void standAloneNamedGoal() {}

goal
dependsOn(`function standAloneGoal`)
shared void goalWithOneDependency() {}

goal
dependsOn(`function standAloneNamedGoal`)
shared void goalWithOneNamedDependency() {}

goal
dependsOn(`function standAloneGoal`)
dependsOn(`function goalWithOneDependency`)
shared void goalWithMultiplesDependency() {}

goal
dependsOn(`function standAloneGoal`, `function goalWithOneDependency`)
shared void goalWithMultiplesDependencyInOneAnnotation() {}

test void shouldBuildGoalWithOneDependency() {
    checkGoalDefinition {
        goal = goalDefinition(`function goalWithOneDependency`, emptyPhases);
        expectedDefinition = ExpectedDefinition {
            name = "goalWithOneDependency";
            dependencies = ["standAloneGoal"];
        };
    };
}

test void shouldBuildGoalWithOneNamedDependency() {
    checkGoalDefinition {
        goal = goalDefinition(`function goalWithOneNamedDependency`, emptyPhases);
        expectedDefinition = ExpectedDefinition {
            name = "goalWithOneNamedDependency";
            dependencies = ["named-goal"];
        };
    };
}

test void shouldBuildGoalWithMultiplesDependencies() {
    checkGoalDefinition {
        goal = goalDefinition(`function goalWithMultiplesDependency`, emptyPhases);
        expectedDefinition = ExpectedDefinition {
            name = "goalWithMultiplesDependency";
            dependencies = ["standAloneGoal", "goalWithOneDependency"];
        };
    };
}

test void shouldBuildGoalWithMultiplesDependenciesInOneAnnotation() {
    checkGoalDefinition {
        goal = goalDefinition(`function goalWithMultiplesDependencyInOneAnnotation`, emptyPhases);
        expectedDefinition = ExpectedDefinition {
            name = "goalWithMultiplesDependencyInOneAnnotation";
            dependencies = ["standAloneGoal", "goalWithOneDependency"];
        };
    };
}<commit_msg>Add tests for direct dependencies + one coming from attachTo phase<commit_after>import ceylon.build.engine {
    Goal
}
import ceylon.build.runner {
    goalDefinition,
    InvalidGoalDeclaration
}
import ceylon.build.task {
    goal,
    dependsOn,
    attachTo
}
import ceylon.collection {
    HashMap
}
import ceylon.test {
    test,
    assertEquals
}
import test.ceylon.build.runner { emptyPhases }

goal
shared void standAloneGoal() {}

goal("named-goal")
shared void standAloneNamedGoal() {}

goal
dependsOn(`function standAloneGoal`)
shared void goalWithOneDependency() {}

goal
dependsOn(`function standAloneNamedGoal`)
shared void goalWithOneNamedDependency() {}

goal
dependsOn(`function standAloneGoal`)
dependsOn(`function standAloneNamedGoal`)
shared void goalWithMultiplesDependency() {}

goal
dependsOn(`function standAloneGoal`, `function standAloneNamedGoal`)
shared void goalWithMultiplesDependencyInOneAnnotation() {}

test void shouldHaveOneDependency() {
    shouldHaveDependencies(goalDefinition(`function goalWithOneDependency`, emptyPhases), ["standAloneGoal"]);
    shouldHaveDependencies(goalDefinition(`function standAloneGoal`, emptyPhases), []);
}

test void shouldHaveOneNamedDependency() {
    shouldHaveDependencies(goalDefinition(`function goalWithOneNamedDependency`, emptyPhases), ["named-goal"]);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal`, emptyPhases), []);
}

test void shouldHaveMultiplesDependenciesFromMultipleAnnotations() {
    shouldHaveDependencies(goalDefinition(`function goalWithMultiplesDependency`, emptyPhases),
        ["standAloneGoal", "named-goal"]);
    shouldHaveDependencies(goalDefinition(`function standAloneGoal`, emptyPhases), []);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal`, emptyPhases), []);
}

test void shouldHaveMultiplesDependenciesFromOneAnnotation() {
    shouldHaveDependencies(goalDefinition(`function goalWithMultiplesDependencyInOneAnnotation`, emptyPhases),
        ["standAloneGoal", "named-goal"]);
    shouldHaveDependencies(goalDefinition(`function standAloneGoal`, emptyPhases), []);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal`, emptyPhases), []);
}

goal
attachTo(`function standAloneNamedGoal2`)
shared void standAloneGoal2() {}

goal("named-goal2")
shared void standAloneNamedGoal2() {}

goal
attachTo(`function goalWithOneDependency2`)
shared void standAloneNamedGoal3() {}

goal
dependsOn(`function standAloneNamedGoal2`)
shared void goalWithOneDependency2() {}


test void shouldAttachGoalToPhase() {
    value phases = HashMap { entries = {
            `function standAloneGoal2` -> [`function standAloneNamedGoal2`]
        };
    };
    shouldHaveDependencies(goalDefinition(`function standAloneGoal2`, phases), ["named-goal2"]);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal2`, phases), []);
}

test void shouldConcatenateDependenciesAndAttachTo() {
    value phases = HashMap { entries = {
            `function goalWithOneDependency2` -> [`function standAloneNamedGoal3`]
        };
    };
    shouldHaveDependencies(goalDefinition(`function goalWithOneDependency2`, phases),
        ["named-goal2", "standAloneNamedGoal3"]);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal2`, phases), []);
    shouldHaveDependencies(goalDefinition(`function standAloneNamedGoal3`, phases), []);
}

void shouldHaveDependencies(Goal|InvalidGoalDeclaration goal, [String*] dependencies) {
    assert(is Goal goal);
    assertEquals(goal.properties.dependencies, dependencies);
}
{'fraction_non_alphanumeric': 0.0996309963099631, 'fraction_numerical': 0.003514320857494289, 'mean_word_length': 5.446206115515289, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6885942', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1519, 'n_words': 291}