1
# Basic Hello world test plust testing arguments with and without name
2
SELECT JS("var foo = 'Hello'; foo + ', World';");
3
SELECT JS("var foo = 'Hello'; foo + ', ' + arguments[0];", "World");
4
SELECT JS("var foo = 'Hello'; foo + ', ' + bar;", "World" AS 'bar');
6
# Test all data types are passed correctly as arguments (string was handled above)
8
CREATE TABLE jstest (id INT PRIMARY KEY auto_increment, i INT, d DOUBLE, t TIMESTAMP, dt DATETIME);
10
INSERT INTO jstest VALUES (1, -5, 7.5, '2001-02-16 20:38:40', '2011-09-24 22:26:31');
11
SELECT JS("arguments[0] + 1", i) FROM jstest WHERE id=1;
12
SELECT JS("arguments[0] + 1.1", d) FROM jstest WHERE id=1;
13
SELECT JS("var d = arguments[0]; d.getUTCFullYear() + ' - ' + d.getUTCHours() + ' - ' + + d.getUTCSeconds();", t) FROM jstest WHERE id=1;
14
SELECT JS("var d = arguments[0]; d.getUTCDate() + ' - ' + d.getUTCHours() + ' - ' + d.getUTCMinutes();", dt) FROM jstest WHERE id=1;
17
SELECT JS("var num = arguments[0] + arguments[1]; arguments[2] + num;", i, d, "The sum is: ") FROM jstest WHERE id=1;
19
# And the JSON test, why all this was created in the first place
20
SELECT JS('var jsondoc = JSON.parse(arguments[0]); JSON.stringify(jsondoc["name"]["firstname"]);', '{ "name" : {"firstname" : "Henrik", "lastname" : "Ingo"} }');
24
# Make deliberate error
26
SELECT JS("this is not javascript");
28
# Why does this crash drizzletest?
31
# Make another connection and make sure we are handling multi-threaded mode correctly
32
# (V8 is single threaded only by default.)
33
connect (con2,localhost,test,jstest,mysql);
34
SELECT JS("var foo = 'Another'; foo + ' thread';");