-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tracking std out prints #343
Changes from 4 commits
51827f1
2e5a772
f44251d
117ee6c
24e4b9f
3d4dcdf
99be41c
03f2fe1
67aba14
69fd2d7
a5be738
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ public async Task it_returns_the_result_of_a_non_null_expression() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("123", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("123")); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Last() | ||
|
@@ -44,9 +44,9 @@ public async Task when_it_throws_exception_after_a_value_was_produced_then_only_ | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("using System;", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("2 + 2", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("adddddddddd", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("using System;")); | ||
await kernel.SendAsync(new SubmitCode("2 + 2")); | ||
await kernel.SendAsync(new SubmitCode("adddddddddd")); | ||
|
||
var (failure, lastCodeSubmissionEvaluationFailedPosition) = KernelEvents | ||
.Select((error, pos) => (error, pos)) | ||
|
@@ -75,8 +75,8 @@ public async Task it_returns_exceptions_thrown_in_user_code() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("using System;", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("throw new NotImplementedException();", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("using System;")); | ||
await kernel.SendAsync(new SubmitCode("throw new NotImplementedException();")); | ||
|
||
KernelEvents.Last() | ||
.Should() | ||
|
@@ -92,8 +92,8 @@ public async Task it_returns_diagnostics() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("using System;", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("aaaadd", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("using System;")); | ||
await kernel.SendAsync(new SubmitCode("aaaadd")); | ||
|
||
KernelEvents.Last() | ||
.Should() | ||
|
@@ -109,9 +109,9 @@ public async Task it_notifies_when_submission_is_complete() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("var a =", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("var a =")); | ||
|
||
await kernel.SendAsync(new SubmitCode("12;", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("12;")); | ||
|
||
KernelEvents.Should() | ||
.NotContain(e => e is ValueProduced); | ||
|
@@ -126,7 +126,7 @@ public async Task it_notifies_when_submission_is_incomplete() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("var a =", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("var a =")); | ||
|
||
KernelEvents.Should() | ||
.NotContain(e => e is ValueProduced); | ||
|
@@ -141,7 +141,7 @@ public async Task it_returns_the_result_of_a_null_expression() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("null", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("null")); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Last() | ||
|
@@ -155,7 +155,7 @@ public async Task it_does_not_return_a_result_for_a_statement() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("var x = 1;", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("var x = 1;")); | ||
|
||
KernelEvents | ||
.Should() | ||
|
@@ -167,9 +167,9 @@ public async Task it_aggregates_multiple_submissions() | |
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("var x = new List<int>{1,2};", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("x.Add(3);", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("x.Max()", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("var x = new List<int>{1,2};")); | ||
await kernel.SendAsync(new SubmitCode("x.Add(3);")); | ||
await kernel.SendAsync(new SubmitCode("x.Max()")); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Last() | ||
|
@@ -178,13 +178,52 @@ public async Task it_aggregates_multiple_submissions() | |
.Be(3); | ||
} | ||
|
||
[Fact] | ||
public async Task it_produces_values_when_executing_Console_output() | ||
{ | ||
var kernel = CreateKernel(); | ||
|
||
var kernelCommand = new SubmitCode(@" | ||
Console.Write(""value one""); | ||
Console.Write(""value two""); | ||
Console.Write(""value three"");"); | ||
await kernel.SendAsync(kernelCommand); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Should() | ||
.BeEquivalentTo( | ||
new ValueProduced("value one", kernelCommand, false, new[] { new FormattedValue(null, "value one"), }), | ||
new ValueProduced("value two", kernelCommand, false, new[] { new FormattedValue(null, "value two"), }), | ||
new ValueProduced("value three", kernelCommand, false, new[] { new FormattedValue(null, "value three"), })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why no mime type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. myme types are done later on when formatting on raw value is done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. null value is generated by the Formatter.MimeTypeFor method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's the right behavior. |
||
} | ||
|
||
[Fact] | ||
public async Task it_produces_a_final_value_if_the_code_expression_evaluates() | ||
{ | ||
var kernel = CreateKernel(); | ||
|
||
var kernelCommand = new SubmitCode(@" | ||
Console.Write(""value one""); | ||
Console.Write(""value two""); | ||
Console.Write(""value three""); | ||
5", "csharp"); | ||
colombod marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await kernel.SendAsync(kernelCommand); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Should() | ||
.HaveCount(4) | ||
.And | ||
.ContainSingle(e => e.IsLastValue); | ||
|
||
} | ||
|
||
[Fact(Skip = "requires support for cs8 in roslyn scripting")] | ||
public async Task it_supports_csharp_8() | ||
{ | ||
var kernel = CreateKernel(); | ||
|
||
await kernel.SendAsync(new SubmitCode("var text = \"meow? meow!\";", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("text[^5..^0]", "csharp")); | ||
await kernel.SendAsync(new SubmitCode("var text = \"meow? meow!\";")); | ||
await kernel.SendAsync(new SubmitCode("text[^5..^0]")); | ||
|
||
KernelEvents.OfType<ValueProduced>() | ||
.Last() | ||
|
@@ -280,7 +319,7 @@ await kernel.SendAsync( | |
.Should() | ||
.Contain(i => i.DisplayText == "SerializeObject"); | ||
} | ||
|
||
[Fact] | ||
public async Task The_extend_directive_can_be_used_to_load_a_kernel_extension() | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should no longer need a fallback here.