-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
buffering.js
56 lines (47 loc) · 1.75 KB
/
buffering.js
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
//
// Test buffering for execution requests.
//
casper.notebook_test(function () {
this.then(function() {
// make sure there are at least three cells for the tests below.
this.append_cell();
this.append_cell();
this.append_cell();
})
this.thenEvaluate(function () {
IPython.notebook.kernel.stop_channels();
var cell = IPython.notebook.get_cell(0);
cell.set_text('a=10; print(a)');
IPython.notebook.execute_cells([0]);
IPython.notebook.kernel.reconnect(1);
});
this.wait_for_output(0);
this.then(function () {
var result = this.get_output_cell(0);
this.test.assertEquals(result.text, '10\n', 'kernels buffer messages if connection is down');
});
this.thenEvaluate(function () {
var cell = IPython.notebook.get_cell(0);
var cellplus = IPython.notebook.get_cell(1);
var cellprint = IPython.notebook.get_cell(2);
cell.set_text('k=1');
cellplus.set_text('k+=1');
cellprint.set_text('k*=2')
IPython.notebook.kernel.stop_channels();
// Repeated execution of cell queued up in the kernel executes
// each execution request in order.
IPython.notebook.execute_cells([0]);
IPython.notebook.execute_cells([2]);
IPython.notebook.execute_cells([1]);
IPython.notebook.execute_cells([1]);
IPython.notebook.execute_cells([1]);
cellprint.set_text('print(k)')
IPython.notebook.execute_cells([2]);
IPython.notebook.kernel.reconnect(1);
});
this.wait_for_output(2);
this.then(function () {
var result = this.get_output_cell(2);
this.test.assertEquals(result.text, '5\n', 'kernels send buffered messages in order');
});
});