~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/js/tests/t/js.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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');
 
5
 
 
6
# Test all data types are passed correctly as arguments (string was handled above)
 
7
 
 
8
CREATE TABLE jstest (id INT PRIMARY KEY auto_increment, i INT, d DOUBLE, t TIMESTAMP, dt DATETIME);
 
9
 
 
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;
 
15
 
 
16
# Test combinations
 
17
SELECT JS("var num = arguments[0] + arguments[1]; arguments[2] + num;", i, d, "The sum is: ") FROM jstest WHERE id=1;
 
18
 
 
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"} }');
 
21
 
 
22
DROP TABLE jstest;
 
23
 
 
24
# Make deliberate error
 
25
--error ER_SCRIPT
 
26
SELECT JS("this is not javascript");
 
27
 
 
28
# Why does this crash drizzletest?
 
29
# SHOW ERRORS;
 
30
 
 
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';");
 
35
disconnect con2;