forked from dotnet/interactive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NotebookTestScript.dib
152 lines (111 loc) · 2.81 KB
/
NotebookTestScript.dib
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!markdown
# Execute the following cell.
You'll notice a counter that appears and starts incrementing. After a second or two, stop the cell. Your output should look similar to:
```
5
Error: Comamnd cancelled
```
#!csharp
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive;
var output = string.Empty.Display("text/plain");
var counter = 1;
while (!KernelInvocationContext.Current.CancellationToken.IsCancellationRequested)
{
await Task.Delay(500, KernelInvocationContext.Current.CancellationToken);
output.Update($"{counter++}");
}
#!markdown
# Execute the next two cells.
#!csharp
var x = 123;
#!html
<div id="output"></div>
#!markdown
# Execute the next cell. After execution, the output immediately above this should read:
```
The value is 123.
```
#!javascript
const x = await interactive.csharp.getVariable("x");
document.getElementById("output").innerText = `The value is ${x}.`;
#!markdown
# Execute the next cell, the output should be displayed as JSON like so:
``` json
{"Name":"Developer","Salary":42}
```
#!csharp
display(new { Name = "Developer", Salary = 42 }, "application/json");
#!markdown
# Execute the next cell and verify the following error appears:
```
Error: input.fsx (1,11)-(1,12) parse error Unexpected token '+' or incomplete expression
```
#!fsharp
let x = 1 +
#!markdown
# Check this manual scenario:
1. `Ctrl+Shift+P` => ".NET Interactive: Create new blank notebook"
2. Select "Create as .dib"
3. Select "F#"
4. You should have a new empty notebook named something like "Untitled-1.dib" with a single cell of type "F# (Interactive)".
5. Set the cell contents to `1+1` and execute.
6. Verify output of `2`.
7. Save to disk.
8. Open that file in notepad.
9. The contents should look like this:
```
#!fsharp
1+1
```
#!markdown
# Execute the above scenario again with the following changes:
2. Select "Create as .ipynb"
4. File should be named something like "Untitled-1.ipynb".
(new steps)
9. The contents should look like this:
``` json
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"dotnet_interactive": {
"language": "fsharp"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div class=\"dni-plaintext\">2</div>"
]
},
"output_type": "unknown"
}
],
"source": [
"1+1"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".NET (F#)",
"language": "F#",
"name": ".net-fsharp"
},
"language_info": {
"name": "F#"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
```
#!markdown
# Open the two previously saved notebooks via the following:
1. `Ctrl+Shift+P` => ".NET Interactive: Open notebook"
2. Select the "Untitled-1.dib"/"Untitled-1.ipynb" from before.
3. Verify that it contains a single F# cell with the contents "1+1" and that it can execute.