-
Notifications
You must be signed in to change notification settings - Fork 13
/
UnitTest.ux
60 lines (54 loc) · 1.36 KB
/
UnitTest.ux
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
<App Theme="Basic">
<SQLite ux:Global="SQLite" />
<JavaScript>
var sqlite = require('SQLite');
var db = sqlite.open("file.sqlite");
function init_db () {
db.execute("create table if not exists ids (id integer primary key)");
}
function insert_loop () {
// This crashes on Android 0.10.1
// This also crashes on Fuse OSX Preview 0.10.1 when run twice
for (var i = 0; i < 300; i++) {
try {
db.execute("insert into ids values (?)", i);
}
catch (e) {
debug_log("Error with insert " + i);
}
}
}
var db_2;
function open_1 () {
if (db_2) {
debug_log("Closing");
db_2.close();
}
debug_log("Open bundle_2");
db_2 = sqlite.openFromBundle('bundle_2.sqlite');
debug_log(JSON.stringify(db_2.query("SELECT * FROM ids WHERE id < 10")));
}
function open_2 () {
if (db_2) {
debug_log("Closing");
db_2.close();
}
debug_log("Open bundle_3");
db_2 = sqlite.openFromBundle('bundle_3.sqlite');
debug_log(JSON.stringify(db_2.query("SELECT * FROM ids WHERE id < 10")));
}
init_db();
module.exports = {
test_1: insert_loop,
test_2: open_1,
test_3: open_2
}
</JavaScript>
<ClientPanel>
<StackPanel>
<Button Text="Insert Loop" Clicked="{test_1}" />
<Button Text="Open 1" Clicked="{test_2}" />
<Button Text="Open 2" Clicked="{test_3}" />
</StackPanel>
</ClientPanel>
</App>