private void AssertEquals(TcDeclaration expected, TcDeclaration actual)
 {
     Assert.Equal(expected.Name, actual.Name);
     Assert.Equal(expected.Allocation, actual.Allocation);
     Assert.Equal(expected.DataType, actual.DataType);
     Assert.Equal(expected.Initialization, actual.Initialization);
     Assert.Equal(expected.Comment, actual.Comment);
 }
        public void VarAndTypeVariousWhitespaceArrangements(
            string variable, string type
            )
        {
            VariableDeclaration varDecl = new VariableDeclaration(
                $"{variable}:{type};", singleIndent: "    ", lineEnding: "\n"
                );
            TcDeclaration expectedDecl = new TcDeclaration(
                variable.Trim(), "", varDecl.RemoveWhiteSpaceIfPossible(type), "", ""
                );

            AssertEquals(expectedDecl, varDecl.Tokenize());
        }
        public void VarAllocationAndTypeVariousWhitespaceArangements
        (
            string variable, string allocation, string type)
        {
            VariableDeclaration varDecl = new VariableDeclaration(
                $"{variable} AT {allocation}:{type};",
                singleIndent: "    ",
                lineEnding: "\n"
                );
            TcDeclaration expectedDecl = new TcDeclaration(
                variable.Trim(), allocation.Trim(), type.Trim(), "", ""
                );

            AssertEquals(expectedDecl, varDecl.Tokenize());
        }
        public void VarAllocationTypeAndInitializationVariousWhitespaceArangements(
            string variable, string allocation, string type, string initialization
            )
        {
            VariableDeclaration varDecl = new VariableDeclaration(
                $"{variable}{allocation}:{type}:={initialization};",
                singleIndent: "    ",
                lineEnding: "\n"
                );
            string        _allocation  = allocation.Replace("AT", "");
            TcDeclaration expectedDecl = new TcDeclaration(
                variable.Trim(),
                _allocation.Trim(),
                varDecl.RemoveWhiteSpaceIfPossible(type),
                varDecl.RemoveWhiteSpaceIfPossible(initialization), ""
                );

            AssertEquals(expectedDecl, varDecl.Tokenize());
        }
Exemple #5
0
        public void VarAndTypeVariousWhitespaceArrangements(
            string variable, string type
            )
        {
            Globals.indentation = "    ";
            Globals.lineEnding  = "\n";
            VariableDeclaration varDecl = new VariableDeclaration(
                $"{variable}:{type};"
                );
            TcDeclaration expectedDecl = new TcDeclaration(
                variable.Trim(),
                "",
                VariableDeclaration.RemoveWhiteSpaceIfPossible(type),
                "",
                ""
                );

            AssertEquals(expectedDecl, varDecl.Tokenize());
        }
Exemple #6
0
        public void AllDeclarationsVariousWhitespaceArangements(
            string variable,
            string allocation,
            string type,
            string initialization,
            string comment
            )
        {
            Globals.indentation = "    ";
            Globals.lineEnding  = "\n";
            VariableDeclaration varDecl = new VariableDeclaration(
                $"{variable}{allocation}:{type}:={initialization};{comment}"
                );
            string        _allocation  = allocation.Replace("AT", "");
            TcDeclaration expectedDecl = new TcDeclaration(
                variable.Trim(),
                _allocation.Trim(),
                VariableDeclaration.RemoveWhiteSpaceIfPossible(type.Trim()),
                VariableDeclaration.RemoveWhiteSpaceIfPossible(initialization),
                comment.Trim()
                );

            AssertEquals(expectedDecl, varDecl.Tokenize());
        }