Translate() public static method

public static Translate ( Statement, statement ) : SUnit
statement Statement,
return Swummary.SUnit
Ejemplo n.º 1
0
    public void TranslateAssignmentSUnit()
    {
        var assignmentStatement = methodDef.GetDescendants <Statement>().OfType <DeclarationStatement>().First();

        Console.WriteLine("Assignment statement: {0}", assignmentStatement.ToString());

        var translated = SUnitTranslator.Translate(assignmentStatement);

        Console.WriteLine("Action: {0}\nTheme: {1}", translated.action, translated.theme);
    }
Ejemplo n.º 2
0
    public void TranslateVoidReturnSUnit()
    {
        var voidReturn = methodDef.GetDescendants <Statement>()
                         .First(s => Regex.IsMatch(s.ToString(), "getHurry"));

        var translated = SUnitTranslator.Translate(voidReturn);

        Console.WriteLine("SUnit Type: {0}\nAction: {1}\nTheme: {2}",
                          translated.type, translated.action, translated.theme);

        Assert.AreEqual("get", translated.action, "correct action");
        Assert.AreEqual("hurry", translated.theme, "exact theme");
    }
Ejemplo n.º 3
0
    public void TranslateSameActionSUnit()
    {
        var sameAction = methodDef.GetDescendants <Statement>()
                         .First(s => Regex.IsMatch(s.ToString(), "setFindInFilesDirFilter"));

        var translated = SUnitTranslator.Translate(sameAction);

        Console.WriteLine("SUnit Type: {0}\nAction: {1}\nTheme: {2}",
                          translated.type, translated.action, translated.theme);

        Assert.AreEqual("set", translated.action, "correct action");
        Assert.AreEqual("filter", translated.theme, "exact theme");
        Assert.IsTrue(Regex.IsMatch(translated.theme, "filter"), "vague theme");
    }
Ejemplo n.º 4
0
    public void TranslateEndingSUnit()
    {
        var ending = methodDef.GetDescendants <Statement>()
                     .First(s => Regex.IsMatch(s.ToString(), "return"));

        ending = methodDef.GetDescendants <ReturnStatement>().First();

        Console.WriteLine("Ending statement: {0}", ending);

        var translated = SUnitTranslator.Translate(ending);

        Assert.AreEqual("Return", translated.action, "correct action");
        Assert.AreEqual("true", translated.theme, "exact theme");
        Assert.IsTrue(Regex.IsMatch(translated.theme, "true"), "vague theme");
    }