-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
prompt_numbers.js
36 lines (31 loc) · 1.38 KB
/
prompt_numbers.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
// Test
casper.notebook_test(function () {
var that = this;
var set_prompt = function (i, val) {
that.evaluate(function (i, val) {
var cell = IPython.notebook.get_cell(i);
cell.set_input_prompt(val);
}, [i, val]);
};
var get_prompt = function (i) {
return that.evaluate(function (i) {
var elem = IPython.notebook.get_cell(i).element;
return elem.find('div.input_prompt').html();
}, [i]);
};
this.then(function () {
var a = 'print("a")';
var index = this.append_cell(a);
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [ ]:", "prompt number is by default");
set_prompt(index, 2);
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [2]:", "prompt number is 2");
set_prompt(index, 0);
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [0]:", "prompt number is 0");
set_prompt(index, "*");
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [*]:", "prompt number is *");
set_prompt(index, undefined);
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [ ]:", "prompt number is ");
set_prompt(index, null);
this.test.assertEquals(get_prompt(index), "<bdi>In</bdi> [ ]:", "prompt number is ");
});
});