Ejemplo n.º 1
0
        public void UserFunctions02()
        {
            var completionSets = new List <CompletionSet>();
            var content        =
                @"
aaa123 <- function(a,b,c) { }
while(TRUE) {
aaa456 <- function() { }
#
aa
}";

            RCompletionTestUtilities.GetCompletions(_services, content, content.IndexOf('#') + 4, completionSets);
            completionSets.Should().ContainSingle();
            completionSets[0].Completions.Should().BeEmpty();

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_services, content, content.IndexOf('#') + 5, completionSets);
            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            var completions = completionSets[0].Completions;

            completions.Should().NotBeEmpty();
            completions.Should().Contain(c => c.DisplayText == "aaa123");
            completions.Should().Contain(c => c.DisplayText == "aaa456");
        }
Ejemplo n.º 2
0
        public void FunctionDefinition01()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, "x <- function()", 14, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions.Should().BeEmpty();
        }
Ejemplo n.º 3
0
        public void SuppressedCompletion(string content, int position)
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, content, position, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions.Should().BeEmpty();
        }
Ejemplo n.º 4
0
        public void BeforeComment()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, "#No", 0, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions.Should().NotBeEmpty();
        }
        public void Datasets()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "m", 1, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions
            .Should().Contain(c => c.DisplayText == "mtcars");
        }
        public void BaseFunctions01()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "", 0, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions.Should().Contain(c => c.DisplayText == "abbreviate")
            .And.Contain(c => c.DisplayText == "abs");
        }
        public void RtvsPackage()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "rtv", 3, completionSets, new TextRange(0, 3));

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();
            completionSets[0].Completions[0].DisplayText.Should().Be("rtvs");
        }
        public void NoDuplicatesEntries()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "r", 1, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions
            .Should().ContainSingle(c => c.DisplayText == "require");
        }
        public void CaseSensitiveEntries()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "ma", 2, completionSets);

            completionSets.Should().ContainSingle()
            .Which.Completions.Should()
            .Contain(c => c.DisplayText == "matrix").And
            .Contain(c => c.DisplayText == "Matrix");
        }
Ejemplo n.º 10
0
        public void FunctionDefinition02()
        {
            for (int i = 14; i <= 18; i++)
            {
                var completionSets = new List <CompletionSet>();
                RCompletionTestUtilities.GetCompletions(_services, "x <- function(a, b)", i, completionSets);

                completionSets.Should().ContainSingle()
                .Which.Completions.Should().BeEmpty();
            }
        }
Ejemplo n.º 11
0
        public void Keywords01()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, "f", 1, completionSets, new TextRange(0, 1));

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().Contain(c => c.DisplayText == "for");
        }
Ejemplo n.º 12
0
        public void Packages01()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "lIbrAry(", 8, completionSets);

            completionSets.Should().ContainSingle();

            completionSets[0].Completions.Should().Contain(c => c.DisplayText == "base")
            .Which.Description.Should().Be("Base R functions.");
        }
Ejemplo n.º 13
0
        public void UserFunctionArgumentsNoBrace(string content, string expectedEntry)
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, content, 2, content.Length - content.IndexOfOrdinal("aaa("), completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == expectedEntry);
        }
Ejemplo n.º 14
0
        public void UserFunctions01()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(_services, "aaaa <- function(a,b,c)\r\na", 25, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaaa");
        }
Ejemplo n.º 15
0
        public void BaseFunctions02()
        {
            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(EditorShell, "FAC", 3, completionSets, new TextRange(0, 3));

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions[0].DisplayText.Should().Be("factanal");
            completionSets[0].Completions[1].DisplayText.Should().Be("factor");
        }
Ejemplo n.º 16
0
        public void UserVariables03()
        {
            var completionSets = new List <CompletionSet>();
            var content        =
                @"x123 <- 1
for(x456 in 1:10) x";

            RCompletionTestUtilities.GetCompletions(_services, content, 0, content.Length, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "x123")
            .And.Contain(c => c.DisplayText == "x456");
        }
Ejemplo n.º 17
0
        public async Task InternalExternal(string content, int position, string expectedEntry, string notExpectedEntry)
        {
            var packageName = await FunctionIndex.GetPackageNameAsync(expectedEntry);

            packageName.Should().NotBeNull();

            var completionSets = new List <CompletionSet>();

            RCompletionTestUtilities.GetCompletions(Services, content, position, completionSets);
            completionSets.Should().ContainSingle();

            var entries = completionSets[0].Completions.Select(c => c.DisplayText).ToList();

            entries.Should().Contain(expectedEntry);
            entries.Should().NotContain(notExpectedEntry);
        }
Ejemplo n.º 18
0
        public void UserFunctionArguments01()
        {
            var    completionSets = new List <CompletionSet>();
            string content        =
                @"
aaa <- function(a, b, c) { }
aaa(a
";

            RCompletionTestUtilities.GetCompletions(_services, content, 2, 5, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "a =");
        }
Ejemplo n.º 19
0
        public void UserVariables02()
        {
            var completionSets = new List <CompletionSet>();
            var content        =
                @"
{

    aaa123 <- 1

    1 -> bbb123

}
";

            RCompletionTestUtilities.GetCompletions(_services, content, 2, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.NotContain(c => c.DisplayText == "aaa123")
            .And.NotContain(c => c.DisplayText == "bbb123");

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_services, content, 4, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaa123")
            .And.NotContain(c => c.DisplayText == "bbb123");

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_services, content, 6, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaa123")
            .And.Contain(c => c.DisplayText == "bbb123");
        }
Ejemplo n.º 20
0
        public async Task InstallPackageTest()
        {
            await Workflow.RSession.EnsureHostStartedAsync(new RHostStartupInfo(), null, 50000);

            var completionSets = new List <CompletionSet>();

            for (int i = 0; i < 2; i++)
            {
                try {
                    await Workflow.Packages.UninstallPackageAsync("abc", null);

                    EventsPump.DoEvents(1000);
                } catch (RException) { }

                await PackageIndex.BuildIndexAsync();

                completionSets.Clear();
                RCompletionTestUtilities.GetCompletions(Services, "abc::", 5, completionSets);

                completionSets.Should().ContainSingle();
                // Try again one more time
                if (completionSets[0].Completions.Count == 0)
                {
                    break;
                }
            }
            completionSets[0].Completions.Should().BeEmpty();

            try {
                await Workflow.RSession.ExecuteAsync("install.packages('abc')", REvaluationKind.Mutating);

                EventsPump.DoEvents(1000);
            } catch (RException) { }

            await PackageIndex.BuildIndexAsync();

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(Services, "abc::", 5, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Completions.Should().NotBeEmpty();
        }
Ejemplo n.º 21
0
        public void FunctionDefinition03()
        {
            for (int i = 14; i <= 19; i++)
            {
                var completionSets = new List <CompletionSet>();
                RCompletionTestUtilities.GetCompletions(_editorShell, "x <- function(a, b = x+y)", i, completionSets);

                completionSets.Should().ContainSingle()
                .Which.Completions.Should().BeEmpty();
            }

            for (int i = 20; i <= 24; i++)
            {
                var completionSets = new List <CompletionSet>();
                RCompletionTestUtilities.GetCompletions(_editorShell, "x <- function(a, b = x+y)", i, completionSets);

                completionSets.Should().NotBeEmpty();
                completionSets[0].Completions.Should().NotBeEmpty();
            }
        }
Ejemplo n.º 22
0
        public void UserFunctions03()
        {
            var completionSets = new List <CompletionSet>();
            var content        =
                @"
aaa123 <- function(a,b,c) { }
while(TRUE) {

aa
aaa456 <- function() { }

aa
}
aaa789 = function(a,b,c) { }
";

            RCompletionTestUtilities.GetCompletions(_editorShell, content, 4, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            var completions = completionSets[0].Completions;

            completions.Should().NotBeEmpty();
            completions.Should().Contain(c => c.DisplayText == "aaa123");
            completions.Should().NotContain(c => c.DisplayText == "aaa456");
            completions.Should().Contain(c => c.DisplayText == "aaa789");

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_editorShell, content, 7, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completions = completionSets[0].Completions;
            completions.Should().NotBeEmpty();
            completions.Should().Contain(c => c.DisplayText == "aaa123");
            completions.Should().Contain(c => c.DisplayText == "aaa456");
            completions.Should().Contain(c => c.DisplayText == "aaa789");
        }
Ejemplo n.º 23
0
        public void UserVariables01()
        {
            var completionSets = new List <CompletionSet>();
            var content        =
                @"
aaa123 <- 1

bbb123 = 1

";

            RCompletionTestUtilities.GetCompletions(_editorShell, content, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaa123")
            .And.Contain(c => c.DisplayText == "bbb123");

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_editorShell, content, 2, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaa123")
            .And.Contain(c => c.DisplayText == "bbb123");

            completionSets.Clear();
            RCompletionTestUtilities.GetCompletions(_editorShell, content, 4, 0, completionSets);

            completionSets.Should().ContainSingle();
            completionSets[0].Filter();

            completionSets[0].Completions.Should().NotBeEmpty()
            .And.Contain(c => c.DisplayText == "aaa123")
            .And.Contain(c => c.DisplayText == "bbb123");
        }
Ejemplo n.º 24
0
        public async Task SpecificPackage(string content, int position, string expectedEntry, string expectedDescription, bool realHost)
        {
            var hostScript = realHost ? new RHostScript(Workflow.RSessions) : null;

            try {
                var info = await FunctionIndex.GetFunctionInfoAsync(expectedEntry);

                info.Should().NotBeNull();

                var completionSets = new List <CompletionSet>();
                RCompletionTestUtilities.GetCompletions(EditorShell, content, position, completionSets);

                completionSets.Should().ContainSingle();

                var entry = completionSets[0].Completions.FirstOrDefault(c => c.DisplayText == expectedEntry);
                entry.Should().NotBeNull();

                var description = entry.Description;
                description.Should().Contain(expectedDescription);
            } finally {
                hostScript?.Dispose();
            }
        }