-
Notifications
You must be signed in to change notification settings - Fork 656
/
test302.js
111 lines (94 loc) · 3.38 KB
/
test302.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
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
if (typeof exports === 'object') {
var assert = require('assert');
var alasql = require('..');
} else {
__dirname = '.';
}
describe('Test 302 CREATE CLASS ', function () {
it.skip('1. CREATE CLASS', function (done) {
alasql('CREATE DATABASE test302;USE test302');
done();
});
it.skip('2. CREATE CLASS', function (done) {
var res = alasql('CREATE CLASS Person');
assert(res == 1);
assert(alasql.databases.test302.tables.Person.isclass);
done();
});
var italy, rome, milano, romeo, paola, peter, berlin, germany;
it.skip('3. CREATE CLASS Country and City, INSERT data', function (done) {
alasql('CREATE CLASS Country');
italy = alasql('INSERT INTO Country VALUES {name:"Italy"}');
germany = alasql('INSERT INTO Country VALUES {name:"Germany"}');
alasql('CREATE CLASS City');
rome = alasql('INSERT INTO City VALUES {name:"Rome",country:' + italy + '}');
milano = alasql('INSERT INTO City VALUES {name:"Milano",country:' + italy + '}');
berlin = alasql('INSERT INTO City VALUES {name:"Berlin",country:' + germany + '}');
assert(alasql.databases.test302.tables.Person.isclass);
done();
});
it.skip('4. INSERT INTO CLASS', function (done) {
romeo = alasql('INSERT INTO Person VALUES {name:"Romeo",age:32, city:' + rome + '}');
paola = alasql('INSERT INTO Person VALUES {name:"Paola",age:25, city:' + milano + '}');
peter = alasql('INSERT INTO Person VALUES {name:"Peter",age:18, city:' + berlin + '}');
// assert(alasql.databases.test302.tables.Person.isclass);
done();
});
it.skip('5. SET variable = (INSERT)', function (done) {
alasql('SET @egypt = (INSERT INTO Country VALUES {name:"Egypt"})');
alasql('SET @cairo = (INSERT INTO City VALUES {name:"Cairo", country:(@egypt)})');
alasql('INSERT INTO Person VALUES {name:"Ali",city:(@cairo)}');
done();
});
it.skip('6. SELECT !', function (done) {
var res = alasql(
'SELECT COLUMN DISTINCT city!country!name AS country\
FROM Person ORDER BY country'
);
assert.deepEqual(res, ['Egypt', 'Germany', 'Italy']);
done();
});
it.skip('7. SEARCH #', function (done) {
var res = alasql('SEARCH DISTINCT(/ city!country!name) FROM Person');
assert.deepEqual(res.sort(), ['Egypt', 'Germany', 'Italy']);
done();
});
it.skip('8. SEARCH #', function (done) {
var res = alasql('SEARCH DISTINCT(/ :Person city!country!name)');
assert.deepEqual(res.sort(), ['Egypt', 'Germany', 'Italy']);
var res = alasql('SEARCH ALL(/ :Person city!country!name) DISTINCT()');
assert.deepEqual(res.sort(), ['Egypt', 'Germany', 'Italy']);
done();
});
it.skip('9. SEARCH AS', function (done) {
var res = alasql(
'search / city as @c ! where(name like "M%") ex({city:name,country:(@c!country!name)}) FROM Person'
);
assert.deepEqual(res, [{city: 'Milano', country: 'Italy'}]);
done();
});
it.skip('10. SEARCH TO', function (done) {
var res = alasql('search / city to @c ! ex({city:name,num:len(@c)}) FROM Person');
assert.deepEqual(res, [
{city: 'Rome', num: 1},
{city: 'Milano', num: 2},
{city: 'Berlin', num: 3},
{city: 'Cairo', num: 4},
]);
done();
});
it.skip('11. SEARCH EX JSON', function (done) {
var res = alasql('search / city to @c ! @[name,len(@c)] FROM Person');
assert.deepEqual(res, [
['Rome', 1],
['Milano', 2],
['Berlin', 3],
['Cairo', 4],
]);
done();
});
it.skip('99. DROP DATABASE', function (done) {
alasql('DROP DATABASE test302');
done();
});
});