jediwhale / fitsharp

Functional testing tools for .NET

Home Page:http://fitsharp.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ParseArray Fails When First term Is a Symbol

andydavidsmith opened this issue · comments

Hi if I have a an array of symbols the parsing fails as it looks for the entire string as a symbol but doesn't

the unit test below shows the behavior

using fitSharp.Fit.Model;
using fitSharp.Fit.Operators;
using fitSharp.Machine.Engine;
using fitSharp.Machine.Model;
using fitSharp.Samples.Fit;
using NUnit.Framework;

namespace fitSharp.Test.NUnit.Fit
{
[TestFixture]
public class ParseArraySymbols
{
[Test]
public void AllSymbols()
{
CheckParse("<<Name1,<<Name2,<<Name3", new string[] { "TED", "GEOFF", "BOB" });
}

    [Test]
    public void FirstItemNotSymbols()
    {
        CheckParse("TED,<<Name2,<<Name3", new string[] { "TED", "GEOFF", "BOB" });
    }

    private static void CheckParse(string input, string[] expected)
    {
        ParseArray parser = new ParseArray { Processor = Builder.CellProcessor() };

        Symbols sym = (Symbols)parser.Processor.Memory.GetItem("Symbols");
        sym.Save("Name1", "TED");
        sym.Save("Name2", "GEOFF");
        sym.Save("Name3", "BOB");
        Assert.IsTrue(parser.CanParse(typeof(string[]), TypedValue.Void, new CellTreeLeaf(input)));
        TypedValue result = parser.Parse(typeof(string[]), TypedValue.Void, new CellTreeLeaf(input));
        Assert.AreEqual(expected, result.Value);
    }
}

}

fixed release 2.4