mirror of https://gitee.com/bigwinds/arangodb
added AQL function TO_LIST
This commit is contained in:
parent
442627c95f
commit
2bf74c48c5
|
@ -1,7 +1,9 @@
|
|||
v1.0.1 (2012-09-30)
|
||||
-------------------
|
||||
|
||||
* darft for issue #165: front-end application howto
|
||||
* added AQL function TO_LIST
|
||||
|
||||
* draft for issue #165: front-end application howto
|
||||
|
||||
* updated mruby to cf8fdea4a6598aa470e698e8cbc9b9b492319d
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@ TRI_associative_pointer_t* TRI_InitialiseFunctionsAql (void) {
|
|||
REGISTER_FUNCTION("TO_NUMBER", "CAST_NUMBER", true, false, ".");
|
||||
REGISTER_FUNCTION("TO_STRING", "CAST_STRING", true, false, ".");
|
||||
REGISTER_FUNCTION("TO_BOOL", "CAST_BOOL", true, false, ".");
|
||||
REGISTER_FUNCTION("TO_LIST", "CAST_LIST", true, false, ".");
|
||||
|
||||
// string functions
|
||||
REGISTER_FUNCTION("CONCAT", "STRING_CONCAT", true, false, "sz,sz|+");
|
||||
|
@ -409,6 +410,7 @@ TRI_associative_pointer_t* TRI_InitialiseFunctionsAql (void) {
|
|||
REGISTER_FUNCTION("PASSTHRU", "PASSTHRU", false, false, "."); // simple non-deterministic wrapper to avoid optimisations at parse time
|
||||
REGISTER_FUNCTION("COLLECTIONS", "COLLECTIONS", false, false, "");
|
||||
REGISTER_FUNCTION("NOT_NULL", "NOT_NULL", true, false, ".,.");
|
||||
REGISTER_FUNCTION("NOT_LIST", "NOT_LIST", true, false, ".,.");
|
||||
|
||||
if (!result) {
|
||||
TRI_FreeFunctionsAql(functions);
|
||||
|
|
|
@ -254,6 +254,22 @@ function AHUACATL_TYPEWEIGHT (value) {
|
|||
return AHUACATL_TYPEWEIGHT_NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the values of an object in the order that they are defined
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AHUACATL_VALUES (value) {
|
||||
var values = [];
|
||||
|
||||
for (var k in value) {
|
||||
if (value.hasOwnProperty(k)) {
|
||||
values.push(value[k]);
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get the keys of an array or object in a comparable way
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1389,6 +1405,27 @@ function AHUACATL_CAST_STRING (value) {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief cast to a list
|
||||
///
|
||||
/// the operand can have any type, always returns a list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AHUACATL_CAST_LIST (value) {
|
||||
switch (AHUACATL_TYPEWEIGHT(value)) {
|
||||
case AHUACATL_TYPEWEIGHT_LIST:
|
||||
return value;
|
||||
case AHUACATL_TYPEWEIGHT_NULL:
|
||||
return [ ];
|
||||
case AHUACATL_TYPEWEIGHT_BOOL:
|
||||
case AHUACATL_TYPEWEIGHT_NUMBER:
|
||||
case AHUACATL_TYPEWEIGHT_STRING:
|
||||
return [ value ];
|
||||
case AHUACATL_TYPEWEIGHT_DOCUMENT:
|
||||
return AHUACATL_VALUES(value);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2076,7 +2113,21 @@ function AHUACATL_NOT_NULL (value, alternative) {
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether a document has an attribute
|
||||
/// @brief return value if it's a list, otherwise return alternative
|
||||
///
|
||||
/// the operands can have any type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AHUACATL_NOT_LIST (value, alternative) {
|
||||
if (AHUACATL_TYPEWEIGHT(value) === AHUACATL_TYPEWEIGHT_LIST) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return alternative;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief check whether a document has a specific attribute
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function AHUACATL_HAS () {
|
||||
|
|
|
@ -256,6 +256,22 @@ static string JS_server_ahuacatl =
|
|||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief get the values of an object in the order that they are defined\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"function AHUACATL_VALUES (value) {\n"
|
||||
" var values = [];\n"
|
||||
" \n"
|
||||
" for (var k in value) {\n"
|
||||
" if (value.hasOwnProperty(k)) {\n"
|
||||
" values.push(value[k]);\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" return values;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief get the keys of an array or object in a comparable way\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
|
@ -1464,6 +1480,27 @@ static string JS_server_ahuacatl =
|
|||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief cast to a list\n"
|
||||
"///\n"
|
||||
"/// the operand can have any type, always returns a list\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"function AHUACATL_CAST_LIST (value) {\n"
|
||||
" switch (AHUACATL_TYPEWEIGHT(value)) {\n"
|
||||
" case AHUACATL_TYPEWEIGHT_LIST:\n"
|
||||
" return value;\n"
|
||||
" case AHUACATL_TYPEWEIGHT_NULL:\n"
|
||||
" return [ ];\n"
|
||||
" case AHUACATL_TYPEWEIGHT_BOOL:\n"
|
||||
" case AHUACATL_TYPEWEIGHT_NUMBER:\n"
|
||||
" case AHUACATL_TYPEWEIGHT_STRING:\n"
|
||||
" return [ value ];\n"
|
||||
" case AHUACATL_TYPEWEIGHT_DOCUMENT:\n"
|
||||
" return AHUACATL_VALUES(value);\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @}\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
|
@ -2077,7 +2114,21 @@ static string JS_server_ahuacatl =
|
|||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief check whether a document has an attribute\n"
|
||||
"/// @brief return value if it's a list, otherwise return alternative\n"
|
||||
"///\n"
|
||||
"/// the operands can have any type\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"function AHUACATL_NOT_LIST (value, alternative) {\n"
|
||||
" if (AHUACATL_TYPEWEIGHT(value) === AHUACATL_TYPEWEIGHT_LIST) {\n"
|
||||
" return value;\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" return alternative;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"/// @brief check whether a document has a specific attribute\n"
|
||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||
"\n"
|
||||
"function AHUACATL_HAS () {\n"
|
||||
|
|
|
@ -1105,6 +1105,566 @@ function ahuacatlFunctionsTestSuite () {
|
|||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList1 : function () {
|
||||
var expected = [ [ 1, 2 ] ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST(null, [ 1, 2 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList2 : function () {
|
||||
var expected = [ "not a list!" ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST(null, \"not a list!\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList3 : function () {
|
||||
var expected = [ [ 1, 4 ] ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST([ 1, 4 ], [ 1, 5 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList4 : function () {
|
||||
var expected = [ [ ] ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST([ ], [ 1, 5 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList5 : function () {
|
||||
var expected = [ [ false ] ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST([ false ], [ 1, 5 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test not_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testNotList6 : function () {
|
||||
var expected = [ 7 ];
|
||||
var actual = getQueryResults("RETURN NOT_LIST(false, 7)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool1 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(null)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool2 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(false)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool3 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(true)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool4 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(0)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool5 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(0.1)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool6 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(-1)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool7 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(100)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool8 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(\"\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool9 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(\" \")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool10 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(\"0\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool11 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL(\"false\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool12 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool13 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ 1 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool14 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ false ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool15 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ 0 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool16 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ \"\" ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool17 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ \" \" ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool18 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ \"0\" ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool19 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ \"false\" ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool20 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL([ { } ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool21 : function () {
|
||||
var expected = [ false ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL({ })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool22 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL({ \"0\" : \"\" })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_bool
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToBool23 : function () {
|
||||
var expected = [ true ];
|
||||
var actual = getQueryResults("RETURN TO_BOOL({ \"false\" : null })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber1 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(null)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber2 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER([ ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber3 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER([ 1 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber4 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER([ -1, 1 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber5 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER({ })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber6 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER({ \"2\" : \"3\" })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber7 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(false)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber8 : function () {
|
||||
var expected = [ 1 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(true)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber9 : function () {
|
||||
var expected = [ 1 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\"1\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber10 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\"0\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber11 : function () {
|
||||
var expected = [ -435.3 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\"-435.3\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber12 : function () {
|
||||
var expected = [ 3553.4 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\"3553.4er6\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber13 : function () {
|
||||
var expected = [ 0 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\"-wert324\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber14 : function () {
|
||||
var expected = [ 143 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\" 143\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToNumber15 : function () {
|
||||
var expected = [ 0.4 ];
|
||||
var actual = getQueryResults("RETURN TO_NUMBER(\" .4\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList1 : function () {
|
||||
var expected = [ [ ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(null)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList2 : function () {
|
||||
var expected = [ [ false ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(false)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList3 : function () {
|
||||
var expected = [ [ true ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(true)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList4 : function () {
|
||||
var expected = [ [ 35 ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(35)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList5 : function () {
|
||||
var expected = [ [ -0.635 ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(-0.635)", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList6 : function () {
|
||||
var expected = [ [ "" ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(\"\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList7 : function () {
|
||||
var expected = [ [ "value" ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST(\"value\")", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList8 : function () {
|
||||
var expected = [ [ ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST({ })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList9 : function () {
|
||||
var expected = [ [ 0 ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST({ \"a\" : 0 })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList10 : function () {
|
||||
var expected = [ [ null, -63, [ 1, 2 ], { "a" : "b" } ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST({ \"a\" : null, \"b\" : -63, \"c\" : [ 1, 2 ], \"d\": { \"a\" : \"b\" } })", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList11 : function () {
|
||||
var expected = [ [ ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST([ ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test to_list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testToList12 : function () {
|
||||
var expected = [ [ 0, null, -1 ] ];
|
||||
var actual = getQueryResults("RETURN TO_LIST([ 0, null, -1 ])", true);
|
||||
assertEqual(expected, actual);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test non-existing functions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue