Exemple #1
0
        public async Task StepOutFromGlobal()
        {
            const string code =
                @"x <- 1
  y <- 2";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);

                    var bp2 = await debugSession.CreateBreakpointAsync(sf, 2);

                    var bp1Hit = new BreakpointHitDetector(bp1);

                    await sf.Source(_session);

                    await bp1Hit.ShouldBeHitAtNextPromptAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { bp1.Location }
                    });

                    (await debugSession.StepOutAsync()).Should().Be(false);
                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { bp2.Location }
                    });
                }
        }
Exemple #2
0
        public async Task AddRemoveBreakpoint()
        {
            const string code =
                @"x <- 1
  y <- 2
  z <- 3";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    var bp1Loc = new DebugBreakpointLocation(sf.FilePath, 1);
                    var bp1    = await debugSession.CreateBreakpointAsync(bp1Loc);

                    bp1.Location.Should().Be(bp1Loc);
                    bp1.Session.Should().Be(debugSession);

                    debugSession.Breakpoints.Count.Should().Be(1);

                    var bp2Loc = new DebugBreakpointLocation(sf.FilePath, 3);
                    var bp2    = await debugSession.CreateBreakpointAsync(bp2Loc);

                    bp2.Location.Should().Be(bp2Loc);
                    bp2.Session.Should().Be(debugSession);

                    debugSession.Breakpoints.Count.Should().Be(2);

                    await bp1.DeleteAsync();

                    debugSession.Breakpoints.Count.Should().Be(1);
                    debugSession.Breakpoints.First().Should().BeSameAs(bp2);
                }
        }
Exemple #3
0
        public async Task StepOntoBreakpoint()
        {
            const string code =
                @"x <- 1
  y <- 2";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);

                    var bp2 = await debugSession.CreateBreakpointAsync(sf, 2);

                    var bp1Hit = new BreakpointHitDetector(bp1);
                    var bp2Hit = new BreakpointHitDetector(bp2);

                    await sf.Source(_session);

                    await bp1Hit.ShouldBeHitAtNextPromptAsync();

                    (await debugSession.StepOverAsync()).Should().Be(false);
                    await bp2Hit.ShouldBeHitAtNextPromptAsync();
                }
        }
Exemple #4
0
        public async Task AddRemoveBreakpoint() {
            const string code =
@"x <- 1
  y <- 2
  z <- 3";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                var bp1Loc = new DebugBreakpointLocation(sf.FilePath, 1);
                var bp1 = await debugSession.CreateBreakpointAsync(bp1Loc);

                bp1.Location.Should().Be(bp1Loc);
                bp1.Session.Should().Be(debugSession);

                debugSession.Breakpoints.Count.Should().Be(1);

                var bp2Loc = new DebugBreakpointLocation(sf.FilePath, 3);
                var bp2 = await debugSession.CreateBreakpointAsync(bp2Loc);

                bp2.Location.Should().Be(bp2Loc);
                bp2.Session.Should().Be(debugSession);

                debugSession.Breakpoints.Count.Should().Be(2);

                await bp1.DeleteAsync();
                debugSession.Breakpoints.Count.Should().Be(1);
                debugSession.Breakpoints.First().Should().BeSameAs(bp2);
            }

        }
Exemple #5
0
        public async Task OverlappingBreakpoints()
        {
            const string code =
                @"f <- function() {
    1
  }";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    await sf.Source(_session);

                    var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);

                    var bp2 = await debugSession.CreateBreakpointAsync(sf, 1);

                    bp1.Should().BeSameAs(bp2);
                    debugSession.Breakpoints.Should().HaveCount(1);

                    var bp1Hit = new BreakpointHitDetector(bp1);
                    var bp2Hit = new BreakpointHitDetector(bp2);

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f()\n");
                    }

                    await bp1Hit.ShouldBeHitAtNextPromptAsync();

                    bp2Hit.WasHit.Should().BeTrue();

                    await bp1.DeleteAsync();

                    debugSession.Breakpoints.Should().HaveCount(1);
                    debugSession.Breakpoints.Should().Contain(bp2);

                    await debugSession.ContinueAsync();

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f()\n");
                    }

                    await bp2Hit.ShouldBeHitAtNextPromptAsync();

                    await bp2.DeleteAsync();

                    debugSession.Breakpoints.Should().HaveCount(0);

                    await debugSession.ContinueAsync();

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f()\n");
                    }

                    using (var inter = await _session.BeginInteractionAsync()) {
                        inter.Contexts.IsBrowser().Should().BeFalse();
                    }
                }
        }
Exemple #6
0
        public async Task SetBreakpointWhileRunning()
        {
            const string code =
                @"browser()
  f <- function() {
    NULL
  }
  while (TRUE) f()";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    await sf.Source(_session);

                    await debugSession.NextPromptShouldBeBrowseAsync();

                    await debugSession.ContinueAsync();

                    await Task.Delay(100);

                    var bp = await debugSession.CreateBreakpointAsync(sf, 3);

                    await debugSession.NextPromptShouldBeBrowseAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { bp.Location }
                    });
                }
        }
Exemple #7
0
        public async Task StepOver() {
            const string code =
@"f <- function(x) {
    x + 1
  }
  x <- f(1)
  print(x)";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp = await debugSession.CreateBreakpointAsync(sf, 4);
                var bpHit = new BreakpointHitDetector(bp);

                await sf.Source(_session);
                await bpHit.ShouldBeHitAtNextPromptAsync();
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { bp.Location }
                });

                (await debugSession.StepOverAsync()).Should().Be(true);
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { bp.Location, +1 }
                });
            }
        }
Exemple #8
0
        public async Task StepOver()
        {
            const string code =
                @"f <- function(x) {
    x + 1
  }
  x <- f(1)
  print(x)";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp = await debugSession.CreateBreakpointAsync(sf, 4);

                    var bpHit = new BreakpointHitDetector(bp);

                    await sf.Source(_session);

                    await bpHit.ShouldBeHitAtNextPromptAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { bp.Location }
                    });

                    (await debugSession.StepOverAsync()).Should().Be(true);
                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { bp.Location, +1 }
                    });
                }
        }
Exemple #9
0
        public async Task CallStack()
        {
            using (var debugSession = new DebugSession(_session)) {
                const string code1 =
                    @"f <- function(n) {
     if (n > 0) {
        g(n - 1)
     } else {
        return()
     }
  }";

                const string code2 =
                    @"g <- function(n) {
     if (n > 0) {
        f(n - 1)
     } else {
        return()
     }
  }";

                using (var sf1 = new SourceFile(code1))
                    using (var sf2 = new SourceFile(code2)) {
                        await debugSession.EnableBreakpointsAsync(true);

                        await sf1.Source(_session);

                        await sf2.Source(_session);

                        var bp = await debugSession.CreateBreakpointAsync(sf1, 5);

                        var bpHit = new BreakpointHitDetector(bp);

                        using (var inter = await _session.BeginInteractionAsync()) {
                            await inter.RespondAsync("f(4)\n");
                        }
                        await bpHit.ShouldBeHitAtNextPromptAsync();

                        (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                            { (string)null, null, "f(4)" },
                            { sf1, 3, "g(n - 1)" },
                            { sf2, 3, "f(n - 1)" },
                            { sf1, 3, "g(n - 1)" },
                            { sf2, 3, "f(n - 1)" },
                            { sf1, 5, MatchAny <string> .Instance },
                        });
                    }
            }
        }
Exemple #10
0
        public async Task BreakpointsInDifferentFiles()
        {
            using (var debugSession = new DebugSession(_session))
                using (var sf1 = new SourceFile("1"))
                    using (var sf2 = new SourceFile($"eval(parse({sf1.FilePath.ToRStringLiteral()}))")) {
                        await debugSession.EnableBreakpointsAsync(true);

                        var bp1Loc = new DebugBreakpointLocation(sf1.FilePath, 1);
                        var bp1    = await debugSession.CreateBreakpointAsync(bp1Loc);

                        bp1.Location.Should().Be(bp1Loc);

                        var bp2Loc = new DebugBreakpointLocation(sf2.FilePath, 1);
                        var bp2    = await debugSession.CreateBreakpointAsync(bp2Loc);

                        bp2.Location.Should().Be(bp2Loc);

                        debugSession.Breakpoints.Should().HaveCount(2);

                        var bp1Hit = new BreakpointHitDetector(bp1);
                        var bp2Hit = new BreakpointHitDetector(bp2);

                        await sf2.Source(_session);

                        await bp2Hit.ShouldBeHitAtNextPromptAsync();

                        bp1Hit.WasHit.Should().BeFalse();

                        bp2Hit.Reset();
                        await debugSession.ContinueAsync();

                        await bp1Hit.ShouldBeHitAtNextPromptAsync();

                        bp2Hit.WasHit.Should().BeFalse();
                    }
        }
Exemple #11
0
        public async Task CallStack() {
            using (var debugSession = new DebugSession(_session)) {
                const string code1 =
@"f <- function(n) {
     if (n > 0) {
        g(n - 1)
     } else {
        return()
     }
  }";

                const string code2 =
@"g <- function(n) {
     if (n > 0) {
        f(n - 1)
     } else {
        return()
     }
  }";

                using (var sf1 = new SourceFile(code1))
                using (var sf2 = new SourceFile(code2)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    await sf1.Source(_session);
                    await sf2.Source(_session);

                    var bp = await debugSession.CreateBreakpointAsync(sf1, 5);
                    var bpHit = new BreakpointHitDetector(bp);

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f(4)\n");
                    }
                    await bpHit.ShouldBeHitAtNextPromptAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { (string)null, null, "f(4)" },
                        { sf1, 3, "g(n - 1)" },
                        { sf2, 3, "f(n - 1)" },
                        { sf1, 3, "g(n - 1)" },
                        { sf2, 3, "f(n - 1)" },
                        { sf1, 5, MatchAny<string>.Instance },
                    });
                }
            }
        }
Exemple #12
0
        public async Task SetBreakpointOnNull()
        {
            const string code =
                @"f <- function() {
    NULL
  }";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));

                    debugSession.Breakpoints.Count.Should().Be(1);

                    await sf.Source(_session);

                    var res = (await debugSession.EvaluateAsync("is.function(f)", DebugEvaluationResultFields.ReprDeparse)).As <DebugValueEvaluationResult>();
                    res.GetRepresentation().Deparse
                    .Should().Be("TRUE");
                }
        }
Exemple #13
0
        public async Task SetAndHitToplevelBreakpoint()
        {
            const string code =
                @"x <- 1
  y <- 2
  z <- 3";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));

                    var bpHit = new BreakpointHitDetector(bp);

                    await sf.Source(_session);

                    await bpHit.ShouldBeHitAtNextPromptAsync();
                }
        }
Exemple #14
0
        public async Task SetAndHitBreakpointInsideUnloadedFunction()
        {
            const string code =
                @"f <- function() {
    0
  }
  f()";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));

                    var bpHit = new BreakpointHitDetector(bp);

                    await sf.Source(_session);

                    await bpHit.ShouldBeHitAtNextPromptAsync();
                }
        }
Exemple #15
0
        public async Task RemoveBreakpointWhileRunning()
        {
            const string code =
                @"browser()
  f <- function() {
    NULL
    browser()
  }
  b <- FALSE;
  while (TRUE) if (b) f()";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    await sf.Source(_session);

                    await debugSession.NextPromptShouldBeBrowseAsync();

                    var bp = await debugSession.CreateBreakpointAsync(sf, 3);

                    int hitCount = 0;
                    bp.BreakpointHit += delegate { ++hitCount; };

                    await debugSession.ContinueAsync();

                    await Task.Delay(100);

                    await bp.DeleteAsync();

                    await _session.EvaluateAsync("b <- TRUE", REvaluationKind.Mutating);

                    await debugSession.NextPromptShouldBeBrowseAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { sf, 4 }
                    });
                    hitCount.Should().Be(0);
                }
        }
Exemple #16
0
        public async Task StepOutToFunction()
        {
            const string code =
                @"f <- function() {
    1
  }
  g <- function() {
    f()
    1
  }
  g()";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    var bp = await debugSession.CreateBreakpointAsync(sf, 2);

                    var bpHit = new BreakpointHitDetector(bp);

                    await sf.Source(_session);

                    await bpHit.ShouldBeHitAtNextPromptAsync();

                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { sf, 8, "g()" },
                        { sf, 5, "f()" },
                        { bp.Location },
                    });

                    (await debugSession.StepOutAsync()).Should().Be(true);
                    (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                        { sf, 8, "g()" },
                        { sf, 6, MatchAny <string> .Instance },
                    });
                }
        }
Exemple #17
0
        public async Task RemovedBreakpointNotHit()
        {
            const string code =
                @"f <- function() {
    0
  }";

            using (var debugSession = new DebugSession(_session))
                using (var sf = new SourceFile(code)) {
                    await debugSession.EnableBreakpointsAsync(true);

                    await sf.Source(_session);

                    var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));

                    var bpHit = new BreakpointHitDetector(bp);

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f()\n");
                    }

                    await bpHit.ShouldBeHitAtNextPromptAsync();

                    await bp.DeleteAsync();

                    await debugSession.ContinueAsync();

                    using (var inter = await _session.BeginInteractionAsync()) {
                        await inter.RespondAsync("f()\n");
                    }

                    using (var inter = await _session.BeginInteractionAsync()) {
                        inter.Contexts.IsBrowser().Should().BeFalse();
                    }
                }
        }
Exemple #18
0
        public async Task StepOutFromGlobal() {
            const string code =
@"x <- 1
  y <- 2";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);
                var bp2 = await debugSession.CreateBreakpointAsync(sf, 2);

                var bp1Hit = new BreakpointHitDetector(bp1);

                await sf.Source(_session);
                await bp1Hit.ShouldBeHitAtNextPromptAsync();
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { bp1.Location }
                });

                (await debugSession.StepOutAsync()).Should().Be(false);
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { bp2.Location }
                });
            }
        }
Exemple #19
0
        public async Task RemovedBreakpointNotHit() {
            const string code =
@"f <- function() {
    0
  }";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);
                await sf.Source(_session);

                var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));
                var bpHit = new BreakpointHitDetector(bp);

                using (var inter = await _session.BeginInteractionAsync()) {
                    await inter.RespondAsync("f()\n");
                }

                await bpHit.ShouldBeHitAtNextPromptAsync();

                await bp.DeleteAsync();
                await debugSession.ContinueAsync();

                using (var inter = await _session.BeginInteractionAsync()) {
                    await inter.RespondAsync("f()\n");
                }

                using (var inter = await _session.BeginInteractionAsync()) {
                    inter.Contexts.IsBrowser().Should().BeFalse();
                }
            }
        }
Exemple #20
0
        public async Task SetBreakpointOnNull() {
            const string code =
@"f <- function() {
    NULL
  }";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));
                debugSession.Breakpoints.Count.Should().Be(1);

                await sf.Source(_session);

                var res = (await debugSession.EvaluateAsync("is.function(f)")).As<DebugValueEvaluationResult>();
                res.GetRepresentation(DebugValueRepresentationKind.Normal).Deparse
                    .Should().Be("TRUE");
            }
        }
Exemple #21
0
        public async Task BreakpointsInDifferentFiles() {
            using (var debugSession = new DebugSession(_session))
            using (var sf1 = new SourceFile("1"))
            using (var sf2 = new SourceFile($"eval(parse({sf1.FilePath.ToRStringLiteral()}))")) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp1Loc = new DebugBreakpointLocation(sf1.FilePath, 1);
                var bp1 = await debugSession.CreateBreakpointAsync(bp1Loc);
                bp1.Location.Should().Be(bp1Loc);

                var bp2Loc = new DebugBreakpointLocation(sf2.FilePath, 1);
                var bp2 = await debugSession.CreateBreakpointAsync(bp2Loc);
                bp2.Location.Should().Be(bp2Loc);

                debugSession.Breakpoints.Should().HaveCount(2);

                var bp1Hit = new BreakpointHitDetector(bp1);
                var bp2Hit = new BreakpointHitDetector(bp2);

                await sf2.Source(_session);

                await bp2Hit.ShouldBeHitAtNextPromptAsync();
                bp1Hit.WasHit.Should().BeFalse();

                bp2Hit.Reset();
                await debugSession.ContinueAsync();

                await bp1Hit.ShouldBeHitAtNextPromptAsync();
                bp2Hit.WasHit.Should().BeFalse();
            }
        }
Exemple #22
0
        public async Task SetAndHitBreakpointInsideUnloadedFunction() {
            const string code =
@"f <- function() {
    0
  }
  f()";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));
                var bpHit = new BreakpointHitDetector(bp);

                await sf.Source(_session);
                await bpHit.ShouldBeHitAtNextPromptAsync();
            }
        }
Exemple #23
0
        public async Task OverlappingBreakpoints() {
            const string code =
@"f <- function() {
    1
  }";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);
                await sf.Source(_session);

                var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);
                var bp2 = await debugSession.CreateBreakpointAsync(sf, 1);

                bp1.Should().BeSameAs(bp2);
                debugSession.Breakpoints.Should().HaveCount(1);

                var bp1Hit = new BreakpointHitDetector(bp1);
                var bp2Hit = new BreakpointHitDetector(bp2);

                using (var inter = await _session.BeginInteractionAsync()) {
                    await inter.RespondAsync("f()\n");
                }

                await bp1Hit.ShouldBeHitAtNextPromptAsync();
                bp2Hit.WasHit.Should().BeTrue();

                await debugSession.ContinueAsync();

                await bp1.DeleteAsync();
                debugSession.Breakpoints.Should().HaveCount(1);
                debugSession.Breakpoints.Should().Contain(bp2);

                using (var inter = await _session.BeginInteractionAsync()) {
                    await inter.RespondAsync("f()\n");
                }

                await bp2Hit.ShouldBeHitAtNextPromptAsync();

                await debugSession.ContinueAsync();

                await bp2.DeleteAsync();
                debugSession.Breakpoints.Should().HaveCount(0);

                using (var inter = await _session.BeginInteractionAsync()) {
                    await inter.RespondAsync("f()\n");
                }

                using (var inter = await _session.BeginInteractionAsync()) {
                    inter.Contexts.IsBrowser().Should().BeFalse();
                }
            }
        }
        public async Task StepOutToGlobal() {
            const string code =
@"f <- function(x) {
    x + 1
  }
  x <- f(1)
  print(x)";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp = await debugSession.CreateBreakpointAsync(sf, 2);
                var bpHit = new BreakpointHitDetector(bp);

                await sf.Source(_session);
                await bpHit.ShouldBeHitAtNextPromptAsync();
                (await debugSession.GetStackFramesAsync()).Should().BeAt(bp.Location, "f(1)");

                (await debugSession.StepOutAsync()).Should().Be(true);
                (await debugSession.GetStackFramesAsync()).Should().BeAt(sf, 5);
            }
        }
        public async Task StepOntoBreakpoint() {
            const string code =
@"x <- 1
  y <- 2";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp1 = await debugSession.CreateBreakpointAsync(sf, 1);
                var bp2 = await debugSession.CreateBreakpointAsync(sf, 2);

                var bp1Hit = new BreakpointHitDetector(bp1);
                var bp2Hit = new BreakpointHitDetector(bp2);

                await sf.Source(_session);
                await bp1Hit.ShouldBeHitAtNextPromptAsync();

                (await debugSession.StepOverAsync()).Should().Be(false);
                await bp2Hit.ShouldBeHitAtNextPromptAsync();
            }
        }
Exemple #26
0
        public async Task StepOutToFunction() {
            const string code =
@"f <- function() {
    1
  }
  g <- function() {
    f()
    1
  }
  g()";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp = await debugSession.CreateBreakpointAsync(sf, 2);
                var bpHit = new BreakpointHitDetector(bp);

                await sf.Source(_session);
                await bpHit.ShouldBeHitAtNextPromptAsync();
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { sf, 8, "g()" },
                    { sf, 5, "f()" },
                    { bp.Location },
                });

                (await debugSession.StepOutAsync()).Should().Be(true);
                (await debugSession.GetStackFramesAsync()).Should().HaveTail(new MatchDebugStackFrames {
                    { sf, 8, "g()" },
                    { sf, 6, MatchAny<string>.Instance },
                });
            }
        }
 public static Task <DebugBreakpoint> CreateBreakpointAsync(this DebugSession session, SourceFile sf, int lineNumber)
 {
     return(session.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, lineNumber)));
 }
Exemple #28
0
        public async Task SetAndHitToplevelBreakpoint() {
            const string code =
@"x <- 1
  y <- 2
  z <- 3";

            using (var debugSession = new DebugSession(_session))
            using (var sf = new SourceFile(code)) {
                await debugSession.EnableBreakpointsAsync(true);

                var bp = await debugSession.CreateBreakpointAsync(new DebugBreakpointLocation(sf.FilePath, 2));
                var bpHit = new BreakpointHitDetector(bp);

                await sf.Source(_session);
                await bpHit.ShouldBeHitAtNextPromptAsync();
            }
        }