From febaff613993706026ff657205f2c13716be1ee1 Mon Sep 17 00:00:00 2001 From: Achim Brandt Date: Tue, 24 Apr 2012 13:09:24 +0200 Subject: [PATCH 01/13] bugfix wrong _outputBuffer.clear() --- V8Client/ImportHelper.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/V8Client/ImportHelper.cpp b/V8Client/ImportHelper.cpp index 38d1fc5702..d84ff5dbd3 100644 --- a/V8Client/ImportHelper.cpp +++ b/V8Client/ImportHelper.cpp @@ -346,8 +346,6 @@ namespace triagens { SimpleHttpResult* result = _client->request(SimpleHttpClient::POST, "/_api/import?type=documents&collection=" + StringUtils::urlEncode(_collectionName), str, len, headerFields); handleResult(result); - - _outputBuffer.clear(); } void ImportHelper::handleResult (SimpleHttpResult* result) { From 84215f1228fecedc9a1596f67ca87653fd3ae6f9 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 13:45:08 +0200 Subject: [PATCH 02/13] added tests for Ahuacatl --- Makefile.in | 3 +- Makefile.unittests | 3 +- js/server/ahuacatl.js | 86 +- js/server/js-ahuacatl.h | 86 +- js/server/tests/ahuacatl-operators.js | 4031 +++++++++++++++++++++++++ 5 files changed, 4191 insertions(+), 18 deletions(-) create mode 100644 js/server/tests/ahuacatl-operators.js diff --git a/Makefile.in b/Makefile.in index 1c1682c9fd..cd163d97b6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1009,7 +1009,8 @@ UNITTESTS_SERVER = $(addprefix --unit-tests ,$(SHELL_SERVER)) ################################################################################ ################################################################################ -SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ +SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js UNITTESTS_SERVER_AHUACATL = $(addprefix --unit-tests ,$(SHELL_SERVER_AHUACATL)) diff --git a/Makefile.unittests b/Makefile.unittests index ff7cdb7154..0629a21029 100644 --- a/Makefile.unittests +++ b/Makefile.unittests @@ -153,7 +153,8 @@ unittests-shell-server: ## SHELL SERVER TESTS (AHUACATL) ################################################################################ -SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ +SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js index f43ca33c72..c348b02301 100644 --- a/js/server/ahuacatl.js +++ b/js/server/ahuacatl.js @@ -350,6 +350,13 @@ function AHUACATL_RELATIONAL_EQUAL (lhs, rhs) { } // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + return (lhs === rhs); } @@ -397,6 +404,13 @@ function AHUACATL_RELATIONAL_UNEQUAL (lhs, rhs) { } // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + return (lhs !== rhs); } @@ -453,6 +467,13 @@ function AHUACATL_RELATIONAL_GREATER_REC (lhs, rhs) { } // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + if (lhs === rhs) { return null; } @@ -528,6 +549,13 @@ function AHUACATL_RELATIONAL_GREATEREQUAL_REC (lhs, rhs) { } // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + if (lhs === rhs) { return null; } @@ -604,6 +632,13 @@ function AHUACATL_RELATIONAL_LESS_REC (lhs, rhs) { } // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + if (lhs === rhs) { return null; } @@ -677,11 +712,18 @@ function AHUACATL_RELATIONAL_LESSEQUAL_REC (lhs, rhs) { return null; } + // primitive type + if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) { + lhs = null; + } + if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) { + rhs = null; + } + if (lhs === rhs) { return null; } - // primitive type return (lhs <= rhs); } @@ -752,7 +794,11 @@ function AHUACATL_UNARY_PLUS (value) { throw "expecting number for unary plus"; } - return AHUACATL_NUMERIC_VALUE(value); + var result = AHUACATL_NUMERIC_VALUE(value); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -766,7 +812,11 @@ function AHUACATL_UNARY_MINUS (value) { throw "expecting number for unary minus"; } - return AHUACATL_NUMERIC_VALUE(-value); + var result = AHUACATL_NUMERIC_VALUE(-value); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -781,7 +831,11 @@ function AHUACATL_ARITHMETIC_PLUS (lhs, rhs) { throw "expecting numbers for plus"; } - return AHUACATL_NUMERIC_VALUE(lhs + rhs); + var result = AHUACATL_NUMERIC_VALUE(lhs + rhs); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -796,7 +850,11 @@ function AHUACATL_ARITHMETIC_MINUS (lhs, rhs) { throw "expecting numbers for minus"; } - return AHUACATL_NUMERIC_VALUE(lhs - rhs); + var result = AHUACATL_NUMERIC_VALUE(lhs - rhs); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -811,7 +869,11 @@ function AHUACATL_ARITHMETIC_TIMES (lhs, rhs) { throw "expecting numbers for times"; } - return AHUACATL_NUMERIC_VALUE(lhs * rhs); + var result = AHUACATL_NUMERIC_VALUE(lhs * rhs); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -830,7 +892,11 @@ function AHUACATL_ARITHMETIC_DIVIDE (lhs, rhs) { throw "division by zero"; } - return AHUACATL_NUMERIC_VALUE(lhs / rhs); + var result = AHUACATL_NUMERIC_VALUE(lhs / rhs); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -849,7 +915,11 @@ function AHUACATL_ARITHMETIC_MODULUS (lhs, rhs) { throw "division by zero"; } - return AHUACATL_NUMERIC_VALUE(lhs % rhs); + var result = AHUACATL_NUMERIC_VALUE(lhs % rhs); + if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) { + throw "number out of range"; + } + return result; } //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h index 9528f32191..23c388c478 100644 --- a/js/server/js-ahuacatl.h +++ b/js/server/js-ahuacatl.h @@ -351,6 +351,13 @@ static string JS_server_ahuacatl = " }\n" "\n" " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + "\n" " return (lhs === rhs);\n" "}\n" "\n" @@ -398,6 +405,13 @@ static string JS_server_ahuacatl = " }\n" "\n" " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + "\n" " return (lhs !== rhs);\n" "}\n" "\n" @@ -454,6 +468,13 @@ static string JS_server_ahuacatl = " }\n" "\n" " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + "\n" " if (lhs === rhs) {\n" " return null;\n" " }\n" @@ -529,6 +550,13 @@ static string JS_server_ahuacatl = " }\n" "\n" " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + "\n" " if (lhs === rhs) {\n" " return null;\n" " }\n" @@ -605,6 +633,13 @@ static string JS_server_ahuacatl = " }\n" "\n" " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + "\n" " if (lhs === rhs) {\n" " return null;\n" " }\n" @@ -678,11 +713,18 @@ static string JS_server_ahuacatl = " return null;\n" " }\n" " \n" + " // primitive type\n" + " if (AHUACATL_TYPEWEIGHT(lhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " lhs = null;\n" + " }\n" + " if (AHUACATL_TYPEWEIGHT(rhs) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " rhs = null;\n" + " }\n" + " \n" " if (lhs === rhs) {\n" " return null;\n" " }\n" "\n" - " // primitive type\n" " return (lhs <= rhs);\n" "}\n" "\n" @@ -753,7 +795,11 @@ static string JS_server_ahuacatl = " throw \"expecting number for unary plus\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(value);\n" + " var result = AHUACATL_NUMERIC_VALUE(value);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -767,7 +813,11 @@ static string JS_server_ahuacatl = " throw \"expecting number for unary minus\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(-value);\n" + " var result = AHUACATL_NUMERIC_VALUE(-value);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -782,7 +832,11 @@ static string JS_server_ahuacatl = " throw \"expecting numbers for plus\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(lhs + rhs);\n" + " var result = AHUACATL_NUMERIC_VALUE(lhs + rhs);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -797,7 +851,11 @@ static string JS_server_ahuacatl = " throw \"expecting numbers for minus\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(lhs - rhs);\n" + " var result = AHUACATL_NUMERIC_VALUE(lhs - rhs);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -812,7 +870,11 @@ static string JS_server_ahuacatl = " throw \"expecting numbers for times\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(lhs * rhs);\n" + " var result = AHUACATL_NUMERIC_VALUE(lhs * rhs);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -831,7 +893,11 @@ static string JS_server_ahuacatl = " throw \"division by zero\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(lhs / rhs);\n" + " var result = AHUACATL_NUMERIC_VALUE(lhs / rhs);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -850,7 +916,11 @@ static string JS_server_ahuacatl = " throw \"division by zero\";\n" " }\n" "\n" - " return AHUACATL_NUMERIC_VALUE(lhs % rhs);\n" + " var result = AHUACATL_NUMERIC_VALUE(lhs % rhs);\n" + " if (AHUACATL_TYPEWEIGHT(result) !== AHUACATL_TYPEWEIGHT_NUMBER) {\n" + " throw \"number out of range\";\n" + " }\n" + " return result;\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" diff --git a/js/server/tests/ahuacatl-operators.js b/js/server/tests/ahuacatl-operators.js new file mode 100644 index 0000000000..f3e2c7e298 --- /dev/null +++ b/js/server/tests/ahuacatl-operators.js @@ -0,0 +1,4031 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for query language, operators +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +var jsunity = require("jsunity"); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +//////////////////////////////////////////////////////////////////////////////// + +function ahuacatlOperatorsTestSuite () { + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tear down +//////////////////////////////////////////////////////////////////////////////// + + tearDown : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_KEYS function +//////////////////////////////////////////////////////////////////////////////// + + testKeys : function () { + assertEqual([ ], AHUACATL_KEYS([ ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ 0, 1, 2 ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ 1, 2, 3 ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ 5, 6, 9 ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ false, false, false ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ -1, -1, 'zang' ])); + assertEqual([ 0, 1, 2, 3 ], AHUACATL_KEYS([ 99, 99, 99, 99 ])); + assertEqual([ 0 ], AHUACATL_KEYS([ [ ] ])); + assertEqual([ 0 ], AHUACATL_KEYS([ [ 1 ] ])); + assertEqual([ 0, 1 ], AHUACATL_KEYS([ [ 1 ], 1 ])); + assertEqual([ 0, 1 ], AHUACATL_KEYS([ [ 1 ], [ 1 ] ])); + assertEqual([ 0 ], AHUACATL_KEYS([ [ 1 , 2 ] ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ [ 1 , 2 ], [ ], 3 ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ { }, { }, { } ])); + assertEqual([ 0, 1, 2 ], AHUACATL_KEYS([ { 'a' : true, 'b' : false }, { }, { } ])); + assertEqual([ ], AHUACATL_KEYS({ })); + assertEqual([ '0' ], AHUACATL_KEYS({ '0' : false })); + assertEqual([ '0' ], AHUACATL_KEYS({ '0' : undefined })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'a' : true, 'b' : true, 'c' : true })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'a' : true, 'c' : true, 'b' : true })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'b' : true, 'a' : true, 'c' : true })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'b' : true, 'c' : true, 'a' : true })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'c' : true, 'a' : true, 'b' : true })); + assertEqual([ 'a', 'b', 'c' ], AHUACATL_KEYS({ 'c' : true, 'b' : true, 'a' : true })); + assertEqual([ '0', '1', '2' ], AHUACATL_KEYS({ '0' : true, '1' : true, '2' : true })); + assertEqual([ '0', '1', '2' ], AHUACATL_KEYS({ '1' : true, '2' : true, '0' : true })); + assertEqual([ 'a1', 'a2', 'a3' ], AHUACATL_KEYS({ 'a1' : true, 'a2' : true, 'a3' : true })); + assertEqual([ 'a1', 'a10', 'a20', 'a200', 'a21' ], AHUACATL_KEYS({ 'a200' : true, 'a21' : true, 'a20' : true, 'a10' : false, 'a1' : null })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_NULL function +//////////////////////////////////////////////////////////////////////////////// + + testIsNullTrue : function () { + assertTrue(AHUACATL_IS_NULL(null)); + assertTrue(AHUACATL_IS_NULL(undefined)); + assertTrue(AHUACATL_IS_NULL(NaN)); + assertTrue(AHUACATL_IS_NULL(1.3e308 * 1.3e308)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_NULL function +//////////////////////////////////////////////////////////////////////////////// + + testIsNullFalse : function () { + assertFalse(AHUACATL_IS_NULL(0)); + assertFalse(AHUACATL_IS_NULL(1)); + assertFalse(AHUACATL_IS_NULL(-1)); + assertFalse(AHUACATL_IS_NULL(0.1)); + assertFalse(AHUACATL_IS_NULL(-0.1)); + assertFalse(AHUACATL_IS_NULL(false)); + assertFalse(AHUACATL_IS_NULL(true)); + assertFalse(AHUACATL_IS_NULL('abc')); + assertFalse(AHUACATL_IS_NULL('null')); + assertFalse(AHUACATL_IS_NULL('false')); + assertFalse(AHUACATL_IS_NULL('undefined')); + assertFalse(AHUACATL_IS_NULL('')); + assertFalse(AHUACATL_IS_NULL(' ')); + assertFalse(AHUACATL_IS_NULL([ ])); + assertFalse(AHUACATL_IS_NULL([ 0 ])); + assertFalse(AHUACATL_IS_NULL([ 0, 1 ])); + assertFalse(AHUACATL_IS_NULL([ 1, 2 ])); + assertFalse(AHUACATL_IS_NULL({ })); + assertFalse(AHUACATL_IS_NULL({ 'a' : 0 })); + assertFalse(AHUACATL_IS_NULL({ 'a' : 1 })); + assertFalse(AHUACATL_IS_NULL({ 'a' : 0, 'b' : 1 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_BOOL function +//////////////////////////////////////////////////////////////////////////////// + + testIsBoolTrue : function () { + assertTrue(AHUACATL_IS_BOOL(false)); + assertTrue(AHUACATL_IS_BOOL(true)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_BOOL function +//////////////////////////////////////////////////////////////////////////////// + + testIsBoolFalse : function () { + assertFalse(AHUACATL_IS_BOOL(undefined)); + assertFalse(AHUACATL_IS_BOOL(NaN)); + assertFalse(AHUACATL_IS_BOOL(1.3e308 * 1.3e308)); + assertFalse(AHUACATL_IS_BOOL(0)); + assertFalse(AHUACATL_IS_BOOL(1)); + assertFalse(AHUACATL_IS_BOOL(-1)); + assertFalse(AHUACATL_IS_BOOL(0.1)); + assertFalse(AHUACATL_IS_BOOL(-0.1)); + assertFalse(AHUACATL_IS_BOOL(null)); + assertFalse(AHUACATL_IS_BOOL('abc')); + assertFalse(AHUACATL_IS_BOOL('null')); + assertFalse(AHUACATL_IS_BOOL('false')); + assertFalse(AHUACATL_IS_BOOL('undefined')); + assertFalse(AHUACATL_IS_BOOL('')); + assertFalse(AHUACATL_IS_BOOL(' ')); + assertFalse(AHUACATL_IS_BOOL([ ])); + assertFalse(AHUACATL_IS_BOOL([ 0 ])); + assertFalse(AHUACATL_IS_BOOL([ 0, 1 ])); + assertFalse(AHUACATL_IS_BOOL([ 1, 2 ])); + assertFalse(AHUACATL_IS_BOOL([ '' ])); + assertFalse(AHUACATL_IS_BOOL([ '0' ])); + assertFalse(AHUACATL_IS_BOOL([ '1' ])); + assertFalse(AHUACATL_IS_BOOL([ true ])); + assertFalse(AHUACATL_IS_BOOL([ false ])); + assertFalse(AHUACATL_IS_BOOL({ })); + assertFalse(AHUACATL_IS_BOOL({ 'a' : 0 })); + assertFalse(AHUACATL_IS_BOOL({ 'a' : 1 })); + assertFalse(AHUACATL_IS_BOOL({ 'a' : 0, 'b' : 1 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_NUMBER function +//////////////////////////////////////////////////////////////////////////////// + + testIsNumberTrue : function () { + assertTrue(AHUACATL_IS_NUMBER(0)); + assertTrue(AHUACATL_IS_NUMBER(1)); + assertTrue(AHUACATL_IS_NUMBER(-1)); + assertTrue(AHUACATL_IS_NUMBER(0.1)); + assertTrue(AHUACATL_IS_NUMBER(-0.1)); + assertTrue(AHUACATL_IS_NUMBER(12.5356)); + assertTrue(AHUACATL_IS_NUMBER(-235.26436)); + assertTrue(AHUACATL_IS_NUMBER(-23.3e17)); + assertTrue(AHUACATL_IS_NUMBER(563.44576e19)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_NUMBER function +//////////////////////////////////////////////////////////////////////////////// + + testIsNumberFalse : function () { + assertFalse(AHUACATL_IS_NUMBER(false)); + assertFalse(AHUACATL_IS_NUMBER(true)); + assertFalse(AHUACATL_IS_NUMBER(undefined)); + assertFalse(AHUACATL_IS_NUMBER(NaN)); + assertFalse(AHUACATL_IS_NUMBER(1.3e308 * 1.3e308)); + assertFalse(AHUACATL_IS_NUMBER(null)); + assertFalse(AHUACATL_IS_NUMBER('abc')); + assertFalse(AHUACATL_IS_NUMBER('null')); + assertFalse(AHUACATL_IS_NUMBER('false')); + assertFalse(AHUACATL_IS_NUMBER('undefined')); + assertFalse(AHUACATL_IS_NUMBER('')); + assertFalse(AHUACATL_IS_NUMBER(' ')); + assertFalse(AHUACATL_IS_NUMBER([ ])); + assertFalse(AHUACATL_IS_NUMBER([ 0 ])); + assertFalse(AHUACATL_IS_NUMBER([ 0, 1 ])); + assertFalse(AHUACATL_IS_NUMBER([ 1, 2 ])); + assertFalse(AHUACATL_IS_NUMBER([ '' ])); + assertFalse(AHUACATL_IS_NUMBER([ '0' ])); + assertFalse(AHUACATL_IS_NUMBER([ '1' ])); + assertFalse(AHUACATL_IS_NUMBER([ true ])); + assertFalse(AHUACATL_IS_NUMBER([ false ])); + assertFalse(AHUACATL_IS_NUMBER({ })); + assertFalse(AHUACATL_IS_NUMBER({ 'a' : 0 })); + assertFalse(AHUACATL_IS_NUMBER({ 'a' : 1 })); + assertFalse(AHUACATL_IS_NUMBER({ 'a' : 0, 'b' : 1 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_STRING function +//////////////////////////////////////////////////////////////////////////////// + + testIsStringTrue : function () { + assertTrue(AHUACATL_IS_STRING('abc')); + assertTrue(AHUACATL_IS_STRING('null')); + assertTrue(AHUACATL_IS_STRING('false')); + assertTrue(AHUACATL_IS_STRING('undefined')); + assertTrue(AHUACATL_IS_STRING('')); + assertTrue(AHUACATL_IS_STRING(' ')); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_STRING function +//////////////////////////////////////////////////////////////////////////////// + + testIsStringFalse : function () { + assertFalse(AHUACATL_IS_STRING(false)); + assertFalse(AHUACATL_IS_STRING(true)); + assertFalse(AHUACATL_IS_STRING(undefined)); + assertFalse(AHUACATL_IS_STRING(NaN)); + assertFalse(AHUACATL_IS_STRING(1.3e308 * 1.3e308)); + assertFalse(AHUACATL_IS_STRING(0)); + assertFalse(AHUACATL_IS_STRING(1)); + assertFalse(AHUACATL_IS_STRING(-1)); + assertFalse(AHUACATL_IS_STRING(0.1)); + assertFalse(AHUACATL_IS_STRING(-0.1)); + assertFalse(AHUACATL_IS_STRING(null)); + assertFalse(AHUACATL_IS_STRING([ ])); + assertFalse(AHUACATL_IS_STRING([ 0 ])); + assertFalse(AHUACATL_IS_STRING([ 0, 1 ])); + assertFalse(AHUACATL_IS_STRING([ 1, 2 ])); + assertFalse(AHUACATL_IS_STRING([ '' ])); + assertFalse(AHUACATL_IS_STRING([ '0' ])); + assertFalse(AHUACATL_IS_STRING([ '1' ])); + assertFalse(AHUACATL_IS_STRING([ true ])); + assertFalse(AHUACATL_IS_STRING([ false ])); + assertFalse(AHUACATL_IS_STRING({ })); + assertFalse(AHUACATL_IS_STRING({ 'a' : 0 })); + assertFalse(AHUACATL_IS_STRING({ 'a' : 1 })); + assertFalse(AHUACATL_IS_STRING({ 'a' : 0, 'b' : 1 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_LIST function +//////////////////////////////////////////////////////////////////////////////// + + testIsArrayTrue : function () { + assertTrue(AHUACATL_IS_LIST([ ])); + assertTrue(AHUACATL_IS_LIST([ 0 ])); + assertTrue(AHUACATL_IS_LIST([ 0, 1 ])); + assertTrue(AHUACATL_IS_LIST([ 1, 2 ])); + assertTrue(AHUACATL_IS_LIST([ '' ])); + assertTrue(AHUACATL_IS_LIST([ '0' ])); + assertTrue(AHUACATL_IS_LIST([ '1' ])); + assertTrue(AHUACATL_IS_LIST([ true ])); + assertTrue(AHUACATL_IS_LIST([ false ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_LIST function +//////////////////////////////////////////////////////////////////////////////// + + testIsArrayFalse : function () { + assertFalse(AHUACATL_IS_LIST('abc')); + assertFalse(AHUACATL_IS_LIST('null')); + assertFalse(AHUACATL_IS_LIST('false')); + assertFalse(AHUACATL_IS_LIST('undefined')); + assertFalse(AHUACATL_IS_LIST('')); + assertFalse(AHUACATL_IS_LIST(' ')); + assertFalse(AHUACATL_IS_LIST(false)); + assertFalse(AHUACATL_IS_LIST(true)); + assertFalse(AHUACATL_IS_LIST(undefined)); + assertFalse(AHUACATL_IS_LIST(NaN)); + assertFalse(AHUACATL_IS_LIST(1.3e308 * 1.3e308)); + assertFalse(AHUACATL_IS_LIST(0)); + assertFalse(AHUACATL_IS_LIST(1)); + assertFalse(AHUACATL_IS_LIST(-1)); + assertFalse(AHUACATL_IS_LIST(0.1)); + assertFalse(AHUACATL_IS_LIST(-0.1)); + assertFalse(AHUACATL_IS_LIST(null)); + assertFalse(AHUACATL_IS_LIST({ })); + assertFalse(AHUACATL_IS_LIST({ 'a' : 0 })); + assertFalse(AHUACATL_IS_LIST({ 'a' : 1 })); + assertFalse(AHUACATL_IS_LIST({ 'a' : 0, 'b' : 1 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_DOCUMENT function +//////////////////////////////////////////////////////////////////////////////// + + testIsObjectTrue : function () { + assertTrue(AHUACATL_IS_DOCUMENT({ })); + assertTrue(AHUACATL_IS_DOCUMENT({ 'a' : 0 })); + assertTrue(AHUACATL_IS_DOCUMENT({ 'a' : 1 })); + assertTrue(AHUACATL_IS_DOCUMENT({ 'a' : 0, 'b' : 1 })); + assertTrue(AHUACATL_IS_DOCUMENT({ '1' : false, 'b' : false })); + assertTrue(AHUACATL_IS_DOCUMENT({ '0' : false })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_IS_DOCUMENT function +//////////////////////////////////////////////////////////////////////////////// + + testIsObjectFalse : function () { + assertFalse(AHUACATL_IS_DOCUMENT('abc')); + assertFalse(AHUACATL_IS_DOCUMENT('null')); + assertFalse(AHUACATL_IS_DOCUMENT('false')); + assertFalse(AHUACATL_IS_DOCUMENT('undefined')); + assertFalse(AHUACATL_IS_DOCUMENT('')); + assertFalse(AHUACATL_IS_DOCUMENT(' ')); + assertFalse(AHUACATL_IS_DOCUMENT(false)); + assertFalse(AHUACATL_IS_DOCUMENT(true)); + assertFalse(AHUACATL_IS_DOCUMENT(undefined)); + assertFalse(AHUACATL_IS_DOCUMENT(NaN)); + assertFalse(AHUACATL_IS_DOCUMENT(1.3e308 * 1.3e308)); + assertFalse(AHUACATL_IS_DOCUMENT(0)); + assertFalse(AHUACATL_IS_DOCUMENT(1)); + assertFalse(AHUACATL_IS_DOCUMENT(-1)); + assertFalse(AHUACATL_IS_DOCUMENT(0.1)); + assertFalse(AHUACATL_IS_DOCUMENT(-0.1)); + assertFalse(AHUACATL_IS_DOCUMENT(null)); + assertFalse(AHUACATL_IS_DOCUMENT([ ])); + assertFalse(AHUACATL_IS_DOCUMENT([ 0 ])); + assertFalse(AHUACATL_IS_DOCUMENT([ 0, 1 ])); + assertFalse(AHUACATL_IS_DOCUMENT([ 1, 2 ])); + assertFalse(AHUACATL_IS_DOCUMENT([ '' ])); + assertFalse(AHUACATL_IS_DOCUMENT([ '0' ])); + assertFalse(AHUACATL_IS_DOCUMENT([ '1' ])); + assertFalse(AHUACATL_IS_DOCUMENT([ true ])); + assertFalse(AHUACATL_IS_DOCUMENT([ false ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_CAST_NULL function +//////////////////////////////////////////////////////////////////////////////// + + testCastNull : function () { + assertEqual(null, AHUACATL_CAST_NULL(undefined)); + assertEqual(null, AHUACATL_CAST_NULL(null)); + assertEqual(null, AHUACATL_CAST_NULL(1)); + assertEqual(null, AHUACATL_CAST_NULL(2)); + assertEqual(null, AHUACATL_CAST_NULL(-1)); + assertEqual(null, AHUACATL_CAST_NULL(0)); + assertEqual(null, AHUACATL_CAST_NULL(NaN)); + assertEqual(null, AHUACATL_CAST_NULL(true)); + assertEqual(null, AHUACATL_CAST_NULL(false)); + assertEqual(null, AHUACATL_CAST_NULL('')); + assertEqual(null, AHUACATL_CAST_NULL(' ')); + assertEqual(null, AHUACATL_CAST_NULL(' ')); + assertEqual(null, AHUACATL_CAST_NULL('1')); + assertEqual(null, AHUACATL_CAST_NULL('0')); + assertEqual(null, AHUACATL_CAST_NULL('-1')); + assertEqual(null, AHUACATL_CAST_NULL([ ])); + assertEqual(null, AHUACATL_CAST_NULL([ 0 ] )); + assertEqual(null, AHUACATL_CAST_NULL([ 0, 1 ] )); + assertEqual(null, AHUACATL_CAST_NULL([ 1, 2 ] )); + assertEqual(null, AHUACATL_CAST_NULL({ } )); + assertEqual(null, AHUACATL_CAST_NULL({ 'a' : true })); + assertEqual(null, AHUACATL_CAST_NULL({ 'a' : true, 'b' : 0 })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_CAST_BOOL function +//////////////////////////////////////////////////////////////////////////////// + + testCastBoolTrue : function () { + assertEqual(true, AHUACATL_CAST_BOOL(true)); + assertEqual(true, AHUACATL_CAST_BOOL(1)); + assertEqual(true, AHUACATL_CAST_BOOL(2)); + assertEqual(true, AHUACATL_CAST_BOOL(-1)); + assertEqual(true, AHUACATL_CAST_BOOL(100)); + assertEqual(true, AHUACATL_CAST_BOOL(100.01)); + assertEqual(true, AHUACATL_CAST_BOOL(0.001)); + assertEqual(true, AHUACATL_CAST_BOOL(-0.001)); + assertEqual(true, AHUACATL_CAST_BOOL(' ')); + assertEqual(true, AHUACATL_CAST_BOOL(' ')); + assertEqual(true, AHUACATL_CAST_BOOL('1')); + assertEqual(true, AHUACATL_CAST_BOOL('1 ')); + assertEqual(true, AHUACATL_CAST_BOOL('0')); + assertEqual(true, AHUACATL_CAST_BOOL('-1')); + assertEqual(true, AHUACATL_CAST_BOOL([ 0 ])); + assertEqual(true, AHUACATL_CAST_BOOL([ 0, 1 ])); + assertEqual(true, AHUACATL_CAST_BOOL([ 1, 2 ])); + assertEqual(true, AHUACATL_CAST_BOOL([ -1, 0 ])); + assertEqual(true, AHUACATL_CAST_BOOL([ '' ])); + assertEqual(true, AHUACATL_CAST_BOOL([ false ])); + assertEqual(true, AHUACATL_CAST_BOOL([ true ])); + assertEqual(true, AHUACATL_CAST_BOOL({ 'a' : true })); + assertEqual(true, AHUACATL_CAST_BOOL({ 'a' : false })); + assertEqual(true, AHUACATL_CAST_BOOL({ 'a' : false, 'b' : 0 })); + assertEqual(true, AHUACATL_CAST_BOOL({ '0' : false })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_CAST_BOOL function +//////////////////////////////////////////////////////////////////////////////// + + testCastBoolFalse : function () { + assertEqual(false, AHUACATL_CAST_BOOL(0)); + assertEqual(false, AHUACATL_CAST_BOOL(NaN)); + assertEqual(false, AHUACATL_CAST_BOOL('')); + assertEqual(false, AHUACATL_CAST_BOOL(undefined)); + assertEqual(false, AHUACATL_CAST_BOOL(null)); + assertEqual(false, AHUACATL_CAST_BOOL(false)); + assertEqual(false, AHUACATL_CAST_BOOL([ ])); + assertEqual(false, AHUACATL_CAST_BOOL({ })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_CAST_NUMBER function +//////////////////////////////////////////////////////////////////////////////// + + testCastNumber : function () { + assertEqual(0, AHUACATL_CAST_NUMBER(undefined)); + assertEqual(0, AHUACATL_CAST_NUMBER(null)); + assertEqual(0, AHUACATL_CAST_NUMBER(false)); + assertEqual(1, AHUACATL_CAST_NUMBER(true)); + assertEqual(1, AHUACATL_CAST_NUMBER(1)); + assertEqual(2, AHUACATL_CAST_NUMBER(2)); + assertEqual(-1, AHUACATL_CAST_NUMBER(-1)); + assertEqual(0, AHUACATL_CAST_NUMBER(0)); + assertEqual(0, AHUACATL_CAST_NUMBER(NaN)); + assertEqual(0, AHUACATL_CAST_NUMBER('')); + assertEqual(0, AHUACATL_CAST_NUMBER(' ')); + assertEqual(0, AHUACATL_CAST_NUMBER(' ')); + assertEqual(1, AHUACATL_CAST_NUMBER('1')); + assertEqual(1, AHUACATL_CAST_NUMBER('1 ')); + assertEqual(0, AHUACATL_CAST_NUMBER('0')); + assertEqual(-1, AHUACATL_CAST_NUMBER('-1')); + assertEqual(-1, AHUACATL_CAST_NUMBER('-1 ')); + assertEqual(-1, AHUACATL_CAST_NUMBER(' -1 ')); + assertEqual(-1, AHUACATL_CAST_NUMBER(' -1a')); + assertEqual(1, AHUACATL_CAST_NUMBER(' 1a')); + assertEqual(12335.3, AHUACATL_CAST_NUMBER(' 12335.3 a')); + assertEqual(0, AHUACATL_CAST_NUMBER('a1bc')); + assertEqual(0, AHUACATL_CAST_NUMBER('aaaa1')); + assertEqual(0, AHUACATL_CAST_NUMBER('-a1')); + assertEqual(-1.255, AHUACATL_CAST_NUMBER('-1.255')); + assertEqual(-1.23456, AHUACATL_CAST_NUMBER('-1.23456')); + assertEqual(-1.23456, AHUACATL_CAST_NUMBER('-1.23456 ')); + assertEqual(1.23456, AHUACATL_CAST_NUMBER(' 1.23456 ')); + assertEqual(1.23456, AHUACATL_CAST_NUMBER(' 1.23456a')); + assertEqual(0, AHUACATL_CAST_NUMBER('--1')); + assertEqual(1, AHUACATL_CAST_NUMBER('+1')); + assertEqual(12.42e32, AHUACATL_CAST_NUMBER('12.42e32')); + assertEqual(0, AHUACATL_CAST_NUMBER([ ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ 0 ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ 0, 1 ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ 1, 2 ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ -1, 0 ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ 0, 1, [ 1, 2 ], [ [ 9, 4 ] ] ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ { } ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ 0, 1, { } ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ { }, { } ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ '' ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ false ])); + assertEqual(0, AHUACATL_CAST_NUMBER([ true ])); + assertEqual(0, AHUACATL_CAST_NUMBER({ })); + assertEqual(0, AHUACATL_CAST_NUMBER({ 'a' : true })); + assertEqual(0, AHUACATL_CAST_NUMBER({ 'a' : true, 'b' : 0 })); + assertEqual(0, AHUACATL_CAST_NUMBER({ 'a' : { }, 'b' : { } })); + assertEqual(0, AHUACATL_CAST_NUMBER({ 'a' : [ ], 'b' : [ ] })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_CAST_STRING function +//////////////////////////////////////////////////////////////////////////////// + + testCastString : function () { + assertEqual('null', AHUACATL_CAST_STRING(undefined)); + assertEqual('null', AHUACATL_CAST_STRING(null)); + assertEqual('false', AHUACATL_CAST_STRING(false)); + assertEqual('true', AHUACATL_CAST_STRING(true)); + assertEqual('1', AHUACATL_CAST_STRING(1)); + assertEqual('2', AHUACATL_CAST_STRING(2)); + assertEqual('-1', AHUACATL_CAST_STRING(-1)); + assertEqual('0', AHUACATL_CAST_STRING(0)); + assertEqual('null', AHUACATL_CAST_STRING(NaN)); + assertEqual('', AHUACATL_CAST_STRING('')); + assertEqual(' ', AHUACATL_CAST_STRING(' ')); + assertEqual(' ', AHUACATL_CAST_STRING(' ')); + assertEqual('1', AHUACATL_CAST_STRING('1')); + assertEqual('1 ', AHUACATL_CAST_STRING('1 ')); + assertEqual('0', AHUACATL_CAST_STRING('0')); + assertEqual('-1', AHUACATL_CAST_STRING('-1')); + assertEqual('', AHUACATL_CAST_STRING([ ])); + assertEqual('0', AHUACATL_CAST_STRING([ 0 ])); + assertEqual('0,1', AHUACATL_CAST_STRING([ 0, 1 ])); + assertEqual('1,2', AHUACATL_CAST_STRING([ 1, 2 ])); + assertEqual('-1,0', AHUACATL_CAST_STRING([ -1, 0 ])); + assertEqual('0,1,1,2,9,4', AHUACATL_CAST_STRING([ 0, 1, [ 1, 2 ], [ [ 9, 4 ] ] ])); + assertEqual('[object Object]', AHUACATL_CAST_STRING([ { } ])); + assertEqual('0,1,[object Object]', AHUACATL_CAST_STRING([ 0, 1, { } ])); + assertEqual('[object Object],[object Object]', AHUACATL_CAST_STRING([ { }, { } ])); + assertEqual('', AHUACATL_CAST_STRING([ '' ])); + assertEqual('false', AHUACATL_CAST_STRING([ false ])); + assertEqual('true', AHUACATL_CAST_STRING([ true ])); + assertEqual('[object Object]', AHUACATL_CAST_STRING({ })); + assertEqual('[object Object]', AHUACATL_CAST_STRING({ 'a' : true })); + assertEqual('[object Object]', AHUACATL_CAST_STRING({ 'a' : true, 'b' : 0 })); + assertEqual('[object Object]', AHUACATL_CAST_STRING({ 'a' : { }, 'b' : { } })); + assertEqual('[object Object]', AHUACATL_CAST_STRING({ 'a' : [ ], 'b' : [ ] })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_AND function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalAndUndefined : function () { + assertException(function() { AHUACATL_LOGICAL_AND(undefined, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, null); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, 0.0); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, 1.0); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, -1.0); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, ''); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, '0'); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, '1'); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, [ 1, 2 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, { }); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, { 'a' : 1 }); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, { '0' : false }); }); + assertException(function() { AHUACATL_LOGICAL_AND(null, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(0.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(1.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(-1.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND('', undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND('0', undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND('1', undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND([ ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0, 1 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 1, 2 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND({ }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : 1 }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND({ '0' : false }, undefined); }); + + assertException(function() { AHUACATL_LOGICAL_AND(true, null); }); + assertException(function() { AHUACATL_LOGICAL_AND(null, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, ''); }); + assertException(function() { AHUACATL_LOGICAL_AND('', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, ' '); }); + assertException(function() { AHUACATL_LOGICAL_AND(' ', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, '0'); }); + assertException(function() { AHUACATL_LOGICAL_AND('0', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, '1'); }); + assertException(function() { AHUACATL_LOGICAL_AND('1', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, 'true'); }); + assertException(function() { AHUACATL_LOGICAL_AND('true', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, 'false'); }); + assertException(function() { AHUACATL_LOGICAL_AND('false', true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, 0); }); + assertException(function() { AHUACATL_LOGICAL_AND(0, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, 1); }); + assertException(function() { AHUACATL_LOGICAL_AND(1, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, -1); }); + assertException(function() { AHUACATL_LOGICAL_AND(-1, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, 1.1); }); + assertException(function() { AHUACATL_LOGICAL_AND(1.1, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0 ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0, 1 ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, [ true ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ true ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, [ false ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ false ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, { }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ }, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, { 'a' : true }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : true }, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, { 'a' : true, 'b' : false }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : true, 'b' : false }, true); }); + + assertException(function() { AHUACATL_LOGICAL_AND(false, null); }); + assertException(function() { AHUACATL_LOGICAL_AND(null, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, ''); }); + assertException(function() { AHUACATL_LOGICAL_AND('', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, ' '); }); + assertException(function() { AHUACATL_LOGICAL_AND(' ', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, '0'); }); + assertException(function() { AHUACATL_LOGICAL_AND('0', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, '1'); }); + assertException(function() { AHUACATL_LOGICAL_AND('1', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, 'true'); }); + assertException(function() { AHUACATL_LOGICAL_AND('true', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, 'false'); }); + assertException(function() { AHUACATL_LOGICAL_AND('false', false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, 0); }); + assertException(function() { AHUACATL_LOGICAL_AND(0, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, 1); }); + assertException(function() { AHUACATL_LOGICAL_AND(1, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, -1); }); + assertException(function() { AHUACATL_LOGICAL_AND(-1, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, 1.1); }); + assertException(function() { AHUACATL_LOGICAL_AND(1.1, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ ], false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0 ], false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ 0, 1 ], false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, [ true ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ false ], true); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, [ false ]); }); + assertException(function() { AHUACATL_LOGICAL_AND([ false ], false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, { }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ }, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, { 'a' : true }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : false }, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, { 'a' : true, 'b' : false }); }); + assertException(function() { AHUACATL_LOGICAL_AND({ 'a' : false, 'b' : false }, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, 0); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, true); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, false); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, null); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, undefined); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, ''); }); + assertException(function() { AHUACATL_LOGICAL_AND(NaN, '0'); }); + assertException(function() { AHUACATL_LOGICAL_AND(0, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND(true, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND(false, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND(null, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND(undefined, NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND('', NaN); }); + assertException(function() { AHUACATL_LOGICAL_AND('0', NaN); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_AND function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalAndBool : function () { + assertTrue(AHUACATL_LOGICAL_AND(true, true)); + assertFalse(AHUACATL_LOGICAL_AND(true, false)); + assertFalse(AHUACATL_LOGICAL_AND(false, true)); + assertFalse(AHUACATL_LOGICAL_AND(false, false)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_OR function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalOrUndefined : function () { + assertException(function() { AHUACATL_LOGICAL_OR(undefined, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, null); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, 0.0); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, 1.0); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, -1.0); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, ''); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, '0'); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, '1'); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, [ 1, 2 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, { }); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, { 'a' : 1 }); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, { '0' : false }); }); + assertException(function() { AHUACATL_LOGICAL_OR(null, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(0.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(1.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(-1.0, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR('', undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR('0', undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR('1', undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR([ ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0, 1 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 1, 2 ], undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR({ }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : 1 }, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR({ '0' : false }, undefined); }); + + assertException(function() { AHUACATL_LOGICAL_OR(true, null); }); + assertException(function() { AHUACATL_LOGICAL_OR(null, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, ''); }); + assertException(function() { AHUACATL_LOGICAL_OR('', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, ' '); }); + assertException(function() { AHUACATL_LOGICAL_OR(' ', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, '0'); }); + assertException(function() { AHUACATL_LOGICAL_OR('0', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, '1'); }); + assertException(function() { AHUACATL_LOGICAL_OR('1', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, 'true'); }); + assertException(function() { AHUACATL_LOGICAL_OR('true', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, 'false'); }); + assertException(function() { AHUACATL_LOGICAL_OR('false', true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, 0); }); + assertException(function() { AHUACATL_LOGICAL_OR(0, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, 1); }); + assertException(function() { AHUACATL_LOGICAL_OR(1, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, -1); }); + assertException(function() { AHUACATL_LOGICAL_OR(-1, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, 1.1); }); + assertException(function() { AHUACATL_LOGICAL_OR(1.1, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0 ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0, 1 ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, [ true ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ true ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, [ false ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ false ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, { }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ }, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, { 'a' : true }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : true }, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, { 'a' : true, 'b' : false }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : true, 'b' : false }, true); }); + + assertException(function() { AHUACATL_LOGICAL_OR(false, null); }); + assertException(function() { AHUACATL_LOGICAL_OR(null, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, ''); }); + assertException(function() { AHUACATL_LOGICAL_OR('', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, ' '); }); + assertException(function() { AHUACATL_LOGICAL_OR(' ', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, '0'); }); + assertException(function() { AHUACATL_LOGICAL_OR('0', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, '1'); }); + assertException(function() { AHUACATL_LOGICAL_OR('1', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, 'true'); }); + assertException(function() { AHUACATL_LOGICAL_OR('true', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, 'false'); }); + assertException(function() { AHUACATL_LOGICAL_OR('false', false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, 0); }); + assertException(function() { AHUACATL_LOGICAL_OR(0, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, 1); }); + assertException(function() { AHUACATL_LOGICAL_OR(1, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, -1); }); + assertException(function() { AHUACATL_LOGICAL_OR(-1, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, 1.1); }); + assertException(function() { AHUACATL_LOGICAL_OR(1.1, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, [ ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ ], false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, [ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0 ], false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, [ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ 0, 1 ], false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, [ true ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ false ], true); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, [ false ]); }); + assertException(function() { AHUACATL_LOGICAL_OR([ false ], false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, { }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ }, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, { 'a' : true }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : false }, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, { 'a' : true, 'b' : false }); }); + assertException(function() { AHUACATL_LOGICAL_OR({ 'a' : false, 'b' : false }, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, 0); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, true); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, false); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, null); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, undefined); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, ''); }); + assertException(function() { AHUACATL_LOGICAL_OR(NaN, '0'); }); + assertException(function() { AHUACATL_LOGICAL_OR(0, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR(true, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR(false, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR(null, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR(undefined, NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR('', NaN); }); + assertException(function() { AHUACATL_LOGICAL_OR('0', NaN); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_OR function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalOrBool : function () { + assertTrue(AHUACATL_LOGICAL_OR(true, true)); + assertTrue(AHUACATL_LOGICAL_OR(true, false)); + assertTrue(AHUACATL_LOGICAL_OR(false, true)); + assertFalse(AHUACATL_LOGICAL_OR(false, false)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_NOT function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalNotUndefined : function () { + assertException(function() { AHUACATL_LOGICAL_NOT(undefined); }); + assertException(function() { AHUACATL_LOGICAL_NOT(null); }); + assertException(function() { AHUACATL_LOGICAL_NOT(0.0); }); + assertException(function() { AHUACATL_LOGICAL_NOT(1.0); }); + assertException(function() { AHUACATL_LOGICAL_NOT(-1.0); }); + assertException(function() { AHUACATL_LOGICAL_NOT(''); }); + assertException(function() { AHUACATL_LOGICAL_NOT('0'); }); + assertException(function() { AHUACATL_LOGICAL_NOT('1'); }); + assertException(function() { AHUACATL_LOGICAL_NOT([ ]); }); + assertException(function() { AHUACATL_LOGICAL_NOT([ 0 ]); }); + assertException(function() { AHUACATL_LOGICAL_NOT([ 0, 1 ]); }); + assertException(function() { AHUACATL_LOGICAL_NOT([ 1, 2 ]); }); + assertException(function() { AHUACATL_LOGICAL_NOT({ }); }); + assertException(function() { AHUACATL_LOGICAL_NOT({ 'a' : 0 }); }); + assertException(function() { AHUACATL_LOGICAL_NOT({ 'a' : 1 }); }); + assertException(function() { AHUACATL_LOGICAL_NOT({ '0' : false}); }); + assertException(function() { AHUACATL_LOGICAL_NOT(NaN); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_LOGICAL_NOT function +//////////////////////////////////////////////////////////////////////////////// + + testLogicalNotBool : function () { + assertTrue(AHUACATL_LOGICAL_NOT(false)); + assertFalse(AHUACATL_LOGICAL_NOT(true)); + + assertTrue(AHUACATL_LOGICAL_NOT(AHUACATL_LOGICAL_NOT(true))); + assertFalse(AHUACATL_LOGICAL_NOT(AHUACATL_LOGICAL_NOT(false))); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_EQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalEqualTrue : function () { + assertTrue(AHUACATL_RELATIONAL_EQUAL(undefined, undefined)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(undefined, null)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(null, undefined)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(null, null)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(NaN, NaN)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(NaN, null)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(NaN, undefined)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(undefined, NaN)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(null, NaN)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1, 1)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(0, 0)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(-1, -1)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.345, 1.345)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.0, 1.00)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.0, 1.000)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.1, 1.1)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.01, 1.01)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.001, 1.001)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.0001, 1.0001)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.00001, 1.00001)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.000001, 1.000001)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(1.245e307, 1.245e307)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(-99.43423, -99.43423)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(true, true)); + assertTrue(AHUACATL_RELATIONAL_EQUAL(false, false)); + assertTrue(AHUACATL_RELATIONAL_EQUAL('', '')); + assertTrue(AHUACATL_RELATIONAL_EQUAL(' ', ' ')); + assertTrue(AHUACATL_RELATIONAL_EQUAL(' 1', ' 1')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('0', '0')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('abc', 'abc')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('-1', '-1')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('true', 'true')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('false', 'false')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('undefined', 'undefined')); + assertTrue(AHUACATL_RELATIONAL_EQUAL('null', 'null')); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ ], [ ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ 0 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ 0, 1 ], [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ 0, 1, 4 ], [ 0, 1, 4 ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ 3, 4, -99 ], [ 3, 4, -99 ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL([ 'a', 4, [ 1, 'a' ], false ], [ 'a', 4, [ 1, 'a' ], false ])); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ }, { })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'a' : true }, { 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'a' : true, 'b': true }, { 'a' : true, 'b': true })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'a' : true, 'b': true }, { 'b' : true, 'a': true })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'b' : true, 'a': true }, { 'b' : true, 'a': true })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'b' : true, 'a': true }, { 'a' : true, 'b': true })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] }, { 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] }, { 'b' : [ 1, 9 ], 'a' : [ 0, 1 ] })); + assertTrue(AHUACATL_RELATIONAL_EQUAL({ 'f' : { 'c' : { 'd' : [ 0, 1 ], 'a' : [ 1, 9 ] }, 'a' : false }, 'a' : true }, { 'a' : true, 'f' : { 'a' : false, 'c' : { 'a' : [ 1, 9 ], 'd' : [ 0, 1 ] } } })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_EQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalEqualFalse : function () { + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, 0.0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, 1.0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, -1.0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, '0')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, '1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, { })); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, { 'a' : 0 })); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, { 'a' : 1 })); + assertFalse(AHUACATL_RELATIONAL_EQUAL(undefined, { '0' : false })); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(-1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('0', undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1', undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ ], undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 0 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 0, 1 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 2 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ }, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : 0 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : 1 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ '0' : false }, undefined)); + + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(-1, 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, -1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(-1, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, -1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, 'true')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, 'false')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('true', true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('false', false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(-1.345, 1.345)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.345, -1.345)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.345, 1.346)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.346, 1.345)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.344, 1.345)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.345, 1.344)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, 2)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(2, 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.246e307, 1.245e307)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.246e307, 1.247e307)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.246e307, 1.2467e307)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(-99.43423, -99.434233)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.00001, 1.000001)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1.00001, 1.0001)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, '0')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('0', null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(false, null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, true)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(true, null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(null, 'null')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('null', null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(0, '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(' ', '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', ' ')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(' 1', '1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1', ' 1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1 ', '1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1', '1 ')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1 ', ' 1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(' 1', '1 ')); + assertFalse(AHUACATL_RELATIONAL_EQUAL(' 1 ', '1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('0', '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('', ' ')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('abc', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('abcd', 'abc')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('dabc', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1', 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL(1, '1')); + assertFalse(AHUACATL_RELATIONAL_EQUAL('0', 0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1.0', 1.0)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1.0', 1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('-1', -1)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('1.234', 1.234)); + assertFalse(AHUACATL_RELATIONAL_EQUAL('NaN', NaN)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ ], [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 0 ], [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 1, 0 ], [ 1, 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0, 0 ], [ 1, 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0, 0 ], [ 1, 0 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0 ], [ 1, 0, 0 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0 ], [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 0 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, 2, 3 ], [ 3, 2, 1 ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ [ 1 ] ], [ [ 0 ] ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, [ 1 , 0 ] ], [ 1, [ 0, 1 ] ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ 1, [ 1 , 0, [ ] ] ], [ 1, [ [ ], 1, 0 ] ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ '' ], false)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ '' ], '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ '' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ true ], [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ true ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ false ], [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ null ], [ ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ null ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ ], null)); + assertFalse(AHUACATL_RELATIONAL_EQUAL([ ], '')); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ }, { 'a' : false })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : false }, { })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : true }, { 'a' : false })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : true }, { 'b' : true })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'b' : true }, { 'a' : true })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : true, 'b' : [ 0, 1 ] }, { 'a' : true, 'b' : [ 1, 0 ] })); + assertFalse(AHUACATL_RELATIONAL_EQUAL({ 'a' : true, 'b' : { 'a' : false, 'b' : true } }, { 'a' : true, 'b' : { 'a' : true, 'b': true } })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_UNEQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalUnequalTrue : function () { + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, 0.0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, 1.0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, -1.0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, '0')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, '1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, [ 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, { })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(undefined, { '0' : false })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(-1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('0', undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1', undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ ], undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 0 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 0, 1 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 2 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ }, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : 0 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : 1 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ '0' : false }, undefined)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(NaN, false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(NaN, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(NaN, '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(NaN, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, NaN)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, NaN)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', NaN)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, NaN)); + + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(-1, 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, -1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(-1, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, -1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, 'true')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, 'false')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('true', true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('false', false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(-1.345, 1.345)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.345, -1.345)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.345, 1.346)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.346, 1.345)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.344, 1.345)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.345, 1.344)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, 2)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(2, 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.246e307, 1.245e307)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.246e307, 1.247e307)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.246e307, 1.2467e307)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(-99.43423, -99.434233)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.00001, 1.000001)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1.00001, 1.0001)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, '0')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('0', null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(false, null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, true)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(true, null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(null, 'null')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('null', null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(0, '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(' ', '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', ' ')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(' 1', '1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1', ' 1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1 ', '1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1', '1 ')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1 ', ' 1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(' 1', '1 ')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(' 1 ', '1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('0', '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('', ' ')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('abc', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('abcd', 'abc')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('dabc', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1', 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL(1, '1')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('0', 0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1.0', 1.0)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1.0', 1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('-1', -1)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL('1.234', 1.234)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 0 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ ], [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 0 ], [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 1, 0 ], [ 1, 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0, 0 ], [ 1, 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0, 0 ], [ 1, 0 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0 ], [ 1, 0, 0 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0 ], [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 0 ], [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, 2, 3 ], [ 3, 2, 1 ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ [ 1 ] ], [ [ 0 ] ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, [ 1 , 0 ] ], [ 1, [ 0, 1 ] ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ 1, [ 1 , 0, [ ] ] ], [ 1, [ [ ], 1, 0 ] ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ '' ], false)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ '' ], '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ '' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ true ], [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ true ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ false ], [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ null ], [ ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ null ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ ], null)); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL([ ], '')); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ }, { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : false }, { })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true }, { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true }, { 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'b' : true }, { 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true, 'b' : [ 0, 1 ] }, { 'a' : true, 'b' : [ 1, 0 ] })); + assertTrue(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true, 'b' : { 'a' : false, 'b' : true } }, { 'a' : true, 'b' : { 'a' : true, 'b': true } })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_UNEQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalUnequalFalse : function () { + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1, 1)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(0, 0)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(-1, -1)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.345, 1.345)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.0, 1.00)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.0, 1.000)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.1, 1.1)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.01, 1.01)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.001, 1.001)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.0001, 1.0001)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.00001, 1.00001)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.000001, 1.000001)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(1.245e307, 1.245e307)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(-99.43423, -99.43423)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(true, true)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(false, false)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('', '')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(' ', ' ')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(' 1', ' 1')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('0', '0')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('abc', 'abc')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('-1', '-1')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(null, null)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(null, undefined)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(null, NaN)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(undefined, NaN)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(NaN, null)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(NaN, undefined)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL(undefined, undefined)); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('true', 'true')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('false', 'false')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('undefined', 'undefined')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL('null', 'null')); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ ], [ ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ 0 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ 0, 1 ], [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ 0, 1, 4 ], [ 0, 1, 4 ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ 3, 4, -99 ], [ 3, 4, -99 ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL([ 'a', 4, [ 1, 'a' ], false ], [ 'a', 4, [ 1, 'a' ], false ])); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ }, { })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true }, { 'a' : true })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true, 'b': true }, { 'a' : true, 'b': true })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : true, 'b': true }, { 'b' : true, 'a': true })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'b' : true, 'a': true }, { 'b' : true, 'a': true })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'b' : true, 'a': true }, { 'a' : true, 'b': true })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] }, { 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'a' : [ 0, 1 ], 'b' : [ 1, 9 ] }, { 'b' : [ 1, 9 ], 'a' : [ 0, 1 ] })); + assertFalse(AHUACATL_RELATIONAL_UNEQUAL({ 'f' : { 'c' : { 'd' : [ 0, 1 ], 'a' : [ 1, 9 ] }, 'a' : false }, 'a' : true }, { 'a' : true, 'f' : { 'a' : false, 'c' : { 'a' : [ 1, 9 ], 'd' : [ 0, 1 ] } } })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_LESS function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalLessTrue : function () { + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, false)); + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, true)); + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, 0)); + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(NaN, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, true)); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, false)); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, 0.0)); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, 1.0)); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, -1.0)); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, [ 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESS(undefined, { '0' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS(null, false)); + assertTrue(AHUACATL_RELATIONAL_LESS(null, true)); + assertTrue(AHUACATL_RELATIONAL_LESS(null, 0)); + assertTrue(AHUACATL_RELATIONAL_LESS(null, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(null, -1)); + assertTrue(AHUACATL_RELATIONAL_LESS(null, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESS(null, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(null, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS(null, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESS(null, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESS(null, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(null, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(null, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS(false, true)); + assertTrue(AHUACATL_RELATIONAL_LESS(false, 0)); + assertTrue(AHUACATL_RELATIONAL_LESS(false, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(false, -1)); + assertTrue(AHUACATL_RELATIONAL_LESS(false, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESS(false, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(false, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS(false, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESS(false, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESS(false, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(false, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(false, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS(true, 0)); + assertTrue(AHUACATL_RELATIONAL_LESS(true, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(true, -1)); + assertTrue(AHUACATL_RELATIONAL_LESS(true, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESS(true, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(true, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS(true, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESS(true, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESS(true, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(true, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(true, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS(0, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(1, 2)); + assertTrue(AHUACATL_RELATIONAL_LESS(1, 100)); + assertTrue(AHUACATL_RELATIONAL_LESS(20, 100)); + assertTrue(AHUACATL_RELATIONAL_LESS(-100, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(-100, -10)); + assertTrue(AHUACATL_RELATIONAL_LESS(-11, -10)); + assertTrue(AHUACATL_RELATIONAL_LESS(999, 1000)); + assertTrue(AHUACATL_RELATIONAL_LESS(-1, 1)); + assertTrue(AHUACATL_RELATIONAL_LESS(-1, 0)); + assertTrue(AHUACATL_RELATIONAL_LESS(1.0, 1.01)); + assertTrue(AHUACATL_RELATIONAL_LESS(1.111, 1.2)); + assertTrue(AHUACATL_RELATIONAL_LESS(-1.111, -1.110)); + assertTrue(AHUACATL_RELATIONAL_LESS(-1.111, -1.1109)); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, 'false')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, '')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, '0')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, '1')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, 'false')); + assertTrue(AHUACATL_RELATIONAL_LESS(1, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '-100')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '-1.1')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, '-0.0')); + assertTrue(AHUACATL_RELATIONAL_LESS(1000, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESS(1000, '10')); + assertTrue(AHUACATL_RELATIONAL_LESS(1000, '10000')); + assertTrue(AHUACATL_RELATIONAL_LESS(0, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(0, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(10, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ 99 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ 100 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, [ 101 ])); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 99 })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 100 })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 101 })); + assertTrue(AHUACATL_RELATIONAL_LESS(100, { 'a' : 1000 })); + assertTrue(AHUACATL_RELATIONAL_LESS('', ' ')); + assertTrue(AHUACATL_RELATIONAL_LESS('0', 'a')); + assertTrue(AHUACATL_RELATIONAL_LESS('a', 'a ')); + assertTrue(AHUACATL_RELATIONAL_LESS('a', 'b')); + assertTrue(AHUACATL_RELATIONAL_LESS('A', 'a')); + assertTrue(AHUACATL_RELATIONAL_LESS('AB', 'Ab')); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', 'bbcd')); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', 'abda')); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', 'abdd')); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', 'abcde')); + assertTrue(AHUACATL_RELATIONAL_LESS('0abcd', 'abcde')); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ " " ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ "" ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ "abc" ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', [ "abcd" ])); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', { } )); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', { 'a' : true } )); + assertTrue(AHUACATL_RELATIONAL_LESS('abcd', { 'abc' : true } )); + assertTrue(AHUACATL_RELATIONAL_LESS('ABCD', { 'a' : true } )); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0 ], [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0, 1, 2 ], [ 0, 1, 2, 3 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0, 1, 2 ], [ 0, 1, 3 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0, 1, 4 ], [ 1, 0, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0, 1, 4 ], [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 15, 99 ], [ 110 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 15, 99 ], [ 15, 100 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ undefined ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ [ null ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], [ { } ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ null ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ null ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ null ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ null ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], [ [ false ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], [ [ false ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false, false ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false, false ], [ false, true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ false, false ], [ false, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ null, null ], [ null, false ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], { 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS([ ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS([ '' ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 0 ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ null ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ false ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS([ true ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 'abcd' ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5 ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6 ], { 'a' : 2, 'b' : 2 })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 7 ], { })); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, false ], [ 5, 6, true ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, true ], [ 5, 6, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 999 ], [ 5, 6, '' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 'a' ], [ 5, 6, 'b' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 'A' ], [ 5, 6, 'a' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, '' ], [ 5, 6, 'a' ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 9, 9 ], [ 5, 6, [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, true ], [ 5, 6, [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, true ], [ 5, 6, { } ])); + assertTrue(AHUACATL_RELATIONAL_LESS([ 5, 6, 9, 9 ], [ 5, 6, { } ])); + assertTrue(AHUACATL_RELATIONAL_LESS({ }, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : 1 }, { 'a' : 2 })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : 1 }, { 'A' : 2 })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : 2 }, { 'A' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : 1, 'b' : 2 }, { 'a' : 1, 'b' : 2, 'c' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'b' : 1 }, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'b' : 2, 'a' : 1 }, { 'a' : 1, 'b' : 2, 'c' : null })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : [ 9 ], 'b' : false }, { 'a' : [ 10 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : [ 9 ], 'b' : true }, { 'a' : [ 10 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : [ ], 'b' : true }, { 'a' : [ 10 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_LESS({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ 10, 1 ] })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_LESS function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalLessFalse : function () { + assertFalse(AHUACATL_RELATIONAL_LESS(undefined, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(undefined, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(undefined, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS(null, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(null, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS(NaN, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(NaN, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(true, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(false, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(0.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS('', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0, 1 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 1, 2 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 0 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 1 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS({ '0' : false }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESS(false, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS(true, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS('', NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESS(null, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(false, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(true, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1, null)); + assertFalse(AHUACATL_RELATIONAL_LESS('', null)); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', null)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', null)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', null)); + assertFalse(AHUACATL_RELATIONAL_LESS('abcd', null)); + assertFalse(AHUACATL_RELATIONAL_LESS('null', null)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], null)); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], null)); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], null)); + assertFalse(AHUACATL_RELATIONAL_LESS([ null ], null)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], null)); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, null)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : null }, null)); + assertFalse(AHUACATL_RELATIONAL_LESS(false, false)); + assertFalse(AHUACATL_RELATIONAL_LESS(true, true)); + assertFalse(AHUACATL_RELATIONAL_LESS(true, false)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, false)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, false)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1, false)); + assertFalse(AHUACATL_RELATIONAL_LESS('', false)); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', false)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', false)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', false)); + assertFalse(AHUACATL_RELATIONAL_LESS('abcd', false)); + assertFalse(AHUACATL_RELATIONAL_LESS('true', false)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], false)); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], false)); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], false)); + assertFalse(AHUACATL_RELATIONAL_LESS([ null ], false)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], false)); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, false)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : null }, false)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, true)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, true)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1, true)); + assertFalse(AHUACATL_RELATIONAL_LESS('', true)); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', true)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', true)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', true)); + assertFalse(AHUACATL_RELATIONAL_LESS('abcd', true)); + assertFalse(AHUACATL_RELATIONAL_LESS('true', true)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], true)); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], true)); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], true)); + assertFalse(AHUACATL_RELATIONAL_LESS([ null ], true)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], true)); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, true)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : null }, true)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, 0)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, 1)); + assertFalse(AHUACATL_RELATIONAL_LESS(-10, -10)); + assertFalse(AHUACATL_RELATIONAL_LESS(-100, -100)); + assertFalse(AHUACATL_RELATIONAL_LESS(-334.5, -334.5)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, 0)); + assertFalse(AHUACATL_RELATIONAL_LESS(2, 1)); + assertFalse(AHUACATL_RELATIONAL_LESS(100, 1)); + assertFalse(AHUACATL_RELATIONAL_LESS(100, 20)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, -100)); + assertFalse(AHUACATL_RELATIONAL_LESS(-10, -100)); + assertFalse(AHUACATL_RELATIONAL_LESS(-10, -11)); + assertFalse(AHUACATL_RELATIONAL_LESS(1000, 999)); + assertFalse(AHUACATL_RELATIONAL_LESS(1, -1)); + assertFalse(AHUACATL_RELATIONAL_LESS(0, -1)); + assertFalse(AHUACATL_RELATIONAL_LESS(1.01, 1.0)); + assertFalse(AHUACATL_RELATIONAL_LESS(1.2, 1.111)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1.110, -1.111)); + assertFalse(AHUACATL_RELATIONAL_LESS(-1.1109, -1.111)); + assertFalse(AHUACATL_RELATIONAL_LESS('', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('-1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('true', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('false', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('null', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('0', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('1', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('-1', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('true', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('false', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('null', 1)); + assertFalse(AHUACATL_RELATIONAL_LESS('-1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('-100', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('-1.1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('-0.0', 0)); + assertFalse(AHUACATL_RELATIONAL_LESS('-1', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESS('10', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESS('10000', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], 0)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], 0)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], 10)); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0, 1 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 99 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 100 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS([ 101 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 0 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 1 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 99 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 100 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 101 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 1000 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, 'zz')); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 'a' }, 'zz')); + assertFalse(AHUACATL_RELATIONAL_LESS('', '')); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', ' ')); + assertFalse(AHUACATL_RELATIONAL_LESS('a', 'a')); + assertFalse(AHUACATL_RELATIONAL_LESS(' a', ' a')); + assertFalse(AHUACATL_RELATIONAL_LESS('abcd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESS(' ', '')); + assertFalse(AHUACATL_RELATIONAL_LESS('a', '0')); + assertFalse(AHUACATL_RELATIONAL_LESS('a ', 'a')); + assertFalse(AHUACATL_RELATIONAL_LESS('b', 'a')); + assertFalse(AHUACATL_RELATIONAL_LESS('a', 'A')); + assertFalse(AHUACATL_RELATIONAL_LESS('Ab', 'AB')); + assertFalse(AHUACATL_RELATIONAL_LESS('bbcd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESS('abda', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESS('abdd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESS('abcde', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESS('abcde', '0abcde')); + assertFalse(AHUACATL_RELATIONAL_LESS([ ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 1 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ 0, 1, 2 ] ], [ [ 0, 1, 2 ] ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ 1, [ "true", 0, -99 , false ] ], 4 ], [ [ 1, [ "true", 0, -99, false ] ], 4 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 1 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0, 1, 2, 3 ], [ 0, 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0, 1, 3 ], [ 0, 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 1, 0, 0 ], [ 0, 1, 4 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 1 ], [ 0, 1, 4 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 110 ], [ 15, 99 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 15, 100 ], [ 15, 99 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ undefined ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ null ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ -1 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '0' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 'abcd' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ ] ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ null ] ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ { } ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ false ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ ] ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ -1 ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '0' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 'abcd' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ ] ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ false ] ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 0 ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ -1 ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ '0' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 'abcd' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ ] ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ [ false] ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ true ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ false, true ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ false, 0 ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ null, false ], [ null, null ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : true }, [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : null }, [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, [ ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ '' ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : false }, [ 5 ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ 'a' : 2, 'b' : 2 }, [ 5, 6 ])); + assertFalse(AHUACATL_RELATIONAL_LESS({ }, [ 5, 6, 7 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, true ], [ 5, 6, false ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, 0 ], [ 5, 6, true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, '' ], [ 5, 6, 999 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, 'b' ], [ 5, 6, 'a' ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, 'a' ], [ 5, 6, 'A' ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, 'a' ], [ 5, 6, '' ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, [ ] ], [ 5, 6, 9 ,9 ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, [ ] ], [ 5, 6, true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, { } ], [ 5, 6, true ])); + assertFalse(AHUACATL_RELATIONAL_LESS([ 5, 6, { } ], [ 5, 6, 9, 9 ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_GREATER function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalGreaterTrue : function () { + assertTrue(AHUACATL_RELATIONAL_GREATER(true, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER(false, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0, 1 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 1, 2 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 0 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ '0' : false }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATER(false, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATER(true, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0, NaN)); + + assertTrue(AHUACATL_RELATIONAL_GREATER(false, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(true, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER('abcd', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER('null', null)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ null ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ }, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : null }, null)); + assertTrue(AHUACATL_RELATIONAL_GREATER(true, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER('abcd', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER('true', false)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ null ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ }, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : null }, false)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0, true)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, true)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1, true)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER('abcd', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER('true', true)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ null ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ }, true)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : null }, true)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER(2, 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER(100, 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER(100, 20)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, -100)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-10, -100)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-10, -11)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1000, 999)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1, -1)); + assertTrue(AHUACATL_RELATIONAL_GREATER(0, -1)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1.01, 1.0)); + assertTrue(AHUACATL_RELATIONAL_GREATER(1.2, 1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1.110, -1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATER(-1.1109, -1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('true', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('false', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('null', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('0', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('1', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-1', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('true', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('false', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('null', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-100', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-1.1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-0.0', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER('-1', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATER('10', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATER('10000', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], 0)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], 10)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0, 1 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 99 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 100 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 101 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 0 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 99 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 100 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 101 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1000 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : false }, 'zz')); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 'a' }, 'zz')); + assertTrue(AHUACATL_RELATIONAL_GREATER(' ', '')); + assertTrue(AHUACATL_RELATIONAL_GREATER('a', '0')); + assertTrue(AHUACATL_RELATIONAL_GREATER('a ', 'a')); + assertTrue(AHUACATL_RELATIONAL_GREATER('b', 'a')); + assertTrue(AHUACATL_RELATIONAL_GREATER('a', 'A')); + assertTrue(AHUACATL_RELATIONAL_GREATER('Ab', 'AB')); + assertTrue(AHUACATL_RELATIONAL_GREATER('bbcd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATER('abda', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATER('abdd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATER('abcde', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATER('abcde', '0abcde')); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 1 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0, 1, 2, 3 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0, 1, 3 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 1, 0, 0 ], [ 0, 1, 4 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 1 ], [ 0, 1, 4 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 110 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 15, 100 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ undefined ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ null ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ -1 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '0' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 'abcd' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ ] ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ null ] ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ { } ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ ] ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ -1 ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '0' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 'abcd' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ ] ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ false ] ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 0 ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ -1 ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ '0' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ 'abcd' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ ] ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ [ false] ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ true ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false, true ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ false, 0 ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATER([ null, false ], [ null, null ])); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 0 }, { })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 2 }, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'A' : 2 }, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'A' : 1 }, { 'a' : 2 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1, 'b' : 2, 'c' : null }, { 'a' : 1, 'b' : 2 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1 }, { 'b' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : 1, 'b' : 2, 'c': null }, { 'b' : 2, 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ 9 ], 'b' : false })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ 9 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATER({ 'a' : [ 10, 1 ] }, { 'a' : [ 10 ], 'b' : true })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_GREATER function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalGreaterFalse : function () { + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, undefined)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, null)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, undefined)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, null)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, NaN)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, NaN)); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, null)); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, undefined)); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, false)); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, true)); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(NaN, 0)); + + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, true)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, false)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, 0.0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, 1.0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, -1.0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, { })); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, { 'a' : 0 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, { 'a' : 1 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(undefined, { '0' : false })); + + assertFalse(AHUACATL_RELATIONAL_GREATER(null, false)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, true)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, { })); + assertFalse(AHUACATL_RELATIONAL_GREATER(null, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, false)); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, true)); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, true)); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, { })); + assertFalse(AHUACATL_RELATIONAL_GREATER(false, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, { })); + assertFalse(AHUACATL_RELATIONAL_GREATER(true, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-10, -10)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-100, -100)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-334.5, -334.5)); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 2)); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 100)); + assertFalse(AHUACATL_RELATIONAL_GREATER(20, 100)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-100, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-100, -10)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-11, -10)); + assertFalse(AHUACATL_RELATIONAL_GREATER(999, 1000)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-1, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-1, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATER(1.0, 1.01)); + assertFalse(AHUACATL_RELATIONAL_GREATER(1.111, 1.2)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-1.111, -1.110)); + assertFalse(AHUACATL_RELATIONAL_GREATER(-1.111, -1.1109)); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, 'false')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 'false')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '-100')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '-1.1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, '-0.0')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1000, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1000, '10')); + assertFalse(AHUACATL_RELATIONAL_GREATER(1000, '10000')); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(0, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(10, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ 99 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ 100 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, [ 101 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 0 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 1 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 99 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 100 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 101 })); + assertFalse(AHUACATL_RELATIONAL_GREATER(100, { 'a' : 1000 })); + assertFalse(AHUACATL_RELATIONAL_GREATER('', '')); + assertFalse(AHUACATL_RELATIONAL_GREATER(' ', ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER('a', 'a')); + assertFalse(AHUACATL_RELATIONAL_GREATER(' a', ' a')); + assertFalse(AHUACATL_RELATIONAL_GREATER('abcd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATER('', ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATER('0', 'a')); + assertFalse(AHUACATL_RELATIONAL_GREATER('a', 'a ')); + assertFalse(AHUACATL_RELATIONAL_GREATER('a', 'b')); + assertFalse(AHUACATL_RELATIONAL_GREATER('A', 'a')); + assertFalse(AHUACATL_RELATIONAL_GREATER('AB', 'Ab')); + assertFalse(AHUACATL_RELATIONAL_GREATER('abcd', 'bbcd')); + assertFalse(AHUACATL_RELATIONAL_GREATER('abcd', 'abda')); + assertFalse(AHUACATL_RELATIONAL_GREATER('abcd', 'abdd')); + assertFalse(AHUACATL_RELATIONAL_GREATER('abcd', 'abcde')); + assertFalse(AHUACATL_RELATIONAL_GREATER('0abcd', 'abcde')); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 1 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ [ 0, 1, 2 ] ], [ [ 0, 1, 2 ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ [ 1, [ "true", 0, -99 , false ] ], 4 ], [ [ 1, [ "true", 0, -99, false ] ], 4 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0, 1, 2 ], [ 0, 1, 2, 3 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0, 1, 2 ], [ 0, 1, 3 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0, 1, 4 ], [ 1, 0, 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 0, 1, 4 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 15, 99 ], [ 110 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ 15, 99 ], [ 15, 100 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ undefined ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ [ null ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ ], [ { } ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ null ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ null ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ null ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ null ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false ], [ [ false ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ true ], [ [ false ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false, false ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false, false ], [ false, true ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ false, false ], [ false, 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATER([ null, null ], [ null, false ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_LESSEQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalLessEqualTrue : function () { + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, undefined)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, null)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, undefined)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, true)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, false)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, 0.0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, 1.0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, -1.0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, [ 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, { '0' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, false)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, true)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, null)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(NaN, undefined)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, NaN)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(undefined, NaN)); + + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, false)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, true)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, -1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(null, null)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, true)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, -1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(false, false)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, -1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(true, true)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 2)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 100)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(20, 100)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-100, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-100, -10)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-11, -10)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(999, 1000)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1.0, 1.01)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1.111, 1.2)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1.111, -1.110)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1.111, -1.1109)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, 0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(2, 2)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(20, 20)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, 100)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-100, -100)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-11, -11)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(999, 999)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1, -1)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1.0, 1.0)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1.111, 1.111)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1.2, 1.2)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(-1.111, -1.111)); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, 'false')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, '1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 'true')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 'false')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1, 'null')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '-100')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '-1.1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, '-0.0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1000, '-1')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1000, '10')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(1000, '10000')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(0, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(10, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ 0, 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ 99 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ 100 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, [ 101 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 0 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 99 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 100 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 101 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(100, { 'a' : 1000 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('', ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('0', 'a')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('a', 'a ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('a', 'b')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('A', 'a')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('AB', 'Ab')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('abcd', 'bbcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('abcd', 'abda')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('abcd', 'abdd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('abcd', 'abcde')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('0abcd', 'abcde')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(' abcd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('', '')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('0', '0')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('a', 'a')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('A', 'A')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('AB', 'AB')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('Ab', 'Ab')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('abcd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL('0abcd', '0abcd')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(' ', ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL(' ', ' ')); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 2 ], [ 0, 1, 2, 3 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 2 ], [ 0, 1, 3 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 4 ], [ 1, 0, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 4 ], [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 15, 99 ], [ 110 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 15, 99 ], [ 15, 100 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ undefined ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ [ null ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ { } ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], [ ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 2 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 15, 99 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ [ [ null, 1, 9 ], [ 12, "true", false ] ] , 0 ], [ [ [ null, 1, 9 ], [ 12, "true", false ] ] ,0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false, true ], [ false, true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ [ false ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ -1 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ '' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ '0' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ [ false ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false, false ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false, false ], [ false, true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false, false ], [ false, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null, null ], [ null, false ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], { 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], { 'a' : null })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ '' ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ null ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ false ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ true ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 'abcd' ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5 ], { 'a' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6 ], { 'a' : 2, 'b' : 2 })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 7 ], { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, false ], [ 5, 6, true ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, true ], [ 5, 6, 0 ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 999 ], [ 5, 6, '' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 'a' ], [ 5, 6, 'b' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 'A' ], [ 5, 6, 'a' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, '' ], [ 5, 6, 'a' ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 9, 9 ], [ 5, 6, [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, true ], [ 5, 6, [ ] ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, true ], [ 5, 6, { } ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL([ 5, 6, 9, 9 ], [ 5, 6, { } ])); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL({ }, { })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL({ 'A' : true }, { 'A' : true })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : true, 'b' : false }, { 'a' : true, 'b' : false })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : true, 'b' : false }, { 'b' : false, 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : true, 'b' : { 'c' : 1, 'f' : 2 }, 'x' : 9 }, { 'x' : 9, 'b' : { 'f' : 2, 'c' : 1 }, 'a' : true })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_LESSEQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalLessEqualFalse : function () { + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(true, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(false, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1.0, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 1, 2 ], undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 0 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 1 }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ '0' : false }, undefined)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(false, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(true, NaN)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', NaN)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0, NaN)); + + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(false, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(true, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abcd', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('null', null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false ], null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ null ], null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ }, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : null }, null)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(true, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abcd', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('true', false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false ], false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ null ], false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ }, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : null }, false)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0, true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1, true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abcd', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('true', true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false ], true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ null ], true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ }, true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : null }, true)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(2, 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(100, 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(100, 20)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, -100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-10, -100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-10, -11)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1000, 999)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1, -1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(0, -1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1.01, 1.0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(1.2, 1.111)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1.110, -1.111)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(-1.1109, -1.111)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('true', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('false', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('null', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('0', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('1', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-1', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('true', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('false', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('null', 1)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-100', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-1.1', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-0.0', 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('-1', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('10', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('10000', 1000)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], 0)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], 10)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 99 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 100 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 101 ], 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 0 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 1 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 99 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 100 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 101 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 1000 }, 100)); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : false }, 'zz')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL({ 'a' : 'a' }, 'zz')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL(' ', '')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('a', '0')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('a ', 'a')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('b', 'a')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('a', 'A')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('Ab', 'AB')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('bbcd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abda', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abdd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abcde', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL('abcde', '0abcde')); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 1 ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 2, 3 ], [ 0, 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0, 1, 3 ], [ 0, 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 1, 0, 0 ], [ 0, 1, 4 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 1 ], [ 0, 1, 4 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 110 ], [ 15, 99 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 15, 100 ], [ 15, 99 ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ undefined ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ null ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ -1 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '0' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 'abcd' ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ ] ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ null ] ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ { } ], [ ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ ] ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ -1 ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '0' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 'abcd' ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ ] ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ false ] ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 0 ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ -1 ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ '0' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ 'abcd' ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ ] ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ [ false] ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ true ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false, true ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ false, 0 ], [ false, false ])); + assertFalse(AHUACATL_RELATIONAL_LESSEQUAL([ null, false ], [ null, null ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_GREATEREQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalGreaterEqualTrue : function () { + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(null, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(null, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(true, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(false, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1.0, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(false, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(true, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, NaN)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 1, 2 ], undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 0 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1 }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ '0' : false }, undefined)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(false, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(true, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('null', null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : null }, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(true, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('true', false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : null }, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('true', true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : null }, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(2, 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(100, 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(100, 20)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, -100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-10, -100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-10, -11)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1000, 999)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, -1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, -1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.01, 1.0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.2, 1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1.110, -1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1.1109, -1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('true', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('false', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('null', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('1', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-1', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('true', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('false', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('null', 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-100', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-1.1', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-0.0', 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('-1', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('10', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('10000', 1000)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], 10)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 99 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 100 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 101 ], 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 0 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 99 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 100 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 101 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1000 }, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, 'zz')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 'a' }, 'zz')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', '')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('a', '0')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('a ', 'a')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('b', 'a')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('a', 'A')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('Ab', 'AB')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('bbcd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abda', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abdd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcde', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcde', '0abcde')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 1 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 2, 3 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 3 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 1, 0, 0 ], [ 0, 1, 4 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 1 ], [ 0, 1, 4 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 110 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 15, 100 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ undefined ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ -1 ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '0' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 'abcd' ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ ] ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ null ] ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ { } ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ ] ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ -1 ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '0' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 'abcd' ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ ] ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ false ] ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ -1 ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ '0' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 'abcd' ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ ] ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ false] ], [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false, true ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false, 0 ], [ false, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null, false ], [ null, null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(null, null)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(false, false)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(true, true)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(0, 0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1, 1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(2, 2)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(20, 20)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(100, 100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-100, -100)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-11, -11)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(999, 999)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1, -1)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.0, 1.0)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.111, 1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(1.2, 1.2)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(-1.111, -1.111)); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('', '')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0', '0')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('a', 'a')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('A', 'A')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('AB', 'AB')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('Ab', 'Ab')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', 'abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL('0abcd', '0abcd')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', ' ')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL(' ', ' ')); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 2 ], [ 0, 1, 2 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 15, 99 ], [ 15, 99 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ [ [ null, 1, 9 ], [ 12, "true", false ] ] , 0 ], [ [ [ null, 1, 9 ], [ 12, "true", false ] ] ,0 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ false, true ], [ false, true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : true }, [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : null }, [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, [ ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ '' ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ null ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, [ false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, [ true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, [ 'abcd' ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : false }, [ 5 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 2, 'b' : 2 }, [ 5, 6 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, [ 5, 6, 7 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, true ], [ 5, 6, false ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, 0 ], [ 5, 6, true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, '' ], [ 5, 6, 999 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, 'b' ], [ 5, 6, 'a' ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, 'a' ], [ 5, 6, 'A' ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, 'a' ], [ 5, 6, '' ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, [ ] ], [ 5, 6, 9, 9 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, [ ] ], [ 5, 6, true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, { } ], [ 5, 6, true ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL([ 5, 6, { } ], [ 5, 6, 9, 9 ])); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 0 }, { })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 2 }, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'A' : 2 }, { 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'A' : 1 }, { 'a' : 2 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1, 'b' : 2, 'c' : null }, { 'a' : 1, 'b' : 2 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1 }, { 'b' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : 1, 'b' : 2, 'c': null }, { 'b' : 2, 'a' : 1 })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ 9 ], 'b' : false })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ 9 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : [ 10 ], 'b' : true }, { 'a' : [ ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : [ 10, 1 ] }, { 'a' : [ 10 ], 'b' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ }, { })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'A' : true }, { 'A' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : true, 'b' : false }, { 'a' : true, 'b' : false })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : true, 'b' : false }, { 'b' : false, 'a' : true })); + assertTrue(AHUACATL_RELATIONAL_GREATEREQUAL({ 'a' : true, 'b' : { 'c' : 1, 'f' : 2 }, 'x' : 9 }, { 'x' : 9, 'b' : { 'f' : 2, 'c' : 1 }, 'a' : true })); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_GREATEREQUAL function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalGreaterEqualFalse : function () { + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, true)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, false)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, 0.0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, 1.0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, -1.0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, { })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, { 'a' : 0 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, { 'a' : 1 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(undefined, { '0' : false })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, false)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, true)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(NaN, 0)); + + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, false)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, true)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, { })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(null, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, true)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, { })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(false, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, -1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, { })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(true, { 'a' : null })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, 2)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, 100)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(20, 100)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-100, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-100, -10)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-11, -10)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(999, 1000)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-1, 1)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-1, 0)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1.0, 1.01)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1.111, 1.2)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-1.111, -1.110)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(-1.111, -1.1109)); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, 'false')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, '')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, '0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, '1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, 'true')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, 'false')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1, 'null')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '-100')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '-1.1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, '-0.0')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1000, '-1')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1000, '10')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(1000, '10000')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(0, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(10, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ 99 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ 100 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, [ 101 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 0 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 1 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 99 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 100 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 101 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(100, { 'a' : 1000 })); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('', ' ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('0', 'a')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('a', 'a ')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('a', 'b')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('A', 'a')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('AB', 'Ab')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', 'bbcd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', 'abda')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', 'abdd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('abcd', 'abcde')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL('0abcd', 'abcde')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL(' abcd', 'abcd')); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 0 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 2 ], [ 0, 1, 2, 3 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 2 ], [ 0, 1, 3 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 4 ], [ 1, 0, 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 0, 1, 4 ], [ 1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 15, 99 ], [ 110 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ 15, 99 ], [ 15, 100 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ undefined ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ null ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ [ null ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ ], [ { } ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ false ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ null ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false ], [ [ false ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ -1 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ '' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ '0' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ 'abcd' ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ [ ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ true ], [ [ false ] ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false, false ], [ true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false, false ], [ false, true ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ false, false ], [ false, 0 ])); + assertFalse(AHUACATL_RELATIONAL_GREATEREQUAL([ null, null ], [ null, false ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_IN function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalInUndefined : function () { + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, 0.0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, 1.0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, -1.0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, '0'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, { 'a' : 1 }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, { '0' : false }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0.0, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1.0, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(-1.0, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN('0', undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN('1', undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0, 1 ], undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1, 2 ], undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ 'a' : 1 }, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ '0' : false }, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(NaN, undefined); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, NaN); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, NaN); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', NaN); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, NaN); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, NaN); }); + assertException(function() { AHUACATL_RELATIONAL_IN(undefined, NaN); }); + + assertException(function() { AHUACATL_RELATIONAL_IN(null, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(null, { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(false, { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(true, { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(0, { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN(1, { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', null); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', false); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', true); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN('', { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', null); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', false); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', true); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN('a', { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], null); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], false); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], true); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ ], { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], null); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], false); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], true); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 0 ], { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], null); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], false); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], true); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN([ 1 ], { 'A' : true }); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, null); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, false); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, true); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, 0); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, 1); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, ''); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, '1'); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, 'a'); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, { }); }); + assertException(function() { AHUACATL_RELATIONAL_IN({ }, { 'A' : true }); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_IN function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalInTrue : function () { + assertTrue(AHUACATL_RELATIONAL_IN(null, [ null ])); + assertTrue(AHUACATL_RELATIONAL_IN(null, [ null, false ])); + assertTrue(AHUACATL_RELATIONAL_IN(null, [ false, null ])); + assertTrue(AHUACATL_RELATIONAL_IN(false, [ false ])); + assertTrue(AHUACATL_RELATIONAL_IN(false, [ true, false ])); + assertTrue(AHUACATL_RELATIONAL_IN(false, [ 0, false ])); + assertTrue(AHUACATL_RELATIONAL_IN(true, [ true ])); + assertTrue(AHUACATL_RELATIONAL_IN(true, [ false, true ])); + assertTrue(AHUACATL_RELATIONAL_IN(true, [ 0, false, true ])); + assertTrue(AHUACATL_RELATIONAL_IN(0, [ 0 ])); + assertTrue(AHUACATL_RELATIONAL_IN(1, [ 1 ])); + assertTrue(AHUACATL_RELATIONAL_IN(0, [ 3, 2, 1, 0 ])); + assertTrue(AHUACATL_RELATIONAL_IN(1, [ 3, 2, 1, 0 ])); + assertTrue(AHUACATL_RELATIONAL_IN(-35.5, [ 3, 2, 1, -35.5, 0 ])); + assertTrue(AHUACATL_RELATIONAL_IN(1.23e32, [ 3, 2, 1, 1.23e32, 35.5, 0 ])); + assertTrue(AHUACATL_RELATIONAL_IN('', [ '' ])); + assertTrue(AHUACATL_RELATIONAL_IN('', [ ' ', '' ])); + assertTrue(AHUACATL_RELATIONAL_IN('', [ 'a', 'b', 'c', '' ])); + assertTrue(AHUACATL_RELATIONAL_IN('A', [ 'c', 'b', 'a', 'A' ])); + assertTrue(AHUACATL_RELATIONAL_IN(' ', [ ' ' ])); + assertTrue(AHUACATL_RELATIONAL_IN(' a', [ ' a' ])); + assertTrue(AHUACATL_RELATIONAL_IN(' a ', [ ' a ' ])); + assertTrue(AHUACATL_RELATIONAL_IN([ ], [ [ ] ])); + assertTrue(AHUACATL_RELATIONAL_IN([ ], [ 1, null, 2, 3, [ ], 5 ])); + assertTrue(AHUACATL_RELATIONAL_IN([ null ], [ [ null ] ])); + assertTrue(AHUACATL_RELATIONAL_IN([ null ], [ null, [ null ], true ])); + assertTrue(AHUACATL_RELATIONAL_IN([ null, false ], [ [ null, false ] ])); + assertTrue(AHUACATL_RELATIONAL_IN([ 'a', 'A', false ], [ 'a', true, [ 'a', 'A', false ] ])); + assertTrue(AHUACATL_RELATIONAL_IN({ }, [ { } ])); + assertTrue(AHUACATL_RELATIONAL_IN({ }, [ 'a', null, false, 0, { } ])); + assertTrue(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ 'a', null, false, 0, { 'a' : true } ])); + assertTrue(AHUACATL_RELATIONAL_IN({ 'a' : true, 'A': false }, [ 'a', null, false, 0, { 'A' : false, 'a' : true } ])); + assertTrue(AHUACATL_RELATIONAL_IN({ 'a' : { 'b' : null, 'c': 1 } }, [ { 'a' : { 'c' : 1, 'b' : null } } ])); + assertTrue(AHUACATL_RELATIONAL_IN({ 'a' : { 'b' : null, 'c': 1 } }, [ 'a', 'b', { 'a' : { 'c' : 1, 'b' : null } } ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_RELATIONAL_IN function +//////////////////////////////////////////////////////////////////////////////// + + testRelationalInFalse : function () { + assertFalse(AHUACATL_RELATIONAL_IN(undefined, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(undefined, [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_IN(undefined, [ 0, 1 ])); + assertFalse(AHUACATL_RELATIONAL_IN(undefined, [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN(null, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(false, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(true, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(0, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(1, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN('', [ ])); + assertFalse(AHUACATL_RELATIONAL_IN('0', [ ])); + assertFalse(AHUACATL_RELATIONAL_IN('1', [ ])); + assertFalse(AHUACATL_RELATIONAL_IN([ ], [ ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 0 ], [ ])); + assertFalse(AHUACATL_RELATIONAL_IN({ }, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ ])); + assertFalse(AHUACATL_RELATIONAL_IN(null, [ '0', '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(true, [ '0', '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(false, [ '0', '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(0, [ '0', '1', '', 'null', 'true', 'false', -1, 1, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(1, [ '0', '1', '', 'null', 'true', 'false', -1, 0, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(-1, [ '0', '1', '', 'null', 'true', 'false', 0, 1, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN('', [ '0', '1', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN('0', [ '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN('1', [ '0', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, false, { }, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN([ ], [ '0', '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, false, { } ])); + assertFalse(AHUACATL_RELATIONAL_IN({ }, [ '0', '1', '', 'null', 'true', 'false', -1, 0, 1, 2, 3, null, true, false, [ ] ])); + assertFalse(AHUACATL_RELATIONAL_IN(null, [ [ null ]])); + assertFalse(AHUACATL_RELATIONAL_IN(false, [ [ false ]])); + assertFalse(AHUACATL_RELATIONAL_IN(true, [ [ true ]])); + assertFalse(AHUACATL_RELATIONAL_IN(0, [ [ 0 ]])); + assertFalse(AHUACATL_RELATIONAL_IN(1, [ [ 1 ]])); + assertFalse(AHUACATL_RELATIONAL_IN('', [ [ '' ]])); + assertFalse(AHUACATL_RELATIONAL_IN('1', [ [ '1' ]])); + assertFalse(AHUACATL_RELATIONAL_IN('', [ [ '' ]])); + assertFalse(AHUACATL_RELATIONAL_IN(' ', [ [ ' ' ]])); + assertFalse(AHUACATL_RELATIONAL_IN('a', [ 'A' ])); + assertFalse(AHUACATL_RELATIONAL_IN('a', [ 'b', 'c', 'd' ])); + assertFalse(AHUACATL_RELATIONAL_IN('', [ ' ', ' ' ])); + assertFalse(AHUACATL_RELATIONAL_IN(' ', [ '', ' ' ])); + assertFalse(AHUACATL_RELATIONAL_IN([ ], [ 0 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ ], [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 0 ], [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1 ], [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 2 ], [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2 ], [ 1, 2 ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2 ], [ [ 1 ], [ 2 ] ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2 ], [ [ 2, 1 ] ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2 ], [ [ 1, 2, 3 ] ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2, 3 ], [ [ 1, 2, 4 ] ])); + assertFalse(AHUACATL_RELATIONAL_IN([ 1, 2, 3 ], [ [ 0, 1, 2, 3 ] ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ { 'a' : true, 'b' : false } ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ { 'a' : false } ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ { 'b' : true } ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ [ { 'a' : true } ] ])); + assertFalse(AHUACATL_RELATIONAL_IN({ 'a' : true }, [ 1, 2, { 'a' : { 'a' : true } } ])); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_UNARY_PLUS function +//////////////////////////////////////////////////////////////////////////////// + + testUnaryPlusUndefined : function () { + assertException(function() { AHUACATL_UNARY_PLUS(undefined); }); + assertException(function() { AHUACATL_UNARY_PLUS(null); }); + assertException(function() { AHUACATL_UNARY_PLUS(NaN); }); + assertException(function() { AHUACATL_UNARY_PLUS(false); }); + assertException(function() { AHUACATL_UNARY_PLUS(true); }); + assertException(function() { AHUACATL_UNARY_PLUS(' '); }); + assertException(function() { AHUACATL_UNARY_PLUS('abc'); }); + assertException(function() { AHUACATL_UNARY_PLUS('1abc'); }); + assertException(function() { AHUACATL_UNARY_PLUS(''); }); + assertException(function() { AHUACATL_UNARY_PLUS('-1'); }); + assertException(function() { AHUACATL_UNARY_PLUS('0'); }); + assertException(function() { AHUACATL_UNARY_PLUS('1'); }); + assertException(function() { AHUACATL_UNARY_PLUS('1.5'); }); + assertException(function() { AHUACATL_UNARY_PLUS([ ]); }); + assertException(function() { AHUACATL_UNARY_PLUS([ 0 ]); }); + assertException(function() { AHUACATL_UNARY_PLUS([ 1 ]); }); + assertException(function() { AHUACATL_UNARY_PLUS({ 'a' : 1 }); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_UNARY_PLUS function +//////////////////////////////////////////////////////////////////////////////// + + testUnaryPlusValue : function () { + assertEqual(0, AHUACATL_UNARY_PLUS(0)); + assertEqual(1, AHUACATL_UNARY_PLUS(1)); + assertEqual(-1, AHUACATL_UNARY_PLUS(-1)); + assertEqual(0.0001, AHUACATL_UNARY_PLUS(0.0001)); + assertEqual(-0.0001, AHUACATL_UNARY_PLUS(-0.0001)); + assertEqual(100, AHUACATL_UNARY_PLUS(100)); + assertEqual(1054.342, AHUACATL_UNARY_PLUS(1054.342)); + assertEqual(-1054.342, AHUACATL_UNARY_PLUS(-1054.342)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_UNARY_MINUS function +//////////////////////////////////////////////////////////////////////////////// + + testUnaryMinusUndefined : function () { + assertException(function() { AHUACATL_UNARY_MINUS(undefined); }); + assertException(function() { AHUACATL_UNARY_MINUS(null); }); + assertException(function() { AHUACATL_UNARY_MINUS(false); }); + assertException(function() { AHUACATL_UNARY_MINUS(true); }); + assertException(function() { AHUACATL_UNARY_MINUS(' '); }); + assertException(function() { AHUACATL_UNARY_MINUS('abc'); }); + assertException(function() { AHUACATL_UNARY_MINUS('1abc'); }); + assertException(function() { AHUACATL_UNARY_MINUS(''); }); + assertException(function() { AHUACATL_UNARY_MINUS('-1'); }); + assertException(function() { AHUACATL_UNARY_MINUS('0'); }); + assertException(function() { AHUACATL_UNARY_MINUS('1'); }); + assertException(function() { AHUACATL_UNARY_MINUS('1.5'); }); + assertException(function() { AHUACATL_UNARY_MINUS([ ]); }); + assertException(function() { AHUACATL_UNARY_MINUS([ 0 ]); }); + assertException(function() { AHUACATL_UNARY_MINUS([ 1 ]); }); + assertException(function() { AHUACATL_UNARY_MINUS({ 'a' : 1 }); }); + assertException(function() { AHUACATL_UNARY_PLUS(NaN); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_UNARY_MINUS function +//////////////////////////////////////////////////////////////////////////////// + + testUnaryMinusValue : function () { + assertEqual(0, AHUACATL_UNARY_MINUS(0)); + assertEqual(1, AHUACATL_UNARY_MINUS(-1)); + assertEqual(-1, AHUACATL_UNARY_MINUS(1)); + assertEqual(0.0001, AHUACATL_UNARY_MINUS(-0.0001)); + assertEqual(-0.0001, AHUACATL_UNARY_MINUS(0.0001)); + assertEqual(100, AHUACATL_UNARY_MINUS(-100)); + assertEqual(-100, AHUACATL_UNARY_MINUS(100)); + assertEqual(1054.342, AHUACATL_UNARY_MINUS(-1054.342)); + assertEqual(-1054.342, AHUACATL_UNARY_MINUS(1054.342)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_PLUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticPlusUndefined : function () { + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, null); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, false); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, true); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, 2); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, -1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(undefined, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(null, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(false, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(true, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(0, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(2, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(-1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('0', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(' ', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('a', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS([ ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS([ 1 ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS({ }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(NaN, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, null); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, false); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, true); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, '1'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, [ 0 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(NaN, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(null, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(false, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(true, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(' ', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('0', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('1', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('a', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS([ ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS([ 0 ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS({ }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS('0', '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_PLUS(1.3e317, 1.3e317); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_PLUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticPlusValue : function () { + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(0, 0)); + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(1, -1)); + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(-1, 1)); + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(-100, 100)); + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(100, -100)); + assertEqual(0, AHUACATL_ARITHMETIC_PLUS(0.11, -0.11)); + assertEqual(10, AHUACATL_ARITHMETIC_PLUS(5, 5)); + assertEqual(10, AHUACATL_ARITHMETIC_PLUS(4, 6)); + assertEqual(10, AHUACATL_ARITHMETIC_PLUS(1, 9)); + assertEqual(10, AHUACATL_ARITHMETIC_PLUS(0.1, 9.9)); + assertEqual(9.8, AHUACATL_ARITHMETIC_PLUS(-0.1, 9.9)); + assertEqual(-34.2, AHUACATL_ARITHMETIC_PLUS(-17.1, -17.1)); + assertEqual(-2, AHUACATL_ARITHMETIC_PLUS(-1, -1)); + assertEqual(2.6e307, AHUACATL_ARITHMETIC_PLUS(1.3e307, 1.3e307)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_MINUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticMinusUndefined : function () { + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, null); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, false); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, true); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, 2); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, -1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(undefined, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(null, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(false, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(true, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(0, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(2, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(-1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('0', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(' ', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('a', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS([ ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS([ 1 ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS({ }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(NaN, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, null); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, false); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, true); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, '1'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, [ 0 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(NaN, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(null, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(false, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(true, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(' ', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('0', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('1', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('a', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS([ ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS([ 0 ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS({ }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS('0', '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_MINUS(-1.3e317, 1.3e317); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_MINUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticMinusValue : function () { + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(0, 0)); + assertEqual(-1, AHUACATL_ARITHMETIC_MINUS(0, 1)); + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(-1, -1)); + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(1, 1)); + assertEqual(2, AHUACATL_ARITHMETIC_MINUS(1, -1)); + assertEqual(-2, AHUACATL_ARITHMETIC_MINUS(-1, 1)); + assertEqual(-200, AHUACATL_ARITHMETIC_MINUS(-100, 100)); + assertEqual(200, AHUACATL_ARITHMETIC_MINUS(100, -100)); + assertEqual(0.22, AHUACATL_ARITHMETIC_MINUS(0.11, -0.11)); + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(5, 5)); + assertEqual(-2, AHUACATL_ARITHMETIC_MINUS(4, 6)); + assertEqual(-8, AHUACATL_ARITHMETIC_MINUS(1, 9)); + assertEqual(-9.8, AHUACATL_ARITHMETIC_MINUS(0.1, 9.9)); + assertEqual(-10, AHUACATL_ARITHMETIC_MINUS(-0.1, 9.9)); + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(-17.1, -17.1)); + assertEqual(0, AHUACATL_ARITHMETIC_MINUS(1.3e307, 1.3e307)); + assertEqual(2.6e307, AHUACATL_ARITHMETIC_MINUS(1.3e307, -1.3e307)); + assertEqual(-2.6e307, AHUACATL_ARITHMETIC_MINUS(-1.3e307, 1.3e307)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_TIMES function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticTimesUndefined : function () { + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, null); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, false); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, true); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, 2); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, -1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(undefined, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(null, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(false, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(true, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(0, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(2, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(-1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('0', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(' ', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('a', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES([ ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES([ 1 ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES({ }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(NaN, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, null); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, false); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, true); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, '1'); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, [ 0 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(NaN, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(null, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(false, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(true, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(' ', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('0', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('1', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('a', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES([ ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES([ 0 ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES({ }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1.3e190, 1.3e190); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1.3e307, 1.3e307); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES(1.3e317, 1.3e317); }); + assertException(function() { AHUACATL_ARITHMETIC_TIMES('0', '0'); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_TIMES function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticTimesValue : function () { + assertEqual(0, AHUACATL_ARITHMETIC_TIMES(0, 0)); + assertEqual(0, AHUACATL_ARITHMETIC_TIMES(1, 0)); + assertEqual(0, AHUACATL_ARITHMETIC_TIMES(0, 1)); + assertEqual(1, AHUACATL_ARITHMETIC_TIMES(1, 1)); + assertEqual(2, AHUACATL_ARITHMETIC_TIMES(2, 1)); + assertEqual(2, AHUACATL_ARITHMETIC_TIMES(1, 2)); + assertEqual(4, AHUACATL_ARITHMETIC_TIMES(2, 2)); + assertEqual(100, AHUACATL_ARITHMETIC_TIMES(10, 10)); + assertEqual(1000, AHUACATL_ARITHMETIC_TIMES(10, 100)); + assertEqual(1.44, AHUACATL_ARITHMETIC_TIMES(1.2, 1.2)); + assertEqual(-1.44, AHUACATL_ARITHMETIC_TIMES(1.2, -1.2)); + assertEqual(1.44, AHUACATL_ARITHMETIC_TIMES(-1.2, -1.2)); + assertEqual(2, AHUACATL_ARITHMETIC_TIMES(0.25, 8)); + assertEqual(2, AHUACATL_ARITHMETIC_TIMES(8, 0.25)); + assertEqual(2.25, AHUACATL_ARITHMETIC_TIMES(9, 0.25)); + assertEqual(-2.25, AHUACATL_ARITHMETIC_TIMES(9, -0.25)); + assertEqual(-2.25, AHUACATL_ARITHMETIC_TIMES(-9, 0.25)); + assertEqual(2.25, AHUACATL_ARITHMETIC_TIMES(-9, -0.25)); + assertEqual(4, AHUACATL_ARITHMETIC_TIMES(-2, -2)); + assertEqual(-4, AHUACATL_ARITHMETIC_TIMES(-2, 2)); + assertEqual(-4, AHUACATL_ARITHMETIC_TIMES(2, -2)); + assertEqual(1000000, AHUACATL_ARITHMETIC_TIMES(1000, 1000)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_DIVIDE function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticDivideUndefined : function () { + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, null); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, false); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, true); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, 2); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, -1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(undefined, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(null, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(false, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(true, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(0, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(2, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(-1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('0', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(' ', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('a', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE([ ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE([ 1 ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE({ }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(NaN, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, null); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, false); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, true); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, '1'); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, [ 0 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(NaN, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(null, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(false, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(true, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(' ', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('0', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('1', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('a', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE([ ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE([ 0 ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE({ }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(1, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(100, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(-1, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(-100, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE(0, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_DIVIDE('0', '0'); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_DIVIDE function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticDivideValue : function () { + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, 1)); + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, 2)); + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, 10)); + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, -1)); + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, -2)); + assertEqual(0, AHUACATL_ARITHMETIC_DIVIDE(0, -10)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(1, 1)); + assertEqual(2, AHUACATL_ARITHMETIC_DIVIDE(2, 1)); + assertEqual(-1, AHUACATL_ARITHMETIC_DIVIDE(-1, 1)); + assertEqual(100, AHUACATL_ARITHMETIC_DIVIDE(100, 1)); + assertEqual(-100, AHUACATL_ARITHMETIC_DIVIDE(-100, 1)); + assertEqual(-1, AHUACATL_ARITHMETIC_DIVIDE(1, -1)); + assertEqual(-2, AHUACATL_ARITHMETIC_DIVIDE(2, -1)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(-1, -1)); + assertEqual(-100, AHUACATL_ARITHMETIC_DIVIDE(100, -1)); + assertEqual(100, AHUACATL_ARITHMETIC_DIVIDE(-100, -1)); + assertEqual(0.5, AHUACATL_ARITHMETIC_DIVIDE(1, 2)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(2, 2)); + assertEqual(2, AHUACATL_ARITHMETIC_DIVIDE(4, 2)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(4, 4)); + assertEqual(5, AHUACATL_ARITHMETIC_DIVIDE(10, 2)); + assertEqual(2, AHUACATL_ARITHMETIC_DIVIDE(10, 5)); + assertEqual(2.5, AHUACATL_ARITHMETIC_DIVIDE(10, 4)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(1.2, 1.2)); + assertEqual(-1, AHUACATL_ARITHMETIC_DIVIDE(1.2, -1.2)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(-1.2, -1.2)); + assertEqual(2, AHUACATL_ARITHMETIC_DIVIDE(1, 0.5)); + assertEqual(4, AHUACATL_ARITHMETIC_DIVIDE(1, 0.25)); + assertEqual(16, AHUACATL_ARITHMETIC_DIVIDE(4, 0.25)); + assertEqual(-16, AHUACATL_ARITHMETIC_DIVIDE(4, -0.25)); + assertEqual(-16, AHUACATL_ARITHMETIC_DIVIDE(-4, 0.25)); + assertEqual(100, AHUACATL_ARITHMETIC_DIVIDE(25, 0.25)); + assertEqual(-100, AHUACATL_ARITHMETIC_DIVIDE(25, -0.25)); + assertEqual(-100, AHUACATL_ARITHMETIC_DIVIDE(-25, 0.25)); + assertEqual(1, AHUACATL_ARITHMETIC_DIVIDE(0.22, 0.22)); + assertEqual(0.5, AHUACATL_ARITHMETIC_DIVIDE(0.22, 0.44)); + assertEqual(2, AHUACATL_ARITHMETIC_DIVIDE(0.22, 0.11)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_MODULUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticModulusUndefined : function () { + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, null); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, false); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, true); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, 2); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, -1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(undefined, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(null, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(false, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(true, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(0, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(2, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(-1, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('0', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(' ', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('a', undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS([ ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS([ 1 ], undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS({ }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(NaN, undefined); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, NaN); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, null); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, false); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, true); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, ''); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, ' '); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, '0'); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, '1'); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, 'a'); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, [ ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, [ 0 ]); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, { }); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(NaN, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(null, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(false, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(true, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(' ', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('0', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('1', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS('a', 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS([ ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS([ 0 ], 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS({ }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(1, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(100, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(-1, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(-100, 0); }); + assertException(function() { AHUACATL_ARITHMETIC_MODULUS(0, 0); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_ARITHMETIC_MODULUS function +//////////////////////////////////////////////////////////////////////////////// + + testArithmeticModulusValue : function () { + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(0, 1)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(1, 1)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(1, 2)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(1, 3)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(1, 4)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(2, 2)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(2, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(3, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, 1)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, 2)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(10, 3)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(10, 4)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, 5)); + assertEqual(4, AHUACATL_ARITHMETIC_MODULUS(10, 6)); + assertEqual(3, AHUACATL_ARITHMETIC_MODULUS(10, 7)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(10, 8)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(10, 9)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, 10)); + assertEqual(10, AHUACATL_ARITHMETIC_MODULUS(10, 11)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(4, 3)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(5, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(6, 3)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(7, 3)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(8, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(9, 3)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(10, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, -1)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, -2)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(10, -3)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(10, -4)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, -5)); + assertEqual(4, AHUACATL_ARITHMETIC_MODULUS(10, -6)); + assertEqual(3, AHUACATL_ARITHMETIC_MODULUS(10, -7)); + assertEqual(2, AHUACATL_ARITHMETIC_MODULUS(10, -8)); + assertEqual(1, AHUACATL_ARITHMETIC_MODULUS(10, -9)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(10, -10)); + assertEqual(10, AHUACATL_ARITHMETIC_MODULUS(10, -11)); + assertEqual(-1, AHUACATL_ARITHMETIC_MODULUS(-1, 3)); + assertEqual(-2, AHUACATL_ARITHMETIC_MODULUS(-2, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(-3, 3)); + assertEqual(-1, AHUACATL_ARITHMETIC_MODULUS(-4, 3)); + assertEqual(-2, AHUACATL_ARITHMETIC_MODULUS(-5, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(-6, 3)); + assertEqual(-1, AHUACATL_ARITHMETIC_MODULUS(-7, 3)); + assertEqual(-2, AHUACATL_ARITHMETIC_MODULUS(-8, 3)); + assertEqual(0, AHUACATL_ARITHMETIC_MODULUS(-9, 3)); + assertEqual(-1, AHUACATL_ARITHMETIC_MODULUS(-10, 3)); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_STRING_CONCAT function +//////////////////////////////////////////////////////////////////////////////// + + testStringConcatUndefined : function () { + assertException(function() { AHUACATL_STRING_CONCAT(undefined, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, null); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, false); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, true); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, 2); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, -1); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, ''); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, '0'); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, ' '); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, 'a'); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, [ ]); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, [ 1 ]); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, { }); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, { 'a' : 0 }); }); + assertException(function() { AHUACATL_STRING_CONCAT(undefined, NaN); }); + assertException(function() { AHUACATL_STRING_CONCAT(null, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(false, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(true, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(0, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(2, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(-1, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT('', undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT('0', undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(' ', undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT([ ], undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT([ 1 ], undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT({ }, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT({ 'a' : 0 }, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(NaN, undefined); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, NaN); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, null); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, false); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, true); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, ''); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, ' '); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, '0'); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, '1'); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, 'a'); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, [ ]); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, [ 0 ]); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, { }); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, { 'a' : 0 }); }); + assertException(function() { AHUACATL_STRING_CONCAT(NaN, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(null, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(false, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(true, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT('', 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(' ', 1); }); + assertException(function() { AHUACATL_STRING_CONCAT('0', 1); }); + assertException(function() { AHUACATL_STRING_CONCAT('1', 1); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', 1); }); + assertException(function() { AHUACATL_STRING_CONCAT([ ], 1); }); + assertException(function() { AHUACATL_STRING_CONCAT([ 0 ], 1); }); + assertException(function() { AHUACATL_STRING_CONCAT({ }, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT({ 'a' : 0 }, 1); }); + assertException(function() { AHUACATL_STRING_CONCAT(1, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT(100, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT(-1, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT(-100, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT(0, 0); }); + assertException(function() { AHUACATL_STRING_CONCAT('', null); }); + assertException(function() { AHUACATL_STRING_CONCAT('', false); }); + assertException(function() { AHUACATL_STRING_CONCAT('', true); }); + assertException(function() { AHUACATL_STRING_CONCAT('', [ ]); }); + assertException(function() { AHUACATL_STRING_CONCAT('', { }); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', null); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', false); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', true); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', [ ]); }); + assertException(function() { AHUACATL_STRING_CONCAT('a', { }); }); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test AHUACATL_STRING_CONCAT function +//////////////////////////////////////////////////////////////////////////////// + + testStringConcatValue : function () { + assertEqual('', AHUACATL_STRING_CONCAT('', '')); + assertEqual(' ', AHUACATL_STRING_CONCAT(' ', '')); + assertEqual(' ', AHUACATL_STRING_CONCAT('', ' ')); + assertEqual(' ', AHUACATL_STRING_CONCAT(' ', ' ')); + assertEqual(' a a', AHUACATL_STRING_CONCAT(' a', ' a')); + assertEqual(' a a ', AHUACATL_STRING_CONCAT(' a', ' a ')); + assertEqual('a', AHUACATL_STRING_CONCAT('a', '')); + assertEqual('a', AHUACATL_STRING_CONCAT('', 'a')); + assertEqual('a ', AHUACATL_STRING_CONCAT('', 'a ')); + assertEqual('a ', AHUACATL_STRING_CONCAT('', 'a ')); + assertEqual('a ', AHUACATL_STRING_CONCAT('a ', '')); + assertEqual('ab', AHUACATL_STRING_CONCAT('a', 'b')); + assertEqual('ba', AHUACATL_STRING_CONCAT('b', 'a')); + assertEqual('AA', AHUACATL_STRING_CONCAT('A', 'A')); + assertEqual('AaA', AHUACATL_STRING_CONCAT('A', 'aA')); + assertEqual('AaA', AHUACATL_STRING_CONCAT('Aa', 'A')); + assertEqual('0.00', AHUACATL_STRING_CONCAT('0.00', '')); + assertEqual('abc', AHUACATL_STRING_CONCAT('a', AHUACATL_STRING_CONCAT('b', 'c'))); + assertEqual('', AHUACATL_STRING_CONCAT('', AHUACATL_STRING_CONCAT('', ''))); + } + }; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(ahuacatlOperatorsTestSuite); + +return jsunity.done(); + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)" +// End: From 0f25b479a79b042710a7abe9f7536391bc81b422 Mon Sep 17 00:00:00 2001 From: a-brandt Date: Tue, 24 Apr 2012 14:05:01 +0200 Subject: [PATCH 03/13] added import from STDIN --- V8Client/ImportHelper.cpp | 26 ++++++++++++++++++++++---- V8Client/avocimp.cpp | 8 +++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/V8Client/ImportHelper.cpp b/V8Client/ImportHelper.cpp index d84ff5dbd3..751ee332a9 100644 --- a/V8Client/ImportHelper.cpp +++ b/V8Client/ImportHelper.cpp @@ -91,7 +91,14 @@ namespace triagens { _errorMessage = ""; // read and convert - int fd = open(fileName.c_str(), O_RDONLY); + int fd; + + if (fileName == "-") { + fd = STDIN_FILENO; + } + else { + fd = open(fileName.c_str(), O_RDONLY); + } if (fd < 0) { _errorMessage = TRI_LAST_ERROR_STR; @@ -134,7 +141,9 @@ namespace triagens { TRI_DestroyCsvParser(&parser); - close(fd); + if (fileName != "-") { + close(fd); + } return true; } @@ -149,7 +158,14 @@ namespace triagens { _errorMessage = ""; // read and convert - int fd = open(fileName.c_str(), O_RDONLY); + int fd; + + if (fileName == "-") { + fd = STDIN_FILENO; + } + else { + fd = open(fileName.c_str(), O_RDONLY); + } if (fd < 0) { _errorMessage = TRI_LAST_ERROR_STR; @@ -192,7 +208,9 @@ namespace triagens { _numberLines = _numberError + _numberOk; - close(fd); + if (fileName != "-") { + close(fd); + } return true; } diff --git a/V8Client/avocimp.cpp b/V8Client/avocimp.cpp index 371bc8d68e..cd4cc0f6e3 100644 --- a/V8Client/avocimp.cpp +++ b/V8Client/avocimp.cpp @@ -33,6 +33,7 @@ #include "Basics/ProgramOptions.h" #include "Basics/ProgramOptionsDescription.h" #include "Basics/StringUtils.h" +#include "Basics/FileUtils.h" #include "BasicsC/files.h" #include "BasicsC/init.h" #include "BasicsC/logging.h" @@ -156,7 +157,7 @@ static void ParseProgramOptions (int argc, char* argv[]) { ("help,h", "help message") ("log.level,l", &level, "log level") ("server", &ServerAddress, "server address and port") - ("file", &FileName, "file name") + ("file", &FileName, "file name (\"-\" for STDIN)") ("collection", &CollectionName, "collection name") ("type", &TypeImport, "type of file (\"csv\" or \"json\")") ("quote", &QuoteChar, "quote character") @@ -271,6 +272,11 @@ int main (int argc, char* argv[]) { cout << "file name is missing." << endl; return EXIT_FAILURE; } + + if (FileName != "-" && !FileUtils::isRegularFile(FileName)) { + cout << "file '" << FileName << "' is not a regular file." << endl; + return EXIT_FAILURE; + } bool ok; if (TypeImport == "csv") { From 19d7a70d65b9b3940b9aa82d9a03fb592b050649 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 14:49:59 +0200 Subject: [PATCH 04/13] added test cases --- Ahuacatl/ahuacatl-functions.c | 4 +- Ahuacatl/ast-codegen-js.c | 8 +- Makefile.in | 1 + Makefile.unittests | 1 + js/server/ahuacatl.js | 54 +++++- js/server/js-ahuacatl.h | 54 +++++- js/server/tests/ahuacatl-functions.js | 178 ++++++++++++++++++ js/server/tests/ahuacatl-operators.js | 35 ++-- .../tests/ahuacatl-queries-collection.js | 5 +- .../tests/ahuacatl-queries-noncollection.js | 2 - 10 files changed, 303 insertions(+), 39 deletions(-) create mode 100644 js/server/tests/ahuacatl-functions.js diff --git a/Ahuacatl/ahuacatl-functions.c b/Ahuacatl/ahuacatl-functions.c index ad6edd43dd..24b0ef8d32 100644 --- a/Ahuacatl/ahuacatl-functions.c +++ b/Ahuacatl/ahuacatl-functions.c @@ -127,13 +127,15 @@ TRI_associative_pointer_t* TRI_InitialiseFunctionsAql (void) { REGISTER_FUNCTION("ISDOCUMENT", "IS_DOCUMENT", true, 1, 1); // string concat - REGISTER_FUNCTION("CONCAT", "STRING_CONCAT", true, 2, 2); + REGISTER_FUNCTION("CONCAT", "STRING_CONCAT", true, 2, 256); // numeric functions // string functions // misc functions + REGISTER_FUNCTION("MERGE", "MERGE", true, 2, 256); + REGISTER_FUNCTION("UNION", "UNION", true, 2, 256); REGISTER_FUNCTION("LENGTH", "LENGTH", true, 1, 1); if (!result) { diff --git a/Ahuacatl/ast-codegen-js.c b/Ahuacatl/ast-codegen-js.c index 8697cf324b..c3193a4597 100644 --- a/Ahuacatl/ast-codegen-js.c +++ b/Ahuacatl/ast-codegen-js.c @@ -1222,14 +1222,20 @@ char* TRI_GenerateCodeAql (const void* const data) { if (!generator->_error) { char* funcName = generator->_funcName; - TRI_AppendStringStringBuffer(&generator->_buffer, "return "); + TRI_AppendStringStringBuffer(&generator->_buffer, "try {\n"); + TRI_AppendStringStringBuffer(&generator->_buffer, " return "); TRI_AppendStringStringBuffer(&generator->_buffer, funcName); TRI_AppendStringStringBuffer(&generator->_buffer, "( { } );\n"); + TRI_AppendStringStringBuffer(&generator->_buffer, "}\n"); + TRI_AppendStringStringBuffer(&generator->_buffer, "catch (e) {\n"); + TRI_AppendStringStringBuffer(&generator->_buffer, "print(e);\n"); + TRI_AppendStringStringBuffer(&generator->_buffer, "}\n"); TRI_AppendStringStringBuffer(&generator->_buffer, "})();\n"); code = TRI_DuplicateString(generator->_buffer._buffer); LOG_TRACE("generated code:\n%s\n",code); + //printf("generated code:\n%s\n",code); } TRI_FreeCodegenAql(generator); diff --git a/Makefile.in b/Makefile.in index cd163d97b6..f5fd28c4ae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1010,6 +1010,7 @@ UNITTESTS_SERVER = $(addprefix --unit-tests ,$(SHELL_SERVER)) ################################################################################ ################################################################################ SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-functions.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/Makefile.unittests b/Makefile.unittests index 0629a21029..c90934f648 100644 --- a/Makefile.unittests +++ b/Makefile.unittests @@ -154,6 +154,7 @@ unittests-shell-server: ################################################################################ SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-functions.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js index c348b02301..7436bf667b 100644 --- a/js/server/ahuacatl.js +++ b/js/server/ahuacatl.js @@ -79,7 +79,7 @@ function AHUACATL_CLONE (obj) { //////////////////////////////////////////////////////////////////////////////// function AHUACATL_FCALL(name, parameters) { - return name(parameters); + return name.apply(null, parameters); } //////////////////////////////////////////////////////////////////////////////// @@ -941,13 +941,24 @@ function AHUACATL_ARITHMETIC_MODULUS (lhs, rhs) { /// both operands must be strings or this function will fail //////////////////////////////////////////////////////////////////////////////// -function AHUACATL_STRING_CONCAT (lhs, rhs) { - if (AHUACATL_TYPEWEIGHT(lhs) !== AHUACATL_TYPEWEIGHT_STRING || - AHUACATL_TYPEWEIGHT(rhs) !== AHUACATL_TYPEWEIGHT_STRING) { - throw "expecting strings for string concatenation"; +function AHUACATL_STRING_CONCAT () { + var result = ''; + + for (var i in arguments) { + var element = arguments[i]; + + if (AHUACATL_TYPEWEIGHT(element) === AHUACATL_TYPEWEIGHT_NULL) { + continue; + } + + if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_STRING) { + throw "expecting strings for string concatenation"; + } + + result += element; } - return (lhs + rhs); + return result; } //////////////////////////////////////////////////////////////////////////////// @@ -1205,14 +1216,41 @@ function AHUACATL_LIMIT (value, offset, count) { /// @brief get the length of a list //////////////////////////////////////////////////////////////////////////////// -function AHUACATL_LENGTH (args) { - var value = args[0]; +function AHUACATL_LENGTH () { + var value = arguments[0]; AHUACATL_LIST(value); return value.length; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief merge all arguments +//////////////////////////////////////////////////////////////////////////////// + +function AHUACATL_MERGE () { + var result = { }; + + for (var i in arguments) { + var element = arguments[i]; + + if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_DOCUMENT) { + print(element); + throw "expecting documents for merge"; + } + + for (var k in element) { + if (!element.hasOwnProperty(k)) { + continue; + } + + result[k] = element[k]; + } + } + + return result; +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h index 23c388c478..88bb6f08c8 100644 --- a/js/server/js-ahuacatl.h +++ b/js/server/js-ahuacatl.h @@ -80,7 +80,7 @@ static string JS_server_ahuacatl = "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function AHUACATL_FCALL(name, parameters) {\n" - " return name(parameters);\n" + " return name.apply(null, parameters);\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -942,13 +942,24 @@ static string JS_server_ahuacatl = "/// both operands must be strings or this function will fail\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" - "function AHUACATL_STRING_CONCAT (lhs, rhs) {\n" - " if (AHUACATL_TYPEWEIGHT(lhs) !== AHUACATL_TYPEWEIGHT_STRING ||\n" - " AHUACATL_TYPEWEIGHT(rhs) !== AHUACATL_TYPEWEIGHT_STRING) {\n" - " throw \"expecting strings for string concatenation\";\n" + "function AHUACATL_STRING_CONCAT () {\n" + " var result = '';\n" + "\n" + " for (var i in arguments) {\n" + " var element = arguments[i];\n" + "\n" + " if (AHUACATL_TYPEWEIGHT(element) === AHUACATL_TYPEWEIGHT_NULL) {\n" + " continue;\n" + " }\n" + " \n" + " if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_STRING) {\n" + " throw \"expecting strings for string concatenation\";\n" + " }\n" + "\n" + " result += element;\n" " }\n" "\n" - " return (lhs + rhs);\n" + " return result; \n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" @@ -1206,8 +1217,8 @@ static string JS_server_ahuacatl = "/// @brief get the length of a list\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" - "function AHUACATL_LENGTH (args) {\n" - " var value = args[0];\n" + "function AHUACATL_LENGTH () {\n" + " var value = arguments[0];\n" "\n" " AHUACATL_LIST(value);\n" "\n" @@ -1215,6 +1226,33 @@ static string JS_server_ahuacatl = "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" + "/// @brief merge all arguments\n" + "////////////////////////////////////////////////////////////////////////////////\n" + "\n" + "function AHUACATL_MERGE () {\n" + " var result = { };\n" + "\n" + " for (var i in arguments) {\n" + " var element = arguments[i];\n" + "\n" + " if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_DOCUMENT) {\n" + " print(element);\n" + " throw \"expecting documents for merge\";\n" + " }\n" + "\n" + " for (var k in element) {\n" + " if (!element.hasOwnProperty(k)) {\n" + " continue;\n" + " }\n" + "\n" + " result[k] = element[k];\n" + " }\n" + " }\n" + "\n" + " return result; \n" + "}\n" + "\n" + "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" diff --git a/js/server/tests/ahuacatl-functions.js b/js/server/tests/ahuacatl-functions.js new file mode 100644 index 0000000000..3db80121a5 --- /dev/null +++ b/js/server/tests/ahuacatl-functions.js @@ -0,0 +1,178 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for query language, functions +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +var jsunity = require("jsunity"); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +//////////////////////////////////////////////////////////////////////////////// + +function ahuacatlFunctionsTestSuite () { + + //////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query +//////////////////////////////////////////////////////////////////////////////// + + function executeQuery (query) { + var cursor = AHUACATL_RUN(query, undefined); + if (cursor instanceof AvocadoQueryError) { + print(query, cursor.message); + } + assertFalse(cursor instanceof AvocadoQueryError); + return cursor; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query and return the results as an array +//////////////////////////////////////////////////////////////////////////////// + + function getQueryResults (query, isFlat) { + var result = executeQuery(query); + var results = [ ]; + + for (var i in result) { + if (!result.hasOwnProperty(i)) { + continue; + } + + var row = result[i]; + if (isFlat) { + results.push(row); + } + else { + var keys = [ ]; + for (var k in row) { + if (row.hasOwnProperty(k) && k != '_id' && k != '_rev') { + keys.push(k); + } + } + + keys.sort(); + var resultRow = { }; + for (var k in keys) { + if (keys.hasOwnProperty(k)) { + resultRow[keys[k]] = row[keys[k]]; + } + } + results.push(resultRow); + } + } + + return results; + } + + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tear down +//////////////////////////////////////////////////////////////////////////////// + + tearDown : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test length function +//////////////////////////////////////////////////////////////////////////////// + + testLength : function () { + var expected = [ 4, 4, 4 ]; + var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] LET quarters = ((FOR q IN [ 1, 2, 3, 4 ] return q)) return LENGTH(quarters)", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test concat function +//////////////////////////////////////////////////////////////////////////////// + + testConcat : function () { + var expected = [ "theQuickBrownFoxJumps" ]; + var actual = getQueryResults("FOR r IN [ 1 ] return CONCAT('the', 'Quick', null, 'Brown', null, 'Fox', 'Jumps')", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test merge function +//////////////////////////////////////////////////////////////////////////////// + + testMerge1 : function () { + var expected = [ { "quarter" : 1, "year" : 2010 }, { "quarter" : 2, "year" : 2010 }, { "quarter" : 3, "year" : 2010 }, { "quarter" : 4, "year" : 2010 }, { "quarter" : 1, "year" : 2011 }, { "quarter" : 2, "year" : 2011 }, { "quarter" : 3, "year" : 2011 }, { "quarter" : 4, "year" : 2011 }, { "quarter" : 1, "year" : 2012 }, { "quarter" : 2, "year" : 2012 }, { "quarter" : 3, "year" : 2012 }, { "quarter" : 4, "year" : 2012 } ]; + var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] FOR quarter IN [ 1, 2, 3, 4 ] return MERGE({ \"year\" : year }, { \"quarter\" : quarter })", false); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test merge function +//////////////////////////////////////////////////////////////////////////////// + + testMerge2 : function () { + var expected = [ { "age" : 15, "isAbove18" : false, "name" : "John" }, { "age" : 19, "isAbove18" : true, "name" : "Corey" } ]; + var actual = getQueryResults("FOR u IN [ { \"name\" : \"John\", \"age\" : 15 }, { \"name\" : \"Corey\", \"age\" : 19 } ] return MERGE(u, { \"isAbove18\" : u.age >= 18 })", false); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test merge function +//////////////////////////////////////////////////////////////////////////////// + + testMerge3 : function () { + var expected = [ { "age" : 15, "id" : 9, "name" : "John" }, { "age" : 19, "id" : 9, "name" : "Corey" } ]; + var actual = getQueryResults("FOR u IN [ { \"id\" : 100, \"name\" : \"John\", \"age\" : 15 }, { \"id\" : 101, \"name\" : \"Corey\", \"age\" : 19 } ] return MERGE(u, { \"id\" : 9 })", false); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test merge function +//////////////////////////////////////////////////////////////////////////////// + + testMerge4 : function () { + var expected = [ { "age" : 15, "id" : 33, "name" : "foo" }, { "age" : 19, "id" : 33, "name" : "foo" } ]; + var actual = getQueryResults("FOR u IN [ { \"id\" : 100, \"name\" : \"John\", \"age\" : 15 }, { \"id\" : 101, \"name\" : \"Corey\", \"age\" : 19 } ] return MERGE(u, { \"id\" : 9 }, { \"name\" : \"foo\", \"id\" : 33 })", false); + assertEqual(expected, actual); + }, + }; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(ahuacatlFunctionsTestSuite); + +return jsunity.done(); + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)" +// End: diff --git a/js/server/tests/ahuacatl-operators.js b/js/server/tests/ahuacatl-operators.js index f3e2c7e298..88acdfe12f 100644 --- a/js/server/tests/ahuacatl-operators.js +++ b/js/server/tests/ahuacatl-operators.js @@ -3913,39 +3913,26 @@ function ahuacatlOperatorsTestSuite () { //////////////////////////////////////////////////////////////////////////////// testStringConcatUndefined : function () { - assertException(function() { AHUACATL_STRING_CONCAT(undefined, undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, null); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, false); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, true); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, 0); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, 1); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, 2); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, -1); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, ''); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, '0'); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, ' '); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, 'a'); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, [ ]); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, [ 1 ]); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, { }); }); assertException(function() { AHUACATL_STRING_CONCAT(undefined, { 'a' : 0 }); }); - assertException(function() { AHUACATL_STRING_CONCAT(undefined, NaN); }); - assertException(function() { AHUACATL_STRING_CONCAT(null, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(false, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(true, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(0, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(1, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(2, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(-1, undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT('', undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT('0', undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT(' ', undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT('a', undefined); }); assertException(function() { AHUACATL_STRING_CONCAT([ ], undefined); }); assertException(function() { AHUACATL_STRING_CONCAT([ 1 ], undefined); }); assertException(function() { AHUACATL_STRING_CONCAT({ }, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT({ 'a' : 0 }, undefined); }); - assertException(function() { AHUACATL_STRING_CONCAT(NaN, undefined); }); assertException(function() { AHUACATL_STRING_CONCAT(1, NaN); }); assertException(function() { AHUACATL_STRING_CONCAT(1, null); }); assertException(function() { AHUACATL_STRING_CONCAT(1, false); }); @@ -3977,12 +3964,10 @@ function ahuacatlOperatorsTestSuite () { assertException(function() { AHUACATL_STRING_CONCAT(-1, 0); }); assertException(function() { AHUACATL_STRING_CONCAT(-100, 0); }); assertException(function() { AHUACATL_STRING_CONCAT(0, 0); }); - assertException(function() { AHUACATL_STRING_CONCAT('', null); }); assertException(function() { AHUACATL_STRING_CONCAT('', false); }); assertException(function() { AHUACATL_STRING_CONCAT('', true); }); assertException(function() { AHUACATL_STRING_CONCAT('', [ ]); }); assertException(function() { AHUACATL_STRING_CONCAT('', { }); }); - assertException(function() { AHUACATL_STRING_CONCAT('a', null); }); assertException(function() { AHUACATL_STRING_CONCAT('a', false); }); assertException(function() { AHUACATL_STRING_CONCAT('a', true); }); assertException(function() { AHUACATL_STRING_CONCAT('a', [ ]); }); @@ -3994,6 +3979,23 @@ function ahuacatlOperatorsTestSuite () { //////////////////////////////////////////////////////////////////////////////// testStringConcatValue : function () { + assertEqual('', AHUACATL_STRING_CONCAT()); + assertEqual('', AHUACATL_STRING_CONCAT('')); + assertEqual('a', AHUACATL_STRING_CONCAT('a')); + assertEqual('a', AHUACATL_STRING_CONCAT('a', null)); + assertEqual('', AHUACATL_STRING_CONCAT('', null)); + assertEqual('', AHUACATL_STRING_CONCAT(undefined, '')); + assertEqual('0', AHUACATL_STRING_CONCAT(undefined, '0')); + assertEqual(' ', AHUACATL_STRING_CONCAT(undefined, ' ')); + assertEqual('a', AHUACATL_STRING_CONCAT(undefined, 'a')); + assertEqual('', AHUACATL_STRING_CONCAT('', undefined)); + assertEqual('0', AHUACATL_STRING_CONCAT('0', undefined)); + assertEqual(' ', AHUACATL_STRING_CONCAT(' ', undefined)); + assertEqual('a', AHUACATL_STRING_CONCAT('a', undefined)); + assertEqual('', AHUACATL_STRING_CONCAT(undefined, NaN)); + assertEqual('', AHUACATL_STRING_CONCAT(null, undefined)); + assertEqual('', AHUACATL_STRING_CONCAT(NaN, undefined)); + assertEqual('', AHUACATL_STRING_CONCAT('', '')); assertEqual(' ', AHUACATL_STRING_CONCAT(' ', '')); assertEqual(' ', AHUACATL_STRING_CONCAT('', ' ')); @@ -4013,6 +4015,9 @@ function ahuacatlOperatorsTestSuite () { assertEqual('0.00', AHUACATL_STRING_CONCAT('0.00', '')); assertEqual('abc', AHUACATL_STRING_CONCAT('a', AHUACATL_STRING_CONCAT('b', 'c'))); assertEqual('', AHUACATL_STRING_CONCAT('', AHUACATL_STRING_CONCAT('', ''))); + assertEqual('fux', AHUACATL_STRING_CONCAT('f', 'u', 'x')); + assertEqual('fux', AHUACATL_STRING_CONCAT('f', 'u', null, 'x')); + assertEqual('fux', AHUACATL_STRING_CONCAT(null, 'f', null, 'u', null, 'x', null)); } }; } diff --git a/js/server/tests/ahuacatl-queries-collection.js b/js/server/tests/ahuacatl-queries-collection.js index 5f69ba56d4..5c8d829f55 100644 --- a/js/server/tests/ahuacatl-queries-collection.js +++ b/js/server/tests/ahuacatl-queries-collection.js @@ -507,18 +507,16 @@ function ahuacatlQueryCollectionTestSuite () { testCollectSimple : function () { var expected = [ { "gender" : "f", "numUsers" : 10 }, { "gender" : "m", "numUsers" : 10 } ]; - var actual = getQueryResults("FOR u in " + users.name() + " COLLECT gender = u.gender INTO g SORT gender ASC RETURN { \"gender\" : gender, \"numUsers\" : LENGTH(g) }", false); assertEqual(expected, actual); }, - + //////////////////////////////////////////////////////////////////////////////// /// @brief test collect with filter //////////////////////////////////////////////////////////////////////////////// testCollectFiltered : function () { var expected = [ { "gender" : "m", "numUsers" : 8 }, { "gender" : "f", "numUsers" : 8 } ]; - actual = getQueryResults("FOR u in " + users.name() + " FILTER u.active == true COLLECT gender = u.gender INTO g SORT gender DESC RETURN { \"gender\" : gender, \"numUsers\" : LENGTH(g) }", false); assertEqual(expected, actual); }, @@ -529,7 +527,6 @@ function ahuacatlQueryCollectionTestSuite () { testCollectMultipleCriteria : function () { var expected = [ { "active" : false, "gender" : "m", "numUsers" : 2 }, { "active" : true, "gender" : "m", "numUsers" : 8 }, { "active" : false, "gender" : "f", "numUsers" : 2 }, { "active" : true, "gender" : "f", "numUsers" : 8 } ]; - actual = getQueryResults("FOR u in " + users.name() + " COLLECT gender = u.gender, active = u.active INTO g SORT gender DESC, active ASC RETURN { \"gender\" : gender, \"active\" : active, \"numUsers\" : LENGTH(g) }", false); assertEqual(expected, actual); }, diff --git a/js/server/tests/ahuacatl-queries-noncollection.js b/js/server/tests/ahuacatl-queries-noncollection.js index 7e7941f9b8..f65e07c24d 100644 --- a/js/server/tests/ahuacatl-queries-noncollection.js +++ b/js/server/tests/ahuacatl-queries-noncollection.js @@ -32,8 +32,6 @@ var jsunity = require("jsunity"); //////////////////////////////////////////////////////////////////////////////// function ahuacatlQueryNonCollectionTestSuite () { - var users = null; - var relations = null; //////////////////////////////////////////////////////////////////////////////// /// @brief execute a given query From 663afb0fa1adbaf20d034e335c3c244971dcbbb3 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 14:56:46 +0200 Subject: [PATCH 05/13] added tests --- js/server/ahuacatl.js | 27 ++++++++++++++++++++++- js/server/js-ahuacatl.h | 27 ++++++++++++++++++++++- js/server/tests/ahuacatl-functions.js | 31 +++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/js/server/ahuacatl.js b/js/server/ahuacatl.js index 7436bf667b..2c7c1ac9b9 100644 --- a/js/server/ahuacatl.js +++ b/js/server/ahuacatl.js @@ -1235,7 +1235,6 @@ function AHUACATL_MERGE () { var element = arguments[i]; if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_DOCUMENT) { - print(element); throw "expecting documents for merge"; } @@ -1251,6 +1250,32 @@ function AHUACATL_MERGE () { return result; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief create the union (all) of all arguments +//////////////////////////////////////////////////////////////////////////////// + +function AHUACATL_UNION () { + var result = [ ]; + + for (var i in arguments) { + var element = arguments[i]; + + if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_LIST) { + throw "expecting lists for union"; + } + + for (var k in element) { + if (!element.hasOwnProperty(k)) { + continue; + } + + result.push(element[k]); + } + } + + return result; +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/js/server/js-ahuacatl.h b/js/server/js-ahuacatl.h index 88bb6f08c8..44f3c52f2f 100644 --- a/js/server/js-ahuacatl.h +++ b/js/server/js-ahuacatl.h @@ -1236,7 +1236,6 @@ static string JS_server_ahuacatl = " var element = arguments[i];\n" "\n" " if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_DOCUMENT) {\n" - " print(element);\n" " throw \"expecting documents for merge\";\n" " }\n" "\n" @@ -1253,6 +1252,32 @@ static string JS_server_ahuacatl = "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" + "/// @brief create the union (all) of all arguments\n" + "////////////////////////////////////////////////////////////////////////////////\n" + "\n" + "function AHUACATL_UNION () {\n" + " var result = [ ];\n" + "\n" + " for (var i in arguments) {\n" + " var element = arguments[i];\n" + "\n" + " if (AHUACATL_TYPEWEIGHT(element) !== AHUACATL_TYPEWEIGHT_LIST) {\n" + " throw \"expecting lists for union\";\n" + " }\n" + "\n" + " for (var k in element) {\n" + " if (!element.hasOwnProperty(k)) {\n" + " continue;\n" + " }\n" + "\n" + " result.push(element[k]);\n" + " }\n" + " }\n" + "\n" + " return result; \n" + "}\n" + "\n" + "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" diff --git a/js/server/tests/ahuacatl-functions.js b/js/server/tests/ahuacatl-functions.js index 3db80121a5..3be7ad2226 100644 --- a/js/server/tests/ahuacatl-functions.js +++ b/js/server/tests/ahuacatl-functions.js @@ -161,6 +161,37 @@ function ahuacatlFunctionsTestSuite () { var actual = getQueryResults("FOR u IN [ { \"id\" : 100, \"name\" : \"John\", \"age\" : 15 }, { \"id\" : 101, \"name\" : \"Corey\", \"age\" : 19 } ] return MERGE(u, { \"id\" : 9 }, { \"name\" : \"foo\", \"id\" : 33 })", false); assertEqual(expected, actual); }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test union function +//////////////////////////////////////////////////////////////////////////////// + + testUnion1 : function () { + var expected = [ [ 1, 2, 3, 1, 2, 3 ], [ 1, 2, 3, 1, 2, 3 ] ]; + var actual = getQueryResults("FOR u IN [ 1, 2 ] return UNION([ 1, 2, 3 ], [ 1, 2, 3 ])", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test union function +//////////////////////////////////////////////////////////////////////////////// + + testUnion2 : function () { + var expected = [ [ 1, 2, 3, 3, 2, 1 ], [ 1, 2, 3, 3, 2, 1 ] ]; + var actual = getQueryResults("FOR u IN [ 1, 2 ] return UNION([ 1, 2, 3 ], [ 3, 2, 1 ])", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test union function +//////////////////////////////////////////////////////////////////////////////// + + testUnion3 : function () { + var expected = [ "Fred", "John", "John", "Amy" ]; + var actual = getQueryResults("FOR u IN UNION([ \"Fred\", \"John\" ], [ \"John\", \"Amy\"]) return u", true); + assertEqual(expected, actual); + }, + }; } From 9e26458577255d17038863e3d987bc4e7d15be04 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 15:29:33 +0200 Subject: [PATCH 06/13] added tests, added variable name validation --- Ahuacatl/{error.c => ahuacatl-error.c} | 2 +- Ahuacatl/{error.h => ahuacatl-error.h} | 0 Ahuacatl/ast-node.c | 5 + Ahuacatl/grammar.c | 2 +- Ahuacatl/grammar.y | 2 +- Ahuacatl/parser.c | 16 +++ Ahuacatl/parser.h | 9 +- Makefile.files | 2 +- Makefile.in | 23 ++-- Makefile.unittests | 5 +- RestServer/AvocadoServer.cpp | 2 +- js/server/tests/ahuacatl-escaping.js | 177 +++++++++++++++++++++++++ 12 files changed, 226 insertions(+), 19 deletions(-) rename Ahuacatl/{error.c => ahuacatl-error.c} (99%) rename Ahuacatl/{error.h => ahuacatl-error.h} (100%) create mode 100644 js/server/tests/ahuacatl-escaping.js diff --git a/Ahuacatl/error.c b/Ahuacatl/ahuacatl-error.c similarity index 99% rename from Ahuacatl/error.c rename to Ahuacatl/ahuacatl-error.c index 03d550ed89..ebbe003468 100644 --- a/Ahuacatl/error.c +++ b/Ahuacatl/ahuacatl-error.c @@ -25,7 +25,7 @@ /// @author Copyright 2012, triagens GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "Ahuacatl/error.h" +#include "Ahuacatl/ahuacatl-error.h" // ----------------------------------------------------------------------------- // --SECTION-- defines diff --git a/Ahuacatl/error.h b/Ahuacatl/ahuacatl-error.h similarity index 100% rename from Ahuacatl/error.h rename to Ahuacatl/ahuacatl-error.h diff --git a/Ahuacatl/ast-node.c b/Ahuacatl/ast-node.c index 1e517c29a2..07539feb78 100644 --- a/Ahuacatl/ast-node.c +++ b/Ahuacatl/ast-node.c @@ -139,6 +139,11 @@ TRI_aql_node_t* TRI_CreateNodeForAql (TRI_aql_parse_context_t* const context, if (!name || !expression) { ABORT_OOM } + + if (!TRI_IsValidVariableNameAql(name)) { + TRI_SetErrorAql(context, TRI_ERROR_QUERY_VARIABLE_REDECLARED, name); + return NULL; + } node = (TRI_aql_node_for_t*) TRI_Allocate(sizeof(TRI_aql_node_for_t)); diff --git a/Ahuacatl/grammar.c b/Ahuacatl/grammar.c index 849e989cff..e748bf92de 100644 --- a/Ahuacatl/grammar.c +++ b/Ahuacatl/grammar.c @@ -88,7 +88,7 @@ #include "Ahuacatl/ast-node.h" #include "Ahuacatl/parser.h" -#include "Ahuacatl/error.h" +#include "Ahuacatl/ahuacatl-error.h" diff --git a/Ahuacatl/grammar.y b/Ahuacatl/grammar.y index 1b9c6eb050..71298a915f 100644 --- a/Ahuacatl/grammar.y +++ b/Ahuacatl/grammar.y @@ -18,7 +18,7 @@ #include "Ahuacatl/ast-node.h" #include "Ahuacatl/parser.h" -#include "Ahuacatl/error.h" +#include "Ahuacatl/ahuacatl-error.h" %} diff --git a/Ahuacatl/parser.c b/Ahuacatl/parser.c index 60cfcdf59c..4fb8af3a2a 100644 --- a/Ahuacatl/parser.c +++ b/Ahuacatl/parser.c @@ -594,6 +594,22 @@ bool TRI_VariableExistsAql (TRI_aql_parse_context_t* const context, return false; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief checks if a variable name follows the required naming convention +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_IsValidVariableNameAql (const char* const name) { + TRI_col_parameter_t parameter; + + parameter._isSystem = true; + + if (TRI_IsAllowedCollectionName(¶meter, name) != 0) { + return false; + } + + return true; +} + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/Ahuacatl/parser.h b/Ahuacatl/parser.h index 5ef55e223f..98f7a48a2b 100644 --- a/Ahuacatl/parser.h +++ b/Ahuacatl/parser.h @@ -35,7 +35,8 @@ #include #include "VocBase/vocbase.h" -#include "Ahuacatl/error.h" +#include "VocBase/collection.h" +#include "Ahuacatl/ahuacatl-error.h" #ifdef __cplusplus extern "C" { @@ -241,6 +242,12 @@ char* TRI_RegisterStringAql (TRI_aql_parse_context_t* const, bool TRI_VariableExistsAql (TRI_aql_parse_context_t* const, const char* const); +//////////////////////////////////////////////////////////////////////////////// +/// @brief checks if a variable name follows the required naming convention +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_IsValidVariableNameAql (const char* const); + //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// diff --git a/Makefile.files b/Makefile.files index eab56cbc95..ddcbff53d4 100644 --- a/Makefile.files +++ b/Makefile.files @@ -146,11 +146,11 @@ avocado_SOURCES = \ HttpsServer/HttpsServerImpl.cpp \ PriorityQueue/pqueueindex.c \ PriorityQueue/priorityqueue.c \ + Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ Ahuacatl/ast-codegen-js.c \ Ahuacatl/ast-dump.c \ Ahuacatl/ast-node.c \ - Ahuacatl/error.c \ Ahuacatl/grammar.c \ Ahuacatl/parser.c \ Ahuacatl/tokens.c \ diff --git a/Makefile.in b/Makefile.in index f5fd28c4ae..af8694bb03 100644 --- a/Makefile.in +++ b/Makefile.in @@ -277,13 +277,13 @@ am_avocado_OBJECTS = Admin/ApplicationAdminServer.$(OBJEXT) \ HttpsServer/HttpsServerImpl.$(OBJEXT) \ PriorityQueue/pqueueindex.$(OBJEXT) \ PriorityQueue/priorityqueue.$(OBJEXT) \ + Ahuacatl/ahuacatl-error.$(OBJEXT) \ Ahuacatl/ahuacatl-functions.$(OBJEXT) \ Ahuacatl/ast-codegen-js.$(OBJEXT) Ahuacatl/ast-dump.$(OBJEXT) \ - Ahuacatl/ast-node.$(OBJEXT) Ahuacatl/error.$(OBJEXT) \ - Ahuacatl/grammar.$(OBJEXT) Ahuacatl/parser.$(OBJEXT) \ - Ahuacatl/tokens.$(OBJEXT) QL/ast-query.$(OBJEXT) \ - QL/formatter.$(OBJEXT) QL/optimize.$(OBJEXT) \ - QL/parser.$(OBJEXT) QL/tokens.$(OBJEXT) \ + Ahuacatl/ast-node.$(OBJEXT) Ahuacatl/grammar.$(OBJEXT) \ + Ahuacatl/parser.$(OBJEXT) Ahuacatl/tokens.$(OBJEXT) \ + QL/ast-query.$(OBJEXT) QL/formatter.$(OBJEXT) \ + QL/optimize.$(OBJEXT) QL/parser.$(OBJEXT) QL/tokens.$(OBJEXT) \ RestHandler/RestActionHandler.$(OBJEXT) \ RestHandler/RestDocumentHandler.$(OBJEXT) \ RestHandler/RestEdgeHandler.$(OBJEXT) \ @@ -752,11 +752,11 @@ avocado_SOURCES = \ HttpsServer/HttpsServerImpl.cpp \ PriorityQueue/pqueueindex.c \ PriorityQueue/priorityqueue.c \ + Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ Ahuacatl/ast-codegen-js.c \ Ahuacatl/ast-dump.c \ Ahuacatl/ast-node.c \ - Ahuacatl/error.c \ Ahuacatl/grammar.c \ Ahuacatl/parser.c \ Ahuacatl/tokens.c \ @@ -1010,6 +1010,7 @@ UNITTESTS_SERVER = $(addprefix --unit-tests ,$(SHELL_SERVER)) ################################################################################ ################################################################################ SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-escaping.js \ @srcdir@/js/server/tests/ahuacatl-functions.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js @@ -1649,6 +1650,8 @@ Ahuacatl/$(am__dirstamp): Ahuacatl/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) Ahuacatl/$(DEPDIR) @: > Ahuacatl/$(DEPDIR)/$(am__dirstamp) +Ahuacatl/ahuacatl-error.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ + Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ahuacatl-functions.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ast-codegen-js.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ @@ -1657,8 +1660,6 @@ Ahuacatl/ast-dump.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ast-node.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) -Ahuacatl/error.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ - Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/grammar.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/parser.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ @@ -1903,11 +1904,11 @@ mostlyclean-compile: -rm -f Admin/RestAdminLogHandler.$(OBJEXT) -rm -f Admin/RestBaseHandler.$(OBJEXT) -rm -f Admin/RestVersionHandler.$(OBJEXT) + -rm -f Ahuacatl/ahuacatl-error.$(OBJEXT) -rm -f Ahuacatl/ahuacatl-functions.$(OBJEXT) -rm -f Ahuacatl/ast-codegen-js.$(OBJEXT) -rm -f Ahuacatl/ast-dump.$(OBJEXT) -rm -f Ahuacatl/ast-node.$(OBJEXT) - -rm -f Ahuacatl/error.$(OBJEXT) -rm -f Ahuacatl/grammar.$(OBJEXT) -rm -f Ahuacatl/parser.$(OBJEXT) -rm -f Ahuacatl/tokens.$(OBJEXT) @@ -2130,11 +2131,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestAdminLogHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestBaseHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestVersionHandler.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-codegen-js.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-dump.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-node.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/grammar.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/tokens.Po@am__quote@ @@ -2979,7 +2980,7 @@ start-server: unittests-shell-server: @echo @echo "================================================================================" - @echo "|| SHELL SERVER TESTS (BASCIS) ||" + @echo "|| SHELL SERVER TESTS (BASICS) ||" @echo "================================================================================" @echo diff --git a/Makefile.unittests b/Makefile.unittests index c90934f648..fc2953417e 100644 --- a/Makefile.unittests +++ b/Makefile.unittests @@ -122,7 +122,7 @@ unittests-boost: endif ################################################################################ -## SHELL SERVER TESTS (BASCIS) +## SHELL SERVER TESTS (BASICS) ################################################################################ SHELL_SERVER = @srcdir@/js/common/tests/shell-document.js \ @@ -136,7 +136,7 @@ UNITTESTS_SERVER = $(addprefix --unit-tests ,$(SHELL_SERVER)) unittests-shell-server: @echo @echo "================================================================================" - @echo "|| SHELL SERVER TESTS (BASCIS) ||" + @echo "|| SHELL SERVER TESTS (BASICS) ||" @echo "================================================================================" @echo @@ -154,6 +154,7 @@ unittests-shell-server: ################################################################################ SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-operators.js \ + @srcdir@/js/server/tests/ahuacatl-escaping.js \ @srcdir@/js/server/tests/ahuacatl-functions.js \ @srcdir@/js/server/tests/ahuacatl-queries-collection.js \ @srcdir@/js/server/tests/ahuacatl-queries-noncollection.js diff --git a/RestServer/AvocadoServer.cpp b/RestServer/AvocadoServer.cpp index d2bc09d85b..41996cfb25 100644 --- a/RestServer/AvocadoServer.cpp +++ b/RestServer/AvocadoServer.cpp @@ -860,7 +860,7 @@ int AvocadoServer::executeShell (bool tests) { char* input = console->prompt("avocado> "); if (input == 0) { - printf("\nBye Bye! Auf Wiedersehen!\n"); + printf("\nBye Bye! Auf Wiedersehen! さようなら\n"); break; } diff --git a/js/server/tests/ahuacatl-escaping.js b/js/server/tests/ahuacatl-escaping.js new file mode 100644 index 0000000000..a491eeee5c --- /dev/null +++ b/js/server/tests/ahuacatl-escaping.js @@ -0,0 +1,177 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief tests for query language, escaping +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +var jsunity = require("jsunity"); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test suite +//////////////////////////////////////////////////////////////////////////////// + +function ahuacatlEscapingTestSuite () { + + //////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query +//////////////////////////////////////////////////////////////////////////////// + + function executeQuery (query) { + var cursor = AHUACATL_RUN(query, undefined); + if (cursor instanceof AvocadoQueryError) { + print(query, cursor.message); + } + assertFalse(cursor instanceof AvocadoQueryError); + return cursor; + } + +//////////////////////////////////////////////////////////////////////////////// +/// @brief execute a given query and return the results as an array +//////////////////////////////////////////////////////////////////////////////// + + function getQueryResults (query, isFlat) { + var result = executeQuery(query); + var results = [ ]; + + for (var i in result) { + if (!result.hasOwnProperty(i)) { + continue; + } + + var row = result[i]; + if (isFlat) { + results.push(row); + } + else { + var keys = [ ]; + for (var k in row) { + if (row.hasOwnProperty(k) && k != '_id' && k != '_rev') { + keys.push(k); + } + } + + keys.sort(); + var resultRow = { }; + for (var k in keys) { + if (keys.hasOwnProperty(k)) { + resultRow[keys[k]] = row[keys[k]]; + } + } + results.push(resultRow); + } + } + + return results; + } + + + return { + +//////////////////////////////////////////////////////////////////////////////// +/// @brief set up +//////////////////////////////////////////////////////////////////////////////// + + setUp : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief tear down +//////////////////////////////////////////////////////////////////////////////// + + tearDown : function () { + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test simple name handling +//////////////////////////////////////////////////////////////////////////////// + + testSimpleName : function () { + var expected = [ 1, 2, 3 ]; + var actual = getQueryResults("FOR `x` IN [ 1, 2, 3 ] RETURN `x`", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test reserved name handling +//////////////////////////////////////////////////////////////////////////////// + + testReservedNames1 : function () { + var expected = [ 1, 2, 3 ]; + var names = [ "for", "let", "return", "sort", "collect", "limit", "filter", "asc", "desc", "in", "into" ]; + + for (var i in names) { + if (!names.hasOwnProperty(i)) { + continue; + } + + var actual = getQueryResults("FOR `" + names[i] + "` IN [ 1, 2, 3 ] RETURN `" + names[i] + "`", true); + assertEqual(expected, actual); + } + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test reserved names handling +//////////////////////////////////////////////////////////////////////////////// + + testReservedNames2 : function () { + var expected = [ { "let" : 1 }, { "collect" : 2 }, { "sort" : 3 } ]; + var actual = getQueryResults("FOR `for` IN [ { \"let\" : 1 }, { \"collect\" : 2 }, { \"sort\" : 3 } ] RETURN `for`", false); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test punctuation names escaping +//////////////////////////////////////////////////////////////////////////////// + + testPunctuationName1 : function () { + var expected = [ 1, 2, 3 ]; + var actual = getQueryResults("FOR `brown_fox` IN [ 1, 2, 3 ] RETURN `brown_fox`", true); + assertEqual(expected, actual); + }, + +//////////////////////////////////////////////////////////////////////////////// +/// @brief test punctuation names escaping +//////////////////////////////////////////////////////////////////////////////// + + testPunctuationName2 : function () { + var expected = [ 1, 2, 3 ]; + var actual = getQueryResults("FOR `brown_fox__1234_` IN [ 1, 2, 3 ] RETURN `brown_fox__1234_`", true); + assertEqual(expected, actual); + }, + + }; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief executes the test suite +//////////////////////////////////////////////////////////////////////////////// + +jsunity.run(ahuacatlEscapingTestSuite); + +return jsunity.done(); + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)" +// End: From f5d2b16255febad9de18899f6078396a96aa3f86 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 15:34:02 +0200 Subject: [PATCH 07/13] added proper error message for invalid variable naming --- Ahuacatl/ast-node.c | 2 +- BasicsC/errors.dat | 1 + BasicsC/voc-errors.c | 1 + BasicsC/voc-errors.h | 12 ++++++++++++ js/common/bootstrap/errors.js | 1 + js/common/bootstrap/js-errors.h | 1 + 6 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Ahuacatl/ast-node.c b/Ahuacatl/ast-node.c index 07539feb78..022ae962d3 100644 --- a/Ahuacatl/ast-node.c +++ b/Ahuacatl/ast-node.c @@ -141,7 +141,7 @@ TRI_aql_node_t* TRI_CreateNodeForAql (TRI_aql_parse_context_t* const context, } if (!TRI_IsValidVariableNameAql(name)) { - TRI_SetErrorAql(context, TRI_ERROR_QUERY_VARIABLE_REDECLARED, name); + TRI_SetErrorAql(context, TRI_ERROR_QUERY_VARIABLE_NAME_INVALID, name); return NULL; } diff --git a/BasicsC/errors.dat b/BasicsC/errors.dat index 9f363c85e7..25c8e3b06b 100644 --- a/BasicsC/errors.dat +++ b/BasicsC/errors.dat @@ -118,6 +118,7 @@ ERROR_QUERY_RUNTIME_ERROR,1520,"runtime error in query","Will be raised when a J ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE,1521,"limit value '%s' is out of range","Will be raised when a limit value in the query is outside the allowed range (e. g. when passing a negative skip value)." ERROR_QUERY_VARIABLE_REDECLARED,1522,"variable '%s' is assigned multiple times","Will be raised when a variable gets re-assigned in a query." ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED,1523,"document attribute '%s' is assigned multiple times","Will be raised when a document attribute is re-assigned." +ERROR_QUERY_VARIABLE_NAME_INVALID,1524,"variable name '%s' has an invalid format","Will be raised when an invalid variable name is used." ################################################################################ ## AvocadoDB cursor errors diff --git a/BasicsC/voc-errors.c b/BasicsC/voc-errors.c index bcfe538210..d55957fc80 100644 --- a/BasicsC/voc-errors.c +++ b/BasicsC/voc-errors.c @@ -84,6 +84,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE, "limit value '%s' is out of range"); REG_ERROR(ERROR_QUERY_VARIABLE_REDECLARED, "variable '%s' is assigned multiple times"); REG_ERROR(ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED, "document attribute '%s' is assigned multiple times"); + REG_ERROR(ERROR_QUERY_VARIABLE_NAME_INVALID, "variable name '%s' has an invalid format"); REG_ERROR(ERROR_CURSOR_NOT_FOUND, "cursor not found"); REG_ERROR(ERROR_SESSION_USERHANDLER_URL_INVALID, "expecting /user/"); REG_ERROR(ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER, "cannot create user"); diff --git a/BasicsC/voc-errors.h b/BasicsC/voc-errors.h index 77008f875c..0ed19f7026 100644 --- a/BasicsC/voc-errors.h +++ b/BasicsC/voc-errors.h @@ -184,6 +184,8 @@ extern "C" { /// Will be raised when a variable gets re-assigned in a query. /// - 1523: @CODE{document attribute '\%s' is assigned multiple times} /// Will be raised when a document attribute is re-assigned. +/// - 1524: @CODE{variable name '\%s' has an invalid format} +/// Will be raised when an invalid variable name is used. /// - 1600: @CODE{cursor not found} /// Will be raised when a cursor is requested via its id but a cursor with /// that id cannot be found. @@ -1027,6 +1029,16 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED (1523) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1524: ERROR_QUERY_VARIABLE_NAME_INVALID +/// +/// variable name '%s' has an invalid format +/// +/// Will be raised when an invalid variable name is used. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_VARIABLE_NAME_INVALID (1524) + //////////////////////////////////////////////////////////////////////////////// /// @brief 1600: ERROR_CURSOR_NOT_FOUND /// diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index f5a05dd198..28bcb6d969 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -78,6 +78,7 @@ ModuleCache["/internal"].exports.errors = { "ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE" : { "code" : 1521, "message" : "limit value '%s' is out of range" }, "ERROR_QUERY_VARIABLE_REDECLARED" : { "code" : 1522, "message" : "variable '%s' is assigned multiple times" }, "ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED" : { "code" : 1523, "message" : "document attribute '%s' is assigned multiple times" }, + "ERROR_QUERY_VARIABLE_NAME_INVALID" : { "code" : 1524, "message" : "variable name '%s' has an invalid format" }, "ERROR_CURSOR_NOT_FOUND" : { "code" : 1600, "message" : "cursor not found" }, "ERROR_SESSION_USERHANDLER_URL_INVALID" : { "code" : 1700, "message" : "expecting /user/" }, "ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER" : { "code" : 1701, "message" : "cannot create user" }, diff --git a/js/common/bootstrap/js-errors.h b/js/common/bootstrap/js-errors.h index aa27d6f489..e524cbd73d 100644 --- a/js/common/bootstrap/js-errors.h +++ b/js/common/bootstrap/js-errors.h @@ -79,6 +79,7 @@ static string JS_common_bootstrap_errors = " \"ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE\" : { \"code\" : 1521, \"message\" : \"limit value '%s' is out of range\" }, \n" " \"ERROR_QUERY_VARIABLE_REDECLARED\" : { \"code\" : 1522, \"message\" : \"variable '%s' is assigned multiple times\" }, \n" " \"ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED\" : { \"code\" : 1523, \"message\" : \"document attribute '%s' is assigned multiple times\" }, \n" + " \"ERROR_QUERY_VARIABLE_NAME_INVALID\" : { \"code\" : 1524, \"message\" : \"variable name '%s' has an invalid format\" }, \n" " \"ERROR_CURSOR_NOT_FOUND\" : { \"code\" : 1600, \"message\" : \"cursor not found\" }, \n" " \"ERROR_SESSION_USERHANDLER_URL_INVALID\" : { \"code\" : 1700, \"message\" : \"expecting /user/\" }, \n" " \"ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER\" : { \"code\" : 1701, \"message\" : \"cannot create user\" }, \n" From 994a5d8151d0f3409d9e40a7715a00bb4c30597e Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 16:58:54 +0200 Subject: [PATCH 08/13] re-added bind parameters --- Ahuacatl/ahuacatl-bind-parameter.c | 204 +++++++++++++++++++++++++++++ Ahuacatl/ahuacatl-bind-parameter.h | 116 ++++++++++++++++ Ahuacatl/ast-node.c | 11 +- Ahuacatl/grammar.c | 24 ++-- Ahuacatl/grammar.y | 8 +- Ahuacatl/parser.c | 48 +++++++ Ahuacatl/parser.h | 18 ++- BasicsC/associative.c | 11 ++ BasicsC/associative.h | 8 +- BasicsC/errors.dat | 1 + BasicsC/voc-errors.c | 1 + BasicsC/voc-errors.h | 14 ++ Makefile.files | 1 + Makefile.in | 6 + V8/v8-vocbase.cpp | 28 ++-- js/common/bootstrap/errors.js | 1 + js/common/bootstrap/js-errors.h | 1 + 17 files changed, 462 insertions(+), 39 deletions(-) create mode 100644 Ahuacatl/ahuacatl-bind-parameter.c create mode 100644 Ahuacatl/ahuacatl-bind-parameter.h diff --git a/Ahuacatl/ahuacatl-bind-parameter.c b/Ahuacatl/ahuacatl-bind-parameter.c new file mode 100644 index 0000000000..a284004d82 --- /dev/null +++ b/Ahuacatl/ahuacatl-bind-parameter.c @@ -0,0 +1,204 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Ahuacatl, bind parameters +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triagens GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#include "Ahuacatl/ahuacatl-bind-parameter.h" + +// ----------------------------------------------------------------------------- +// --SECTION-- private functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup Ahuacatl +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +static TRI_aql_bind_parameter_t* CreateParameter (const char* const name, + const TRI_json_t* const value) { + TRI_aql_bind_parameter_t* parameter; + + assert(name); + assert(value); + + parameter = (TRI_aql_bind_parameter_t*) TRI_Allocate(sizeof(TRI_aql_bind_parameter_t)); + if (!parameter) { + return NULL; + } + + parameter->_name = TRI_DuplicateString(name); + if (!parameter->_name) { + TRI_Free(parameter); + return NULL; + } + + parameter->_value = TRI_CopyJson((TRI_json_t*) value); + if (!parameter->_value) { + TRI_Free(parameter->_name); + TRI_Free(parameter); + return NULL; + } + + return parameter; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- public functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup Ahuacatl +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +/// @brief hash bind parameter +//////////////////////////////////////////////////////////////////////////////// + +uint64_t TRI_HashBindParameterAql (TRI_associative_pointer_t* array, + void const* element) { + TRI_aql_bind_parameter_t* parameter = (TRI_aql_bind_parameter_t*) element; + + return TRI_FnvHashString(parameter->_name); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief comparison function used to determine bind parameter equality +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_EqualBindParameterAql (TRI_associative_pointer_t* array, + void const* key, + void const* element) { + TRI_aql_bind_parameter_t* parameter = (TRI_aql_bind_parameter_t*) element; + + return TRI_EqualString(key, parameter->_name); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief add bind parameters +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_AddParameterValuesAql (TRI_aql_parse_context_t* const context, + const TRI_json_t* const parameters) { + size_t i; + size_t n; + + assert(context); + + if (parameters == NULL) { + // no bind parameters + return true; + } + + if (parameters->_type != TRI_JSON_ARRAY) { + // parameters must be a list + TRI_SetErrorAql(context, TRI_ERROR_QUERY_BIND_PARAMETERS_INVALID, NULL); + return false; + } + + n = parameters->_value._objects._length; + if (n == 0) { + // empty list, this is ok + return true; + } + + for (i = 0; i < n; i += 2) { + TRI_json_t* name = TRI_AtVector(¶meters->_value._objects, i); + TRI_json_t* value = TRI_AtVector(¶meters->_value._objects, i + 1); + TRI_aql_bind_parameter_t* parameter; + + assert(name); + assert(name->_type == TRI_JSON_STRING); + assert(value); + + parameter = CreateParameter(name->_value._string.data, value); + if (!parameter) { + TRI_SetErrorAql(context, TRI_ERROR_OUT_OF_MEMORY, NULL); + return false; + } + + TRI_InsertKeyAssociativePointer(&context->_parameterValues, parameter->_name, parameter, false); + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief validate bind parameters passed +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_ValidateBindParametersAql (TRI_aql_parse_context_t* const context) { + size_t i; + size_t n; + + // iterate thru all parameter names used in the query + n = context->_parameterNames._nrAlloc; + for (i = 0; i < n; ++i) { + char* name = (char*) context->_parameterNames._table[i]; + + if (!name) { + continue; + } + + if (!TRI_LookupByKeyAssociativePointer(&context->_parameterValues, name)) { + TRI_SetErrorAql(context, TRI_ERROR_QUERY_BIND_PARAMETER_MISSING, name); + return false; + } + } + + // iterate thru all parameters that we have values for + n = context->_parameterValues._nrAlloc; + for (i = 0; i < n; ++i) { + TRI_aql_bind_parameter_t* parameter; + + parameter = (TRI_aql_bind_parameter_t*) context->_parameterValues._table[i]; + + if (!parameter) { + continue; + } + + assert(parameter->_name); + + if (!TRI_LookupByKeyAssociativePointer(&context->_parameterNames, parameter->_name)) { + TRI_SetErrorAql(context, TRI_ERROR_QUERY_BIND_PARAMETER_UNDECLARED, parameter->_name); + return false; + } + } + + return true; +} + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" +// End: diff --git a/Ahuacatl/ahuacatl-bind-parameter.h b/Ahuacatl/ahuacatl-bind-parameter.h new file mode 100644 index 0000000000..6b0f20e330 --- /dev/null +++ b/Ahuacatl/ahuacatl-bind-parameter.h @@ -0,0 +1,116 @@ +//////////////////////////////////////////////////////////////////////////////// +/// @brief Ahuacatl, bind parameters +/// +/// @file +/// +/// DISCLAIMER +/// +/// Copyright 2010-2012 triagens GmbH, Cologne, Germany +/// +/// Licensed under the Apache License, Version 2.0 (the "License"); +/// you may not use this file except in compliance with the License. +/// You may obtain a copy of the License at +/// +/// http://www.apache.org/licenses/LICENSE-2.0 +/// +/// Unless required by applicable law or agreed to in writing, software +/// distributed under the License is distributed on an "AS IS" BASIS, +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +/// See the License for the specific language governing permissions and +/// limitations under the License. +/// +/// Copyright holder is triAGENS GmbH, Cologne, Germany +/// +/// @author Jan Steemann +/// @author Copyright 2012, triagens GmbH, Cologne, Germany +//////////////////////////////////////////////////////////////////////////////// + +#ifndef TRIAGENS_DURHAM_AHUACATL_BIND_PARAMETER_H +#define TRIAGENS_DURHAM_AHUACATL_BIND_PARAMETER_H 1 + +#include +#include +#include +#include +#include +#include + +#include "Ahuacatl/parser.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// ----------------------------------------------------------------------------- +// --SECTION-- public types +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup Ahuacatl +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +/// @brief bind parameter container +//////////////////////////////////////////////////////////////////////////////// + +typedef struct TRI_aql_bind_parameter_s { + char* _name; + TRI_json_t* _value; +} +TRI_aql_bind_parameter_t; + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +// ----------------------------------------------------------------------------- +// --SECTION-- public functions +// ----------------------------------------------------------------------------- + +//////////////////////////////////////////////////////////////////////////////// +/// @addtogroup Ahuacatl +/// @{ +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +/// @brief hash bind parameter +//////////////////////////////////////////////////////////////////////////////// + +uint64_t TRI_HashBindParameterAql (TRI_associative_pointer_t*, void const*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief comparison function used to determine bind parameter equality +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_EqualBindParameterAql (TRI_associative_pointer_t*, + void const*, + void const*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief add bind parameters +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_AddParameterValuesAql (TRI_aql_parse_context_t* const, + const TRI_json_t* const); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief validate bind parameters passed +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_ValidateBindParametersAql (TRI_aql_parse_context_t* const); + +//////////////////////////////////////////////////////////////////////////////// +/// @} +//////////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +} +#endif + +#endif + +// Local Variables: +// mode: outline-minor +// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" +// End: diff --git a/Ahuacatl/ast-node.c b/Ahuacatl/ast-node.c index 022ae962d3..b40ad39737 100644 --- a/Ahuacatl/ast-node.c +++ b/Ahuacatl/ast-node.c @@ -514,7 +514,10 @@ TRI_aql_node_t* TRI_CreateNodeParameterAql (TRI_aql_parse_context_t* const conte if (!name) { ABORT_OOM } - + + // save name of bind parameter for later + TRI_InsertKeyAssociativePointer(&context->_parameterNames, name, (void*) name, true); + node = (TRI_aql_node_parameter_t*) TRI_Allocate(sizeof(TRI_aql_node_parameter_t)); if (!node) { @@ -1323,9 +1326,9 @@ TRI_aql_node_t* TRI_CreateNodeArrayAql (TRI_aql_parse_context_t* const context) InitNode(context, (TRI_aql_node_t*) node, AQL_NODE_ARRAY); TRI_InitAssociativePointer(&node->_values, - TRI_HashStringKeyAssociativePointer, - HashArrayElement, - EqualArrayElement, + &TRI_HashStringKeyAssociativePointer, + &HashArrayElement, + &EqualArrayElement, 0); node->_base.free = &FreeNodeArray; diff --git a/Ahuacatl/grammar.c b/Ahuacatl/grammar.c index e748bf92de..a30e34e1c9 100644 --- a/Ahuacatl/grammar.c +++ b/Ahuacatl/grammar.c @@ -569,8 +569,8 @@ static const yytype_uint16 yyrline[] = 574, 582, 593, 604, 606, 611, 614, 620, 623, 629, 629, 642, 644, 649, 654, 662, 662, 675, 677, 682, 684, 689, 697, 706, 713, 720, 730, 737, 744, 754, - 757, 763, 771, 785, 793, 801, 812, 829, 836, 845, - 851, 858 + 757, 763, 771, 785, 793, 801, 812, 823, 830, 839, + 845, 852 }; #endif @@ -2792,13 +2792,7 @@ yyreduce: /* Line 1455 of yacc.c */ #line 812 "Ahuacatl/grammar.y" { - TRI_aql_node_t* node; - - if (!(yyvsp[(1) - (1)].strval)) { - YYABORT; - } - - node = TRI_CreateNodeParameterAql(context, (yyvsp[(1) - (1)].strval)); + TRI_aql_node_t* node = TRI_CreateNodeParameterAql(context, (yyvsp[(1) - (1)].strval)); if (!node) { YYABORT; } @@ -2810,7 +2804,7 @@ yyreduce: case 97: /* Line 1455 of yacc.c */ -#line 829 "Ahuacatl/grammar.y" +#line 823 "Ahuacatl/grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { YYABORT; @@ -2823,7 +2817,7 @@ yyreduce: case 98: /* Line 1455 of yacc.c */ -#line 836 "Ahuacatl/grammar.y" +#line 830 "Ahuacatl/grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { YYABORT; @@ -2836,7 +2830,7 @@ yyreduce: case 99: /* Line 1455 of yacc.c */ -#line 845 "Ahuacatl/grammar.y" +#line 839 "Ahuacatl/grammar.y" { (yyval.strval) = (yyvsp[(1) - (1)].strval); ;} @@ -2845,7 +2839,7 @@ yyreduce: case 100: /* Line 1455 of yacc.c */ -#line 851 "Ahuacatl/grammar.y" +#line 845 "Ahuacatl/grammar.y" { if (!(yyvsp[(1) - (1)].strval)) { YYABORT; @@ -2858,7 +2852,7 @@ yyreduce: case 101: /* Line 1455 of yacc.c */ -#line 858 "Ahuacatl/grammar.y" +#line 852 "Ahuacatl/grammar.y" { if (!(yyvsp[(2) - (2)].strval)) { YYABORT; @@ -2871,7 +2865,7 @@ yyreduce: /* Line 1455 of yacc.c */ -#line 2875 "Ahuacatl/grammar.c" +#line 2869 "Ahuacatl/grammar.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/Ahuacatl/grammar.y b/Ahuacatl/grammar.y index 71298a915f..08ee220d92 100644 --- a/Ahuacatl/grammar.y +++ b/Ahuacatl/grammar.y @@ -810,13 +810,7 @@ value_literal: bind_parameter: T_PARAMETER { - TRI_aql_node_t* node; - - if (!$1) { - YYABORT; - } - - node = TRI_CreateNodeParameterAql(context, $1); + TRI_aql_node_t* node = TRI_CreateNodeParameterAql(context, $1); if (!node) { YYABORT; } diff --git a/Ahuacatl/parser.c b/Ahuacatl/parser.c index 4fb8af3a2a..e096f9fcee 100644 --- a/Ahuacatl/parser.c +++ b/Ahuacatl/parser.c @@ -27,6 +27,7 @@ #include "Ahuacatl/parser.h" #include "Ahuacatl/ast-node.h" +#include "Ahuacatl/ahuacatl-bind-parameter.h" // ----------------------------------------------------------------------------- // --SECTION-- private macros @@ -109,6 +110,20 @@ TRI_aql_parse_context_t* TRI_CreateParseContextAql (TRI_vocbase_t* vocbase, context->_vocbase = vocbase; + // actual bind parameter values + TRI_InitAssociativePointer(&context->_parameterValues, + &TRI_HashStringKeyAssociativePointer, + &TRI_HashBindParameterAql, + &TRI_EqualBindParameterAql, + 0); + + // bind parameter names used in the query + TRI_InitAssociativePointer(&context->_parameterNames, + &TRI_HashStringKeyAssociativePointer, + &TRI_HashStringKeyAssociativePointer, + &TRI_EqualStringKeyAssociativePointer, + 0); + TRI_InitVectorPointer(&context->_stack); TRI_InitVectorPointer(&context->_nodes); TRI_InitVectorPointer(&context->_strings); @@ -185,6 +200,12 @@ void TRI_FreeParseContextAql (TRI_aql_parse_context_t* const context) { // free the stack TRI_DestroyVectorPointer(&context->_stack); + // free parameter names hash + TRI_DestroyAssociativePointer(&context->_parameterNames); + + // free parameter values + TRI_DestroyAssociativePointer(&context->_parameterValues); + // free query string if (context->_query) { TRI_Free(context->_query); @@ -202,6 +223,33 @@ void TRI_FreeParseContextAql (TRI_aql_parse_context_t* const context) { TRI_Free(context); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief add bind parameters to the context +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_AddBindParametersAql (TRI_aql_parse_context_t* const context, + const TRI_json_t* const parameters) { + return TRI_AddParameterValuesAql(context, parameters); +} + +//////////////////////////////////////////////////////////////////////////////// +/// @brief parse & validate the query string +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_ParseQueryAql (TRI_aql_parse_context_t* const context) { + if (Ahuacatlparse(context)) { + // lexing/parsing failed + return false; + } + + if (!TRI_ValidateBindParametersAql(context)) { + // invalid bind parameters + return false; + } + + return true; +} + //////////////////////////////////////////////////////////////////////////////// /// @brief create a new variable scope //////////////////////////////////////////////////////////////////////////////// diff --git a/Ahuacatl/parser.h b/Ahuacatl/parser.h index 98f7a48a2b..873e276f20 100644 --- a/Ahuacatl/parser.h +++ b/Ahuacatl/parser.h @@ -33,6 +33,7 @@ #include #include #include +#include #include "VocBase/vocbase.h" #include "VocBase/collection.h" @@ -95,6 +96,8 @@ typedef struct TRI_aql_parse_context_s { TRI_vector_pointer_t _stack; TRI_aql_error_t _error; TRI_vocbase_t* _vocbase; + TRI_associative_pointer_t _parameterValues; + TRI_associative_pointer_t _parameterNames; void* _first; char* _query; } @@ -118,7 +121,7 @@ TRI_aql_parse_context_t; //////////////////////////////////////////////////////////////////////////////// TRI_aql_parse_context_t* TRI_CreateParseContextAql (TRI_vocbase_t*, - const char* const); + const char* const); //////////////////////////////////////////////////////////////////////////////// /// @brief free a parse context @@ -126,6 +129,19 @@ TRI_aql_parse_context_t* TRI_CreateParseContextAql (TRI_vocbase_t*, void TRI_FreeParseContextAql (TRI_aql_parse_context_t* const); +//////////////////////////////////////////////////////////////////////////////// +/// @brief add bind parameters to the context +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_AddBindParametersAql (TRI_aql_parse_context_t* const, + const TRI_json_t* const); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief parse & validate the query string +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_ParseQueryAql (TRI_aql_parse_context_t* const); + //////////////////////////////////////////////////////////////////////////////// /// @brief create a new variable scope //////////////////////////////////////////////////////////////////////////////// diff --git a/BasicsC/associative.c b/BasicsC/associative.c index 02ae11f401..7668a3b421 100644 --- a/BasicsC/associative.c +++ b/BasicsC/associative.c @@ -28,6 +28,7 @@ #include "associative.h" #include "hashes.h" +#include "strings.h" // ----------------------------------------------------------------------------- // --SECTION-- ASSOCIATIVE ARRAY @@ -638,6 +639,16 @@ uint64_t TRI_HashStringKeyAssociativePointer (TRI_associative_pointer_t* array, return TRI_FnvHashString((char const*) key); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief General function to determine equality of two string values +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_EqualStringKeyAssociativePointer (TRI_associative_pointer_t* array, + void const* key, + void const* element) { + return TRI_EqualString((char*) key, (char*) element); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief lookups an element given a key //////////////////////////////////////////////////////////////////////////////// diff --git a/BasicsC/associative.h b/BasicsC/associative.h index e29ec2839b..d1a96d8e52 100644 --- a/BasicsC/associative.h +++ b/BasicsC/associative.h @@ -299,7 +299,13 @@ void TRI_FreeAssociativePointer (TRI_associative_pointer_t*); /// @brief General hash function that can be used to hash a string key //////////////////////////////////////////////////////////////////////////////// -uint64_t TRI_HashStringKeyAssociativePointer (TRI_associative_pointer_t*, void const* key); +uint64_t TRI_HashStringKeyAssociativePointer (TRI_associative_pointer_t*, void const*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief General function to determine equality of two string values +//////////////////////////////////////////////////////////////////////////////// + +bool TRI_EqualStringKeyAssociativePointer (TRI_associative_pointer_t*, void const*, void const*); //////////////////////////////////////////////////////////////////////////////// /// @brief lookups an element given a key diff --git a/BasicsC/errors.dat b/BasicsC/errors.dat index 25c8e3b06b..8339af7d17 100644 --- a/BasicsC/errors.dat +++ b/BasicsC/errors.dat @@ -119,6 +119,7 @@ ERROR_QUERY_LIMIT_VALUE_OUT_OF_RANGE,1521,"limit value '%s' is out of range","Wi ERROR_QUERY_VARIABLE_REDECLARED,1522,"variable '%s' is assigned multiple times","Will be raised when a variable gets re-assigned in a query." ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED,1523,"document attribute '%s' is assigned multiple times","Will be raised when a document attribute is re-assigned." ERROR_QUERY_VARIABLE_NAME_INVALID,1524,"variable name '%s' has an invalid format","Will be raised when an invalid variable name is used." +ERROR_QUERY_BIND_PARAMETERS_INVALID,1525,"invalid structure of bind parameters","Will be raised when the structure of bind parameters passed has an unexpected format." ################################################################################ ## AvocadoDB cursor errors diff --git a/BasicsC/voc-errors.c b/BasicsC/voc-errors.c index d55957fc80..93f941b9f7 100644 --- a/BasicsC/voc-errors.c +++ b/BasicsC/voc-errors.c @@ -85,6 +85,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_QUERY_VARIABLE_REDECLARED, "variable '%s' is assigned multiple times"); REG_ERROR(ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED, "document attribute '%s' is assigned multiple times"); REG_ERROR(ERROR_QUERY_VARIABLE_NAME_INVALID, "variable name '%s' has an invalid format"); + REG_ERROR(ERROR_QUERY_BIND_PARAMETERS_INVALID, "invalid structure of bind parameters"); REG_ERROR(ERROR_CURSOR_NOT_FOUND, "cursor not found"); REG_ERROR(ERROR_SESSION_USERHANDLER_URL_INVALID, "expecting /user/"); REG_ERROR(ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER, "cannot create user"); diff --git a/BasicsC/voc-errors.h b/BasicsC/voc-errors.h index 0ed19f7026..4a94e5881c 100644 --- a/BasicsC/voc-errors.h +++ b/BasicsC/voc-errors.h @@ -186,6 +186,9 @@ extern "C" { /// Will be raised when a document attribute is re-assigned. /// - 1524: @CODE{variable name '\%s' has an invalid format} /// Will be raised when an invalid variable name is used. +/// - 1525: @CODE{invalid structure of bind parameters} +/// Will be raised when the structure of bind parameters passed has an +/// unexpected format. /// - 1600: @CODE{cursor not found} /// Will be raised when a cursor is requested via its id but a cursor with /// that id cannot be found. @@ -1039,6 +1042,17 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_QUERY_VARIABLE_NAME_INVALID (1524) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1525: ERROR_QUERY_BIND_PARAMETERS_INVALID +/// +/// invalid structure of bind parameters +/// +/// Will be raised when the structure of bind parameters passed has an +/// unexpected format. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_QUERY_BIND_PARAMETERS_INVALID (1525) + //////////////////////////////////////////////////////////////////////////////// /// @brief 1600: ERROR_CURSOR_NOT_FOUND /// diff --git a/Makefile.files b/Makefile.files index ddcbff53d4..bc49e2d791 100644 --- a/Makefile.files +++ b/Makefile.files @@ -146,6 +146,7 @@ avocado_SOURCES = \ HttpsServer/HttpsServerImpl.cpp \ PriorityQueue/pqueueindex.c \ PriorityQueue/priorityqueue.c \ + Ahuacatl/ahuacatl-bind-parameter.c \ Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ Ahuacatl/ast-codegen-js.c \ diff --git a/Makefile.in b/Makefile.in index af8694bb03..84f574968d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -277,6 +277,7 @@ am_avocado_OBJECTS = Admin/ApplicationAdminServer.$(OBJEXT) \ HttpsServer/HttpsServerImpl.$(OBJEXT) \ PriorityQueue/pqueueindex.$(OBJEXT) \ PriorityQueue/priorityqueue.$(OBJEXT) \ + Ahuacatl/ahuacatl-bind-parameter.$(OBJEXT) \ Ahuacatl/ahuacatl-error.$(OBJEXT) \ Ahuacatl/ahuacatl-functions.$(OBJEXT) \ Ahuacatl/ast-codegen-js.$(OBJEXT) Ahuacatl/ast-dump.$(OBJEXT) \ @@ -752,6 +753,7 @@ avocado_SOURCES = \ HttpsServer/HttpsServerImpl.cpp \ PriorityQueue/pqueueindex.c \ PriorityQueue/priorityqueue.c \ + Ahuacatl/ahuacatl-bind-parameter.c \ Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ Ahuacatl/ast-codegen-js.c \ @@ -1650,6 +1652,8 @@ Ahuacatl/$(am__dirstamp): Ahuacatl/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) Ahuacatl/$(DEPDIR) @: > Ahuacatl/$(DEPDIR)/$(am__dirstamp) +Ahuacatl/ahuacatl-bind-parameter.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ + Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ahuacatl-error.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ahuacatl-functions.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ @@ -1904,6 +1908,7 @@ mostlyclean-compile: -rm -f Admin/RestAdminLogHandler.$(OBJEXT) -rm -f Admin/RestBaseHandler.$(OBJEXT) -rm -f Admin/RestVersionHandler.$(OBJEXT) + -rm -f Ahuacatl/ahuacatl-bind-parameter.$(OBJEXT) -rm -f Ahuacatl/ahuacatl-error.$(OBJEXT) -rm -f Ahuacatl/ahuacatl-functions.$(OBJEXT) -rm -f Ahuacatl/ast-codegen-js.$(OBJEXT) @@ -2131,6 +2136,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestAdminLogHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestBaseHandler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Admin/$(DEPDIR)/RestVersionHandler.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-bind-parameter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-functions.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-codegen-js.Po@am__quote@ diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index e8ef3966a8..1f30ae1241 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -2297,22 +2297,32 @@ static v8::Handle JS_RunAhuacatl (v8::Arguments const& argv) { v8::Handle result; TRI_json_t* parameters = NULL; + TRI_aql_parse_context_t* context; - - context = TRI_CreateParseContextAql(vocbase, queryString.c_str()); + context = TRI_CreateParseContextAql(vocbase, queryString.c_str()); if (!context) { return scope.Close(v8::ThrowException(v8::String::New("out of memory"))); } + + if (argv.Length() > 1) { + parameters = ConvertHelper(argv[1]); + if (!TRI_AddBindParametersAql(context, parameters)) { + v8::Handle errorObject = CreateErrorObjectAhuacatl(&context->_error); + TRI_FreeJson(parameters); + TRI_FreeParseContextAql(context); + return scope.Close(errorObject); + } + } - if (Ahuacatlparse(context)) { + if (parameters) { + TRI_FreeJson(parameters); + } + + if (!TRI_ParseQueryAql(context)) { v8::Handle errorObject = CreateErrorObjectAhuacatl(&context->_error); TRI_FreeParseContextAql(context); return scope.Close(errorObject); } - - if (argv.Length() > 1) { - parameters = ConvertHelper(argv[1]); - } if (context->_first) { char* code = TRI_GenerateCodeAql((TRI_aql_node_t*) context->_first); @@ -2324,10 +2334,6 @@ static v8::Handle JS_RunAhuacatl (v8::Arguments const& argv) { } TRI_FreeParseContextAql(context); - - if (parameters) { - TRI_FreeJson(parameters); - } return scope.Close(result); } diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index 28bcb6d969..4b41243926 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -79,6 +79,7 @@ ModuleCache["/internal"].exports.errors = { "ERROR_QUERY_VARIABLE_REDECLARED" : { "code" : 1522, "message" : "variable '%s' is assigned multiple times" }, "ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED" : { "code" : 1523, "message" : "document attribute '%s' is assigned multiple times" }, "ERROR_QUERY_VARIABLE_NAME_INVALID" : { "code" : 1524, "message" : "variable name '%s' has an invalid format" }, + "ERROR_QUERY_BIND_PARAMETERS_INVALID" : { "code" : 1525, "message" : "invalid structure of bind parameters" }, "ERROR_CURSOR_NOT_FOUND" : { "code" : 1600, "message" : "cursor not found" }, "ERROR_SESSION_USERHANDLER_URL_INVALID" : { "code" : 1700, "message" : "expecting /user/" }, "ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER" : { "code" : 1701, "message" : "cannot create user" }, diff --git a/js/common/bootstrap/js-errors.h b/js/common/bootstrap/js-errors.h index e524cbd73d..58f84e13ee 100644 --- a/js/common/bootstrap/js-errors.h +++ b/js/common/bootstrap/js-errors.h @@ -80,6 +80,7 @@ static string JS_common_bootstrap_errors = " \"ERROR_QUERY_VARIABLE_REDECLARED\" : { \"code\" : 1522, \"message\" : \"variable '%s' is assigned multiple times\" }, \n" " \"ERROR_QUERY_DOCUMENT_ATTRIBUTE_REDECLARED\" : { \"code\" : 1523, \"message\" : \"document attribute '%s' is assigned multiple times\" }, \n" " \"ERROR_QUERY_VARIABLE_NAME_INVALID\" : { \"code\" : 1524, \"message\" : \"variable name '%s' has an invalid format\" }, \n" + " \"ERROR_QUERY_BIND_PARAMETERS_INVALID\" : { \"code\" : 1525, \"message\" : \"invalid structure of bind parameters\" }, \n" " \"ERROR_CURSOR_NOT_FOUND\" : { \"code\" : 1600, \"message\" : \"cursor not found\" }, \n" " \"ERROR_SESSION_USERHANDLER_URL_INVALID\" : { \"code\" : 1700, \"message\" : \"expecting /user/\" }, \n" " \"ERROR_SESSION_USERHANDLER_CANNOT_CREATE_USER\" : { \"code\" : 1701, \"message\" : \"cannot create user\" }, \n" From d08f45d7785c1e3f8423254b98f543c27b0f826a Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 17:10:12 +0200 Subject: [PATCH 09/13] some renaming --- .gitignore | 2 +- Ahuacatl/ahuacatl-bind-parameter.h | 2 +- Ahuacatl/ahuacatl-grammar.c | 3085 ++++++++++++++++++++ Ahuacatl/ahuacatl-grammar.h | 133 + Ahuacatl/{grammar.y => ahuacatl-grammar.y} | 4 +- Ahuacatl/{parser.c => ahuacatl-parser.c} | 2 +- Ahuacatl/{parser.h => ahuacatl-parser.h} | 0 Ahuacatl/ahuacatl-tokens.c | 2703 +++++++++++++++++ Ahuacatl/{tokens.l => ahuacatl-tokens.l} | 4 +- Ahuacatl/ast-node.h | 2 +- Ahuacatl/grammar.c | 2 +- Makefile.files | 8 +- Makefile.in | 42 +- V8/v8-vocbase.cpp | 2 +- 14 files changed, 5957 insertions(+), 34 deletions(-) create mode 100644 Ahuacatl/ahuacatl-grammar.c create mode 100644 Ahuacatl/ahuacatl-grammar.h rename Ahuacatl/{grammar.y => ahuacatl-grammar.y} (99%) rename Ahuacatl/{parser.c => ahuacatl-parser.c} (99%) rename Ahuacatl/{parser.h => ahuacatl-parser.h} (100%) create mode 100644 Ahuacatl/ahuacatl-tokens.c rename Ahuacatl/{tokens.l => ahuacatl-tokens.l} (98%) diff --git a/.gitignore b/.gitignore index facd138aed..0378d99323 100644 --- a/.gitignore +++ b/.gitignore @@ -86,7 +86,7 @@ stamp-h* .svn *.swp tags -Ahuacatl/grammar.output +Ahuacatl/ahuacatl-grammar.output UnitTests/HttpInterface/logs UnitTests/Jutland/CsvReaderTest.cpp UnitTests/Jutland/Makefile.am diff --git a/Ahuacatl/ahuacatl-bind-parameter.h b/Ahuacatl/ahuacatl-bind-parameter.h index 6b0f20e330..4f6349c0a0 100644 --- a/Ahuacatl/ahuacatl-bind-parameter.h +++ b/Ahuacatl/ahuacatl-bind-parameter.h @@ -35,7 +35,7 @@ #include #include -#include "Ahuacatl/parser.h" +#include "Ahuacatl/ahuacatl-parser.h" #ifdef __cplusplus extern "C" { diff --git a/Ahuacatl/ahuacatl-grammar.c b/Ahuacatl/ahuacatl-grammar.c new file mode 100644 index 0000000000..33f6374609 --- /dev/null +++ b/Ahuacatl/ahuacatl-grammar.c @@ -0,0 +1,3085 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 1 + +/* Substitute the variable and function names. */ +#define yyparse Ahuacatlparse +#define yylex Ahuacatllex +#define yyerror Ahuacatlerror +#define yylval Ahuacatllval +#define yychar Ahuacatlchar +#define yydebug Ahuacatldebug +#define yynerrs Ahuacatlnerrs +#define yylloc Ahuacatllloc + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 10 "Ahuacatl/ahuacatl-grammar.y" + + +#include +#include + +#include +#include +#include + +#include "Ahuacatl/ast-node.h" +#include "Ahuacatl/ahuacatl-parser.h" +#include "Ahuacatl/ahuacatl-error.h" + + + +/* Line 189 of yacc.c */ +#line 97 "Ahuacatl/ahuacatl-grammar.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 1 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_END = 0, + T_FOR = 258, + T_LET = 259, + T_FILTER = 260, + T_RETURN = 261, + T_COLLECT = 262, + T_SORT = 263, + T_LIMIT = 264, + T_ASC = 265, + T_DESC = 266, + T_IN = 267, + T_INTO = 268, + T_NULL = 269, + T_TRUE = 270, + T_FALSE = 271, + T_STRING = 272, + T_QUOTED_STRING = 273, + T_NUMBER = 274, + T_PARAMETER = 275, + T_ASSIGN = 276, + T_NOT = 277, + T_AND = 278, + T_OR = 279, + T_EQ = 280, + T_NE = 281, + T_LT = 282, + T_GT = 283, + T_LE = 284, + T_GE = 285, + T_PLUS = 286, + T_MINUS = 287, + T_TIMES = 288, + T_DIV = 289, + T_MOD = 290, + T_QUESTION = 291, + T_COLON = 292, + T_COMMA = 293, + T_OPEN = 294, + T_CLOSE = 295, + T_DOC_OPEN = 296, + T_DOC_CLOSE = 297, + T_LIST_OPEN = 298, + T_LIST_CLOSE = 299, + UPLUS = 300, + UMINUS = 301, + FUNCCALL = 302, + REFERENCE = 303, + INDEXED = 304 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 26 "Ahuacatl/ahuacatl-grammar.y" + + TRI_aql_node_t* node; + char* strval; + bool boolval; + int64_t intval; + + + +/* Line 214 of yacc.c */ +#line 192 "Ahuacatl/ahuacatl-grammar.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + +/* Copy the second part of user declarations. */ + +/* Line 264 of yacc.c */ +#line 33 "Ahuacatl/ahuacatl-grammar.y" + + +//////////////////////////////////////////////////////////////////////////////// +/// @brief forward for lexer function defined in ahuacatl-tokens.l +//////////////////////////////////////////////////////////////////////////////// + +int Ahuacatllex (YYSTYPE*, YYLTYPE*, void*); + +//////////////////////////////////////////////////////////////////////////////// +/// @brief register parse error +//////////////////////////////////////////////////////////////////////////////// + +void Ahuacatlerror (YYLTYPE* locp, TRI_aql_parse_context_t* const context, const char* err) { + TRI_SetParseErrorAql(context, err, locp->first_line, locp->first_column); +} + +#define scanner context->_parser->_scanner + + +/* Line 264 of yacc.c */ +#line 237 "Ahuacatl/ahuacatl-grammar.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \ + && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; + YYLTYPE yyls_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + + 2 * YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 367 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 52 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 46 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 101 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 164 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 304 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 51, 50, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 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 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 8, 9, 12, 14, 16, 18, + 20, 22, 24, 29, 32, 33, 41, 42, 47, 49, + 53, 57, 59, 60, 63, 64, 68, 70, 74, 77, + 78, 80, 82, 85, 90, 93, 97, 101, 103, 105, + 107, 108, 114, 116, 118, 120, 123, 126, 129, 133, + 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, + 177, 181, 185, 191, 192, 194, 196, 200, 202, 204, + 205, 210, 211, 213, 215, 219, 220, 225, 226, 228, + 230, 234, 238, 240, 245, 252, 256, 258, 263, 267, + 269, 271, 273, 275, 277, 279, 281, 283, 285, 287, + 289, 291 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 53, 0, -1, -1, 54, 55, 72, -1, -1, 55, + 56, -1, 57, -1, 59, -1, 58, -1, 61, -1, + 66, -1, 71, -1, 3, 96, 12, 73, -1, 5, + 73, -1, -1, 4, 96, 60, 21, 39, 73, 40, + -1, -1, 7, 62, 63, 65, -1, 64, -1, 63, + 38, 64, -1, 96, 21, 73, -1, 73, -1, -1, + 13, 96, -1, -1, 8, 67, 68, -1, 69, -1, + 68, 38, 69, -1, 73, 70, -1, -1, 10, -1, + 11, -1, 9, 97, -1, 9, 97, 38, 97, -1, + 6, 73, -1, 39, 73, 40, -1, 39, 53, 40, + -1, 75, -1, 76, -1, 77, -1, -1, 17, 74, + 39, 78, 40, -1, 80, -1, 92, -1, 90, -1, + 31, 73, -1, 32, 73, -1, 22, 73, -1, 73, + 24, 73, -1, 73, 23, 73, -1, 73, 31, 73, + -1, 73, 32, 73, -1, 73, 33, 73, -1, 73, + 34, 73, -1, 73, 35, 73, -1, 73, 25, 73, + -1, 73, 26, 73, -1, 73, 27, 73, -1, 73, + 28, 73, -1, 73, 29, 73, -1, 73, 30, 73, + -1, 73, 12, 73, -1, 73, 36, 73, 37, 73, + -1, -1, 79, -1, 73, -1, 79, 38, 73, -1, + 81, -1, 85, -1, -1, 43, 82, 83, 44, -1, + -1, 84, -1, 73, -1, 84, 38, 73, -1, -1, + 41, 86, 87, 42, -1, -1, 88, -1, 89, -1, + 88, 38, 89, -1, 95, 37, 73, -1, 17, -1, + 90, 43, 73, 44, -1, 90, 43, 33, 44, 50, + 91, -1, 90, 50, 17, -1, 17, -1, 91, 43, + 73, 44, -1, 91, 50, 17, -1, 93, -1, 94, + -1, 18, -1, 19, -1, 14, -1, 15, -1, 16, + -1, 20, -1, 17, -1, 18, -1, 17, -1, 19, + -1, 51, 19, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 173, 173, 173, 189, 191, 196, 199, 202, 205, + 208, 211, 216, 227, 238, 238, 257, 257, 276, 278, + 283, 293, 301, 304, 310, 310, 330, 335, 343, 354, + 357, 360, 366, 374, 385, 397, 400, 408, 411, 414, + 417, 417, 439, 442, 445, 451, 459, 467, 478, 486, + 494, 502, 510, 518, 526, 534, 542, 550, 558, 566, + 574, 582, 593, 604, 606, 611, 614, 620, 623, 629, + 629, 642, 644, 649, 654, 662, 662, 675, 677, 682, + 684, 689, 697, 706, 713, 720, 730, 737, 744, 754, + 757, 763, 771, 785, 793, 801, 812, 823, 830, 839, + 845, 852 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "\"end of query string\"", "error", "$undefined", "\"FOR declaration\"", + "\"LET declaration\"", "\"FILTER declaration\"", + "\"RETURN declaration\"", "\"COLLECT declaration\"", + "\"SORT declaration\"", "\"LIMIT declaration\"", "\"ASC keyword\"", + "\"DESC keyword\"", "\"IN keyword\"", "\"INTO keyword\"", "\"null\"", + "\"true\"", "\"false\"", "\"identifier\"", "\"quoted string\"", + "\"number\"", "\"bind parameter\"", "\"assignment\"", "\"not operator\"", + "\"and operator\"", "\"or operator\"", "\"== operator\"", + "\"!= operator\"", "\"< operator\"", "\"> operator\"", "\"<= operator\"", + "\">= operator\"", "\"+ operator\"", "\"- operator\"", "\"* operator\"", + "\"/ operator\"", "\"% operator\"", "\"?\"", "\":\"", "\",\"", "\"(\"", + "\")\"", "\"{\"", "\"}\"", "\"[\"", "\"]\"", "UPLUS", "UMINUS", + "FUNCCALL", "REFERENCE", "INDEXED", "'.'", "'-'", "$accept", "query", + "$@1", "optional_statement_block_statements", + "statement_block_statement", "for_statement", "filter_statement", + "let_statement", "$@2", "collect_statement", "$@3", "collect_list", + "collect_element", "optional_into", "sort_statement", "$@4", "sort_list", + "sort_element", "sort_direction", "limit_statement", "return_statement", + "expression", "$@5", "operator_unary", "operator_binary", + "operator_ternary", "optional_function_call_arguments", + "function_arguments_list", "compound_type", "list", "$@6", + "optional_list_elements", "list_elements_list", "array", "$@7", + "optional_array_elements", "array_elements_list", "array_element", + "reference", "expansion", "atomic_value", "value_literal", + "bind_parameter", "array_element_name", "variable_name", "signed_number", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 46, 45 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 52, 54, 53, 55, 55, 56, 56, 56, 56, + 56, 56, 57, 58, 60, 59, 62, 61, 63, 63, + 64, 64, 65, 65, 67, 66, 68, 68, 69, 70, + 70, 70, 71, 71, 72, 73, 73, 73, 73, 73, + 74, 73, 73, 73, 73, 75, 75, 75, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 77, 78, 78, 79, 79, 80, 80, 82, + 81, 83, 83, 84, 84, 86, 85, 87, 87, 88, + 88, 89, 90, 90, 90, 90, 91, 91, 91, 92, + 92, 93, 93, 93, 93, 93, 94, 95, 95, 96, + 97, 97 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 3, 0, 2, 1, 1, 1, 1, + 1, 1, 4, 2, 0, 7, 0, 4, 1, 3, + 3, 1, 0, 2, 0, 3, 1, 3, 2, 0, + 1, 1, 2, 4, 2, 3, 3, 1, 1, 1, + 0, 5, 1, 1, 1, 2, 2, 2, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 5, 0, 1, 1, 3, 1, 1, 0, + 4, 0, 1, 1, 3, 0, 4, 0, 1, 1, + 3, 3, 1, 4, 6, 3, 1, 4, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 4, 1, 0, 0, 0, 0, 0, 16, + 24, 0, 5, 6, 8, 7, 9, 10, 11, 3, + 99, 0, 14, 93, 94, 95, 82, 91, 92, 96, + 0, 0, 0, 2, 75, 69, 13, 37, 38, 39, + 42, 67, 68, 44, 43, 89, 90, 34, 0, 0, + 100, 0, 32, 0, 0, 0, 47, 45, 46, 0, + 0, 77, 71, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 82, 22, 18, 21, 0, 25, 26, 29, 101, 0, + 12, 0, 63, 36, 35, 97, 98, 0, 78, 79, + 0, 73, 0, 72, 61, 49, 48, 55, 56, 57, + 58, 59, 60, 50, 51, 52, 53, 54, 0, 0, + 0, 85, 0, 0, 17, 0, 0, 30, 31, 28, + 33, 0, 65, 0, 64, 76, 0, 0, 70, 0, + 0, 0, 83, 23, 19, 20, 27, 0, 41, 0, + 80, 81, 74, 62, 0, 15, 66, 86, 84, 0, + 0, 0, 88, 87 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 2, 4, 12, 13, 14, 15, 54, 16, + 48, 81, 82, 124, 17, 49, 85, 86, 129, 18, + 19, 83, 55, 37, 38, 39, 133, 134, 40, 41, + 62, 102, 103, 42, 61, 97, 98, 99, 43, 158, + 44, 45, 46, 100, 84, 52 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -39 +static const yytype_int16 yypact[] = +{ + -39, 7, -39, -39, 97, -9, -9, 129, 129, -39, + -39, -10, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -1, -39, -39, -39, -39, -29, -39, -39, -39, + 129, 129, 129, 129, -39, -39, 283, -39, -39, -39, + -39, -39, -39, -38, -39, -39, -39, 283, 159, 129, + -39, 0, -21, 129, 1, -18, -39, -39, -39, 14, + 180, -3, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 129, 95, 27, + -19, 5, -39, 283, 24, 9, -39, 232, -39, -10, + 283, 69, 129, -39, -39, -39, -39, 74, 83, -39, + 85, 283, 79, 87, 49, 320, 308, 332, 332, 18, + 18, 18, 18, 39, 39, -39, -39, -39, 257, 91, + 4, -39, -9, 159, -39, 129, 129, -39, -39, -39, + -39, 129, 283, 89, 93, -39, -3, 129, -39, 129, + 129, 90, -39, -39, -39, 283, -39, 205, -39, 129, + -39, 283, 283, 283, 120, -39, 283, -39, -37, 129, + 122, 63, -39, -39 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -39, 108, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, 30, -39, -39, -39, -39, 28, -39, -39, + -39, -7, -39, -39, -39, -39, -39, -39, -39, -39, + -39, -39, -39, -39, -39, -39, -39, 19, -39, -39, + -39, -39, -39, -39, -2, 61 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -100 +static const yytype_int16 yytable[] = +{ + 36, 47, -99, 21, 22, 78, 159, 3, 20, 50, + -40, 53, 79, 160, 95, 96, 63, 89, 122, 88, + -40, 92, 91, 56, 57, 58, 60, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 51, 87, 123, 121, 125, 90, 126, 142, 72, + 73, 74, 75, 76, 93, 101, 104, 105, 106, 107, + 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 120, 74, 75, 76, 63, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 132, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 5, 6, 7, 8, 9, 10, 11, 163, 131, 23, + 24, 25, 26, 27, 28, 29, 135, 30, 145, 87, + 143, 136, 137, 138, 147, 139, 31, 32, 119, 148, + 151, 149, 152, 153, 33, 141, 34, 157, 35, 162, + 154, 59, 156, 23, 24, 25, 26, 27, 28, 29, + 130, 30, 161, 144, 146, 150, 0, 0, 0, 0, + 31, 32, 0, 0, 0, 0, 0, 0, 33, 0, + 34, 0, 35, 23, 24, 25, 80, 27, 28, 29, + 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, + 31, 32, 63, 0, 0, 0, 0, 0, 33, 0, + 34, 0, 35, 64, 65, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 77, 63, 0, 0, + 94, 0, 0, 0, 0, 0, 0, 0, 64, 65, + 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, + 76, 77, 127, 128, 63, 155, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 65, 66, 67, 68, + 69, 70, 71, 72, 73, 74, 75, 76, 77, 63, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, + 74, 75, 76, 77, 140, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, + 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 64, 63, 66, 67, 68, 69, 70, 71, 72, + 73, 74, 75, 76, 63, 66, 67, 68, 69, 70, + 71, 72, 73, 74, 75, 76, 0, 0, 0, 68, + 69, 70, 71, 72, 73, 74, 75, 76 +}; + +static const yytype_int16 yycheck[] = +{ + 7, 8, 21, 5, 6, 43, 43, 0, 17, 19, + 39, 12, 50, 50, 17, 18, 12, 38, 13, 19, + 39, 39, 21, 30, 31, 32, 33, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 51, 49, 38, 17, 21, 53, 38, 44, 31, + 32, 33, 34, 35, 40, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 33, 34, 35, 12, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 92, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 3, 4, 5, 6, 7, 8, 9, 44, 39, 14, + 15, 16, 17, 18, 19, 20, 42, 22, 125, 126, + 122, 38, 37, 44, 131, 38, 31, 32, 33, 40, + 137, 38, 139, 140, 39, 44, 41, 17, 43, 17, + 50, 33, 149, 14, 15, 16, 17, 18, 19, 20, + 89, 22, 159, 123, 126, 136, -1, -1, -1, -1, + 31, 32, -1, -1, -1, -1, -1, -1, 39, -1, + 41, -1, 43, 14, 15, 16, 17, 18, 19, 20, + -1, 22, -1, -1, -1, -1, -1, -1, -1, -1, + 31, 32, 12, -1, -1, -1, -1, -1, 39, -1, + 41, -1, 43, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 12, -1, -1, + 40, -1, -1, -1, -1, -1, -1, -1, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 10, 11, 12, 40, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 12, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 12, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 12, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 23, 12, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 12, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, -1, -1, -1, 27, + 28, 29, 30, 31, 32, 33, 34, 35 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 53, 54, 0, 55, 3, 4, 5, 6, 7, + 8, 9, 56, 57, 58, 59, 61, 66, 71, 72, + 17, 96, 96, 14, 15, 16, 17, 18, 19, 20, + 22, 31, 32, 39, 41, 43, 73, 75, 76, 77, + 80, 81, 85, 90, 92, 93, 94, 73, 62, 67, + 19, 51, 97, 12, 60, 74, 73, 73, 73, 53, + 73, 86, 82, 12, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 43, 50, + 17, 63, 64, 73, 96, 68, 69, 73, 19, 38, + 73, 21, 39, 40, 40, 17, 18, 87, 88, 89, + 95, 73, 83, 84, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 33, + 73, 17, 13, 38, 65, 21, 38, 10, 11, 70, + 97, 39, 73, 78, 79, 42, 38, 37, 44, 38, + 37, 44, 44, 96, 64, 73, 69, 73, 40, 38, + 89, 73, 73, 73, 50, 40, 73, 17, 91, 43, + 50, 73, 17, 44 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (&yylloc, context, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, &yylloc, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, Location, context); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, TRI_aql_parse_context_t* const context) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + TRI_aql_parse_context_t* const context; +#endif +{ + if (!yyvaluep) + return; + YYUSE (yylocationp); + YYUSE (context); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, TRI_aql_parse_context_t* const context) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, context) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + YYLTYPE const * const yylocationp; + TRI_aql_parse_context_t* const context; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + YY_LOCATION_PRINT (yyoutput, *yylocationp); + YYFPRINTF (yyoutput, ": "); + yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, context); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, TRI_aql_parse_context_t* const context) +#else +static void +yy_reduce_print (yyvsp, yylsp, yyrule, context) + YYSTYPE *yyvsp; + YYLTYPE *yylsp; + int yyrule; + TRI_aql_parse_context_t* const context; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , &(yylsp[(yyi + 1) - (yynrhs)]) , context); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, yylsp, Rule, context); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, TRI_aql_parse_context_t* const context) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, yylocationp, context) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + YYLTYPE *yylocationp; + TRI_aql_parse_context_t* const context; +#endif +{ + YYUSE (yyvaluep); + YYUSE (yylocationp); + YYUSE (context); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (TRI_aql_parse_context_t* const context); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (TRI_aql_parse_context_t* const context) +#else +int +yyparse (context) + TRI_aql_parse_context_t* const context; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Location data for the lookahead symbol. */ +YYLTYPE yylloc; + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + /* The location stack. */ + YYLTYPE yylsa[YYINITDEPTH]; + YYLTYPE *yyls; + YYLTYPE *yylsp; + + /* The locations where the error started and ended. */ + YYLTYPE yyerror_range[2]; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + YYLTYPE yyloc; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yyls = yylsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + yylsp = yyls; + +#if YYLTYPE_IS_TRIVIAL + /* Initialize the default location before parsing starts. */ + yylloc.first_line = yylloc.last_line = 1; + yylloc.first_column = yylloc.last_column = 1; +#endif + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + YYLTYPE *yyls1 = yyls; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yyls1, yysize * sizeof (*yylsp), + &yystacksize); + + yyls = yyls1; + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyls_alloc, yyls); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + yylsp = yyls + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + *++yylsp = yylloc; + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + /* Default location. */ + YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: + +/* Line 1455 of yacc.c */ +#line 173 "Ahuacatl/ahuacatl-grammar.y" + { + // a query or a sub-query always starts a new scope + if (!TRI_StartScopeParseContextAql(context)) { + YYABORT; + } + ;} + break; + + case 3: + +/* Line 1455 of yacc.c */ +#line 178 "Ahuacatl/ahuacatl-grammar.y" + { + // end the scope + TRI_AddStatementAql(context, (yyvsp[(3) - (3)].node)); + + (yyval.node) = (TRI_aql_node_t*) TRI_GetFirstStatementAql(context); + + TRI_EndScopeParseContextAql(context); + ;} + break; + + case 4: + +/* Line 1455 of yacc.c */ +#line 189 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 5: + +/* Line 1455 of yacc.c */ +#line 191 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 6: + +/* Line 1455 of yacc.c */ +#line 196 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 7: + +/* Line 1455 of yacc.c */ +#line 199 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 8: + +/* Line 1455 of yacc.c */ +#line 202 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 9: + +/* Line 1455 of yacc.c */ +#line 205 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 10: + +/* Line 1455 of yacc.c */ +#line 208 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 11: + +/* Line 1455 of yacc.c */ +#line 211 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_AddStatementAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 12: + +/* Line 1455 of yacc.c */ +#line 216 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeForAql(context, (yyvsp[(2) - (4)].strval), (yyvsp[(4) - (4)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 227 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeFilterAql(context, (yyvsp[(2) - (2)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 238 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushStackAql(context, (yyvsp[(2) - (2)].strval)) || !TRI_StartScopeParseContextAql(context)) { + YYABORT; + } + ;} + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 242 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node; + + TRI_EndScopeParseContextAql(context); + + node = TRI_CreateNodeAssignAql(context, TRI_PopStackAql(context), (yyvsp[(6) - (7)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 257 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeListAql(context); + + if (!node) { + YYABORT; + } + + TRI_PushStackAql(context, node); + ;} + break; + + case 17: + +/* Line 1455 of yacc.c */ +#line 265 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeCollectAql(context, TRI_PopStackAql(context), (yyvsp[(4) - (4)].strval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 18: + +/* Line 1455 of yacc.c */ +#line 276 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 19: + +/* Line 1455 of yacc.c */ +#line 278 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 20: + +/* Line 1455 of yacc.c */ +#line 283 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeAssignAql(context, (yyvsp[(1) - (3)].strval), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + if (!TRI_PushListAql(context, node)) { + YYABORT; + } + ;} + break; + + case 21: + +/* Line 1455 of yacc.c */ +#line 293 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { + YYABORT; + } + ;} + break; + + case 22: + +/* Line 1455 of yacc.c */ +#line 301 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.strval) = NULL; + ;} + break; + + case 23: + +/* Line 1455 of yacc.c */ +#line 304 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.strval) = (yyvsp[(2) - (2)].strval); + ;} + break; + + case 24: + +/* Line 1455 of yacc.c */ +#line 310 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeListAql(context); + + if (!node) { + YYABORT; + } + + TRI_PushStackAql(context, node); + ;} + break; + + case 25: + +/* Line 1455 of yacc.c */ +#line 318 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* list = TRI_PopStackAql(context); + TRI_aql_node_t* node = TRI_CreateNodeSortAql(context, list); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 26: + +/* Line 1455 of yacc.c */ +#line 330 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { + YYABORT; + } + ;} + break; + + case 27: + +/* Line 1455 of yacc.c */ +#line 335 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushListAql(context, (yyvsp[(3) - (3)].node))) { + YYABORT; + } + ;} + break; + + case 28: + +/* Line 1455 of yacc.c */ +#line 343 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeSortElementAql(context, (yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].boolval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 29: + +/* Line 1455 of yacc.c */ +#line 354 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.boolval) = true; + ;} + break; + + case 30: + +/* Line 1455 of yacc.c */ +#line 357 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.boolval) = true; + ;} + break; + + case 31: + +/* Line 1455 of yacc.c */ +#line 360 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.boolval) = false; + ;} + break; + + case 32: + +/* Line 1455 of yacc.c */ +#line 366 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, 0, (yyvsp[(2) - (2)].intval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 33: + +/* Line 1455 of yacc.c */ +#line 374 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeLimitAql(context, (yyvsp[(2) - (4)].intval), (yyvsp[(4) - (4)].intval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 34: + +/* Line 1455 of yacc.c */ +#line 385 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeReturnAql(context, (yyvsp[(2) - (2)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 35: + +/* Line 1455 of yacc.c */ +#line 397 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(2) - (3)].node); + ;} + break; + + case 36: + +/* Line 1455 of yacc.c */ +#line 400 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeSubqueryAql(context, (yyvsp[(2) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 37: + +/* Line 1455 of yacc.c */ +#line 408 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 38: + +/* Line 1455 of yacc.c */ +#line 411 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 414 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 40: + +/* Line 1455 of yacc.c */ +#line 417 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node; + + if (!TRI_PushStackAql(context, (yyvsp[(1) - (1)].strval))) { + YYABORT; + } + + node = TRI_CreateNodeListAql(context); + if (!node) { + YYABORT; + } + + TRI_PushStackAql(context, node); + ;} + break; + + case 41: + +/* Line 1455 of yacc.c */ +#line 430 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* list = TRI_PopStackAql(context); + TRI_aql_node_t* node = TRI_CreateNodeFcallAql(context, TRI_PopStackAql(context), list); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 42: + +/* Line 1455 of yacc.c */ +#line 439 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 43: + +/* Line 1455 of yacc.c */ +#line 442 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 44: + +/* Line 1455 of yacc.c */ +#line 445 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 45: + +/* Line 1455 of yacc.c */ +#line 451 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryPlusAql(context, (yyvsp[(2) - (2)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 46: + +/* Line 1455 of yacc.c */ +#line 459 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryMinusAql(context, (yyvsp[(2) - (2)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 47: + +/* Line 1455 of yacc.c */ +#line 467 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorUnaryNotAql(context, (yyvsp[(2) - (2)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 48: + +/* Line 1455 of yacc.c */ +#line 478 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryOrAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 49: + +/* Line 1455 of yacc.c */ +#line 486 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryAndAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 50: + +/* Line 1455 of yacc.c */ +#line 494 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryPlusAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 51: + +/* Line 1455 of yacc.c */ +#line 502 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryMinusAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 52: + +/* Line 1455 of yacc.c */ +#line 510 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryTimesAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 53: + +/* Line 1455 of yacc.c */ +#line 518 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryDivAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 54: + +/* Line 1455 of yacc.c */ +#line 526 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryModAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 55: + +/* Line 1455 of yacc.c */ +#line 534 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryEqAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 56: + +/* Line 1455 of yacc.c */ +#line 542 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryNeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 57: + +/* Line 1455 of yacc.c */ +#line 550 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLtAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 58: + +/* Line 1455 of yacc.c */ +#line 558 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGtAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 59: + +/* Line 1455 of yacc.c */ +#line 566 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryLeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 60: + +/* Line 1455 of yacc.c */ +#line 574 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryGeAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 61: + +/* Line 1455 of yacc.c */ +#line 582 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorBinaryInAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 62: + +/* Line 1455 of yacc.c */ +#line 593 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeOperatorTernaryAql(context, (yyvsp[(1) - (5)].node), (yyvsp[(3) - (5)].node), (yyvsp[(5) - (5)].node)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 63: + +/* Line 1455 of yacc.c */ +#line 604 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 64: + +/* Line 1455 of yacc.c */ +#line 606 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 65: + +/* Line 1455 of yacc.c */ +#line 611 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_PushListAql(context, (yyvsp[(1) - (1)].node)); + ;} + break; + + case 66: + +/* Line 1455 of yacc.c */ +#line 614 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_PushListAql(context, (yyvsp[(3) - (3)].node)); + ;} + break; + + case 67: + +/* Line 1455 of yacc.c */ +#line 620 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 68: + +/* Line 1455 of yacc.c */ +#line 623 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 69: + +/* Line 1455 of yacc.c */ +#line 629 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeListAql(context); + if (!node) { + YYABORT; + } + + TRI_PushStackAql(context, node); + ;} + break; + + case 70: + +/* Line 1455 of yacc.c */ +#line 636 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = TRI_PopStackAql(context); + ;} + break; + + case 71: + +/* Line 1455 of yacc.c */ +#line 642 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 72: + +/* Line 1455 of yacc.c */ +#line 644 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 73: + +/* Line 1455 of yacc.c */ +#line 649 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushListAql(context, (yyvsp[(1) - (1)].node))) { + YYABORT; + } + ;} + break; + + case 74: + +/* Line 1455 of yacc.c */ +#line 654 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushListAql(context, (yyvsp[(3) - (3)].node))) { + YYABORT; + } + ;} + break; + + case 75: + +/* Line 1455 of yacc.c */ +#line 662 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeArrayAql(context); + if (!node) { + YYABORT; + } + + TRI_PushStackAql(context, node); + ;} + break; + + case 76: + +/* Line 1455 of yacc.c */ +#line 669 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = TRI_PopStackAql(context); + ;} + break; + + case 77: + +/* Line 1455 of yacc.c */ +#line 675 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 78: + +/* Line 1455 of yacc.c */ +#line 677 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 79: + +/* Line 1455 of yacc.c */ +#line 682 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 80: + +/* Line 1455 of yacc.c */ +#line 684 "Ahuacatl/ahuacatl-grammar.y" + { + ;} + break; + + case 81: + +/* Line 1455 of yacc.c */ +#line 689 "Ahuacatl/ahuacatl-grammar.y" + { + if (!TRI_PushArrayAql(context, (yyvsp[(1) - (3)].strval), (yyvsp[(3) - (3)].node))) { + YYABORT; + } + ;} + break; + + case 82: + +/* Line 1455 of yacc.c */ +#line 697 "Ahuacatl/ahuacatl-grammar.y" + { + // variable or collection + TRI_aql_node_t* node = TRI_CreateNodeReferenceAql(context, (yyvsp[(1) - (1)].strval), !TRI_VariableExistsAql(context, (yyvsp[(1) - (1)].strval))); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 83: + +/* Line 1455 of yacc.c */ +#line 706 "Ahuacatl/ahuacatl-grammar.y" + { + // variable[] + (yyval.node) = TRI_CreateNodeIndexedAql(context, (yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].node)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 84: + +/* Line 1455 of yacc.c */ +#line 713 "Ahuacatl/ahuacatl-grammar.y" + { + // variable[*] + (yyval.node) = TRI_CreateNodeExpandAql(context, (yyvsp[(1) - (6)].node), (yyvsp[(6) - (6)].node)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 85: + +/* Line 1455 of yacc.c */ +#line 720 "Ahuacatl/ahuacatl-grammar.y" + { + // variable.reference + (yyval.node) = TRI_CreateNodeAttributeAccessAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].strval)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 86: + +/* Line 1455 of yacc.c */ +#line 730 "Ahuacatl/ahuacatl-grammar.y" + { + // reference + (yyval.node) = TRI_CreateNodeAttributeAql(context, (yyvsp[(1) - (1)].strval)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 87: + +/* Line 1455 of yacc.c */ +#line 737 "Ahuacatl/ahuacatl-grammar.y" + { + // variable[] + (yyval.node) = TRI_CreateNodeIndexedAql(context, (yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].node)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 88: + +/* Line 1455 of yacc.c */ +#line 744 "Ahuacatl/ahuacatl-grammar.y" + { + // variable.variable + (yyval.node) = TRI_CreateNodeAttributeAccessAql(context, (yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].strval)); + if (!(yyval.node)) { + YYABORT; + } + ;} + break; + + case 89: + +/* Line 1455 of yacc.c */ +#line 754 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 90: + +/* Line 1455 of yacc.c */ +#line 757 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.node) = (yyvsp[(1) - (1)].node); + ;} + break; + + case 91: + +/* Line 1455 of yacc.c */ +#line 763 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeValueStringAql(context, (yyvsp[(1) - (1)].strval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 92: + +/* Line 1455 of yacc.c */ +#line 771 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node; + + if (!(yyvsp[(1) - (1)].strval)) { + YYABORT; + } + + node = TRI_CreateNodeValueDoubleAql(context, TRI_DoubleString((yyvsp[(1) - (1)].strval))); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 93: + +/* Line 1455 of yacc.c */ +#line 785 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeValueNullAql(context); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 94: + +/* Line 1455 of yacc.c */ +#line 793 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, true); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 95: + +/* Line 1455 of yacc.c */ +#line 801 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeValueBoolAql(context, false); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 96: + +/* Line 1455 of yacc.c */ +#line 812 "Ahuacatl/ahuacatl-grammar.y" + { + TRI_aql_node_t* node = TRI_CreateNodeParameterAql(context, (yyvsp[(1) - (1)].strval)); + if (!node) { + YYABORT; + } + + (yyval.node) = node; + ;} + break; + + case 97: + +/* Line 1455 of yacc.c */ +#line 823 "Ahuacatl/ahuacatl-grammar.y" + { + if (!(yyvsp[(1) - (1)].strval)) { + YYABORT; + } + + (yyval.strval) = (yyvsp[(1) - (1)].strval); + ;} + break; + + case 98: + +/* Line 1455 of yacc.c */ +#line 830 "Ahuacatl/ahuacatl-grammar.y" + { + if (!(yyvsp[(1) - (1)].strval)) { + YYABORT; + } + + (yyval.strval) = (yyvsp[(1) - (1)].strval); + ;} + break; + + case 99: + +/* Line 1455 of yacc.c */ +#line 839 "Ahuacatl/ahuacatl-grammar.y" + { + (yyval.strval) = (yyvsp[(1) - (1)].strval); + ;} + break; + + case 100: + +/* Line 1455 of yacc.c */ +#line 845 "Ahuacatl/ahuacatl-grammar.y" + { + if (!(yyvsp[(1) - (1)].strval)) { + YYABORT; + } + + (yyval.intval) = TRI_Int64String((yyvsp[(1) - (1)].strval)); + ;} + break; + + case 101: + +/* Line 1455 of yacc.c */ +#line 852 "Ahuacatl/ahuacatl-grammar.y" + { + if (!(yyvsp[(2) - (2)].strval)) { + YYABORT; + } + + (yyval.intval) = - TRI_Int64String((yyvsp[(2) - (2)].strval)); + ;} + break; + + + +/* Line 1455 of yacc.c */ +#line 2869 "Ahuacatl/ahuacatl-grammar.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + *++yylsp = yyloc; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (&yylloc, context, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (&yylloc, context, yymsg); + } + else + { + yyerror (&yylloc, context, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + yyerror_range[0] = yylloc; + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, &yylloc, context); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + yyerror_range[0] = yylsp[1-yylen]; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + yyerror_range[0] = *yylsp; + yydestruct ("Error: popping", + yystos[yystate], yyvsp, yylsp, context); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + yyerror_range[1] = yylloc; + /* Using YYLLOC is tempting, but would change the location of + the lookahead. YYLOC is available though. */ + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); + *++yylsp = yyloc; + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (&yylloc, context, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc, context); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, yylsp, context); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + diff --git a/Ahuacatl/ahuacatl-grammar.h b/Ahuacatl/ahuacatl-grammar.h new file mode 100644 index 0000000000..8ee82d60e3 --- /dev/null +++ b/Ahuacatl/ahuacatl-grammar.h @@ -0,0 +1,133 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + T_END = 0, + T_FOR = 258, + T_LET = 259, + T_FILTER = 260, + T_RETURN = 261, + T_COLLECT = 262, + T_SORT = 263, + T_LIMIT = 264, + T_ASC = 265, + T_DESC = 266, + T_IN = 267, + T_INTO = 268, + T_NULL = 269, + T_TRUE = 270, + T_FALSE = 271, + T_STRING = 272, + T_QUOTED_STRING = 273, + T_NUMBER = 274, + T_PARAMETER = 275, + T_ASSIGN = 276, + T_NOT = 277, + T_AND = 278, + T_OR = 279, + T_EQ = 280, + T_NE = 281, + T_LT = 282, + T_GT = 283, + T_LE = 284, + T_GE = 285, + T_PLUS = 286, + T_MINUS = 287, + T_TIMES = 288, + T_DIV = 289, + T_MOD = 290, + T_QUESTION = 291, + T_COLON = 292, + T_COMMA = 293, + T_OPEN = 294, + T_CLOSE = 295, + T_DOC_OPEN = 296, + T_DOC_CLOSE = 297, + T_LIST_OPEN = 298, + T_LIST_CLOSE = 299, + UPLUS = 300, + UMINUS = 301, + FUNCCALL = 302, + REFERENCE = 303, + INDEXED = 304 + }; +#endif + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 1676 of yacc.c */ +#line 26 "Ahuacatl/ahuacatl-grammar.y" + + TRI_aql_node_t* node; + char* strval; + bool boolval; + int64_t intval; + + + +/* Line 1676 of yacc.c */ +#line 111 "Ahuacatl/ahuacatl-grammar.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + + +#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED +typedef struct YYLTYPE +{ + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +# define yyltype YYLTYPE /* obsolescent; will be withdrawn */ +# define YYLTYPE_IS_DECLARED 1 +# define YYLTYPE_IS_TRIVIAL 1 +#endif + + + diff --git a/Ahuacatl/grammar.y b/Ahuacatl/ahuacatl-grammar.y similarity index 99% rename from Ahuacatl/grammar.y rename to Ahuacatl/ahuacatl-grammar.y index 08ee220d92..46af9f3f86 100644 --- a/Ahuacatl/grammar.y +++ b/Ahuacatl/ahuacatl-grammar.y @@ -17,7 +17,7 @@ #include #include "Ahuacatl/ast-node.h" -#include "Ahuacatl/parser.h" +#include "Ahuacatl/ahuacatl-parser.h" #include "Ahuacatl/ahuacatl-error.h" %} @@ -33,7 +33,7 @@ %{ //////////////////////////////////////////////////////////////////////////////// -/// @brief forward for lexer function defined in tokens.l +/// @brief forward for lexer function defined in ahuacatl-tokens.l //////////////////////////////////////////////////////////////////////////////// int Ahuacatllex (YYSTYPE*, YYLTYPE*, void*); diff --git a/Ahuacatl/parser.c b/Ahuacatl/ahuacatl-parser.c similarity index 99% rename from Ahuacatl/parser.c rename to Ahuacatl/ahuacatl-parser.c index e096f9fcee..7030b1acfd 100644 --- a/Ahuacatl/parser.c +++ b/Ahuacatl/ahuacatl-parser.c @@ -25,7 +25,7 @@ /// @author Copyright 2012, triagens GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -#include "Ahuacatl/parser.h" +#include "Ahuacatl/ahuacatl-parser.h" #include "Ahuacatl/ast-node.h" #include "Ahuacatl/ahuacatl-bind-parameter.h" diff --git a/Ahuacatl/parser.h b/Ahuacatl/ahuacatl-parser.h similarity index 100% rename from Ahuacatl/parser.h rename to Ahuacatl/ahuacatl-parser.h diff --git a/Ahuacatl/ahuacatl-tokens.c b/Ahuacatl/ahuacatl-tokens.c new file mode 100644 index 0000000000..5e23889187 --- /dev/null +++ b/Ahuacatl/ahuacatl-tokens.c @@ -0,0 +1,2703 @@ + +#line 3 "Ahuacatl/ahuacatl-tokens.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +/* %not-for-header */ + +/* %if-c-only */ +/* %if-not-reentrant */ +/* %endif */ +/* %endif */ +/* %ok-for-header */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* %if-c++-only */ +/* %endif */ + +/* %if-c-only */ + +/* %endif */ + +/* %if-c-only */ + +/* %endif */ + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +/* %if-c-only */ +#include +#include +#include +#include +/* %endif */ + +/* %if-tables-serialization */ +/* %endif */ +/* end standard C headers. */ + +/* %if-c-or-c++ */ +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +/* %endif */ + +/* %if-c++-only */ +/* %endif */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* %not-for-header */ + +/* Returned upon end-of-file. */ +#define YY_NULL 0 +/* %ok-for-header */ + +/* %not-for-header */ + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) +/* %ok-for-header */ + +/* %if-reentrant */ + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* %endif */ + +/* %if-not-reentrant */ +/* %endif */ + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE Ahuacatlrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +/* %if-not-reentrant */ +/* %endif */ + +/* %if-c-only */ +/* %if-not-reentrant */ +/* %endif */ +/* %endif */ + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE Ahuacatllex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { +/* %if-c-only */ + FILE *yy_input_file; +/* %endif */ + +/* %if-c++-only */ +/* %endif */ + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via Ahuacatlrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* %if-c-only Standard (non-C++) definition */ +/* %not-for-header */ + +/* %if-not-reentrant */ +/* %endif */ +/* %ok-for-header */ + +/* %endif */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +/* %if-c-only Standard (non-C++) definition */ + +/* %if-not-reentrant */ +/* %not-for-header */ + +/* %ok-for-header */ + +/* %endif */ + +void Ahuacatlrestart (FILE *input_file ,yyscan_t yyscanner ); +void Ahuacatl_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE Ahuacatl_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void Ahuacatl_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void Ahuacatl_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void Ahuacatlpush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void Ahuacatlpop_buffer_state (yyscan_t yyscanner ); + +static void Ahuacatlensure_buffer_stack (yyscan_t yyscanner ); +static void Ahuacatl_load_buffer_state (yyscan_t yyscanner ); +static void Ahuacatl_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER Ahuacatl_flush_buffer(YY_CURRENT_BUFFER ,yyscanner) + +YY_BUFFER_STATE Ahuacatl_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner ); +YY_BUFFER_STATE Ahuacatl_scan_string (yyconst char *yy_str ,yyscan_t yyscanner ); +YY_BUFFER_STATE Ahuacatl_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner ); + +/* %endif */ + +void *Ahuacatlalloc (yy_size_t ,yyscan_t yyscanner ); +void *Ahuacatlrealloc (void *,yy_size_t ,yyscan_t yyscanner ); +void Ahuacatlfree (void * ,yyscan_t yyscanner ); + +#define yy_new_buffer Ahuacatl_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + Ahuacatlensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + Ahuacatl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + Ahuacatlensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + Ahuacatl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */ +/* Begin user sect3 */ + +#define Ahuacatlwrap(n) 1 +#define YY_SKIP_YYWRAP + +#define FLEX_DEBUG + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +/* %if-c-only Standard (non-C++) definition */ + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* %endif */ + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ +/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ +/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\ + yyg->yy_c_buf_p = yy_cp; + +/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */ +#define YY_NUM_RULES 47 +#define YY_END_OF_BUFFER 48 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[120] = + { 0, + 0, 0, 48, 46, 45, 45, 22, 46, 29, 46, + 46, 33, 34, 27, 25, 32, 26, 28, 43, 43, + 31, 20, 21, 18, 30, 46, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 37, 38, 46, + 46, 35, 46, 36, 45, 16, 0, 41, 0, 23, + 0, 42, 0, 0, 43, 19, 15, 17, 44, 39, + 39, 39, 39, 39, 39, 39, 10, 39, 39, 39, + 39, 39, 39, 39, 0, 0, 0, 40, 24, 43, + 44, 8, 39, 39, 39, 39, 1, 39, 2, 39, + 39, 39, 39, 39, 39, 39, 0, 39, 9, 39, + + 39, 11, 39, 12, 39, 6, 13, 0, 43, 39, + 14, 39, 7, 39, 39, 3, 4, 5, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 5, 1, 1, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 19, 1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 26, 26, 31, 26, 26, 32, 33, 34, 35, 26, + 26, 36, 37, 38, 39, 26, 26, 26, 26, 26, + 40, 41, 42, 1, 43, 44, 45, 26, 46, 47, + + 48, 49, 26, 26, 50, 26, 26, 51, 52, 53, + 54, 26, 26, 55, 56, 57, 58, 26, 26, 26, + 26, 26, 59, 60, 61, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[62] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, + 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, + 1, 1, 4, 1, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, + 1 + } ; + +static yyconst flex_int16_t yy_base[129] = + { 0, + 0, 0, 208, 239, 60, 62, 186, 61, 239, 199, + 59, 239, 239, 239, 239, 239, 239, 239, 190, 53, + 239, 182, 180, 177, 239, 0, 32, 0, 37, 44, + 49, 42, 48, 39, 53, 50, 50, 239, 239, 154, + 46, 239, 136, 239, 104, 239, 70, 239, 192, 239, + 73, 239, 191, 91, 95, 239, 239, 239, 0, 0, + 88, 84, 80, 86, 87, 84, 83, 84, 90, 92, + 87, 90, 88, 111, 50, 89, 86, 239, 239, 130, + 0, 0, 99, 105, 112, 114, 0, 118, 0, 124, + 124, 118, 120, 131, 0, 144, 152, 134, 0, 136, + + 138, 0, 135, 0, 144, 0, 0, 171, 173, 154, + 0, 147, 0, 151, 155, 0, 0, 0, 239, 212, + 216, 80, 219, 221, 225, 228, 231, 234 + } ; + +static yyconst flex_int16_t yy_def[129] = + { 0, + 119, 1, 119, 119, 119, 119, 119, 120, 119, 119, + 121, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 122, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 119, 119, 124, + 125, 119, 119, 119, 119, 119, 120, 119, 120, 119, + 121, 119, 121, 119, 119, 119, 119, 119, 126, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 127, 124, 125, 125, 119, 119, 119, + 126, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 123, 123, 123, 123, 128, 127, 119, 123, 123, 123, + + 123, 123, 123, 123, 123, 123, 123, 119, 119, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 0, 119, + 119, 119, 119, 119, 119, 119, 119, 119 + } ; + +static yyconst flex_int16_t yy_nxt[301] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 4, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 28, 31, + 32, 33, 28, 34, 28, 35, 36, 37, 28, 38, + 4, 39, 40, 41, 27, 29, 30, 28, 31, 32, + 33, 28, 34, 28, 35, 36, 37, 28, 42, 43, + 44, 45, 45, 45, 45, 48, 52, 54, 61, 55, + 55, 62, 63, 64, 48, 67, 68, 70, 69, 65, + 52, 71, 59, 66, 72, 73, 77, 61, 119, 78, + 62, 63, 75, 64, 67, 68, 70, 69, 65, 53, + + 71, 49, 66, 72, 73, 45, 45, 80, 80, 54, + 49, 55, 55, 53, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 92, 93, 94, 95, 95, 77, + 98, 99, 78, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 93, 94, 80, 80, 100, 98, + 99, 101, 102, 95, 103, 104, 105, 106, 97, 107, + 95, 95, 110, 108, 111, 108, 112, 100, 109, 109, + 101, 102, 113, 103, 104, 105, 106, 97, 107, 114, + 115, 110, 116, 111, 117, 112, 95, 109, 109, 109, + 109, 113, 118, 119, 119, 79, 75, 58, 114, 115, + + 57, 116, 56, 117, 54, 50, 46, 119, 119, 119, + 119, 118, 47, 47, 47, 47, 51, 51, 51, 51, + 60, 60, 60, 74, 74, 76, 76, 76, 76, 81, + 81, 81, 96, 96, 96, 95, 95, 95, 3, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119 + + } ; + +static yyconst flex_int16_t yy_chk[301] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 5, 5, 6, 6, 8, 11, 20, 27, 20, + 20, 29, 30, 31, 47, 32, 33, 34, 33, 31, + 51, 35, 122, 31, 36, 37, 41, 27, 77, 41, + 29, 30, 75, 31, 32, 33, 34, 33, 31, 11, + + 35, 8, 31, 36, 37, 45, 45, 54, 54, 55, + 47, 55, 55, 51, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 74, 76, + 83, 84, 76, 61, 62, 63, 64, 65, 66, 67, + 68, 69, 70, 71, 72, 73, 80, 80, 85, 83, + 84, 86, 88, 74, 90, 91, 92, 93, 80, 94, + 96, 96, 98, 97, 100, 97, 101, 85, 97, 97, + 86, 88, 103, 90, 91, 92, 93, 80, 94, 105, + 110, 98, 112, 100, 114, 101, 96, 108, 108, 109, + 109, 103, 115, 53, 49, 43, 40, 24, 105, 110, + + 23, 112, 22, 114, 19, 10, 7, 3, 0, 0, + 0, 115, 120, 120, 120, 120, 121, 121, 121, 121, + 123, 123, 123, 124, 124, 125, 125, 125, 125, 126, + 126, 126, 127, 127, 127, 128, 128, 128, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119 + + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[48] = + { 0, +0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 0, 0, 1, 0, 0, }; + +static yyconst flex_int16_t yy_rule_linenum[47] = + { 0, + 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, + 89, 97, 101, 105, 113, 117, 121, 125, 129, 133, + 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, + 177, 185, 189, 193, 197, 201, 205, 209, 217, 222, + 227, 232, 237, 246, 255, 259 + } ; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#include +#include + +#include "Ahuacatl/ast-node.h" +#include "Ahuacatl/ahuacatl-parser.h" +#include "Ahuacatl/ahuacatl-grammar.h" + +#define YY_EXTRA_TYPE TRI_aql_parse_context_t* + +#define YY_USER_ACTION yylloc->first_line = yylineno; yylloc->first_column = yycolumn; yylloc->last_column = yycolumn + yyleng - 1; yycolumn += yyleng; + +#define YY_NO_INPUT 1 + +#define YY_INPUT(resultBuffer, resultState, maxBytesToRead) { \ + TRI_aql_parser_t* parser = (yyextra)->_parser; \ + int length = parser->_length; \ + if (length > maxBytesToRead) { \ + length = maxBytesToRead; \ + } \ + if (length > 0) { \ + memcpy(resultBuffer, parser->_buffer, length); \ + parser->_buffer += length; \ + parser->_length -= length; \ + resultState = length; \ + } \ + else { \ + resultState = YY_NULL; \ + } \ +} + +#define INITIAL 0 + +#ifndef YY_NO_UNISTD_H +/* Special case for "unistd.h", since it is non-ANSI. We include it way + * down here because we want the user's section 1 to have been scanned first. + * The user has a chance to override it with an option. + */ +/* %if-c-only */ +#include +/* %endif */ +/* %if-c++-only */ +/* %endif */ +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* %if-c-only Reentrant structure and macros (non-C++). */ +/* %if-reentrant */ + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ + char yy_hold_char; + int yy_n_chars; + int yyleng_r; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + YYLTYPE * yylloc_r; + + }; /* end struct yyguts_t */ + +/* %if-c-only */ + +static int yy_init_globals (yyscan_t yyscanner ); + +/* %endif */ + +/* %if-reentrant */ + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + + # define yylloc yyg->yylloc_r + +int Ahuacatllex_init (yyscan_t* scanner); + +int Ahuacatllex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner); + +/* %endif */ + +/* %endif End reentrant structures and macros. */ + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int Ahuacatllex_destroy (yyscan_t yyscanner ); + +int Ahuacatlget_debug (yyscan_t yyscanner ); + +void Ahuacatlset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE Ahuacatlget_extra (yyscan_t yyscanner ); + +void Ahuacatlset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *Ahuacatlget_in (yyscan_t yyscanner ); + +void Ahuacatlset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *Ahuacatlget_out (yyscan_t yyscanner ); + +void Ahuacatlset_out (FILE * out_str ,yyscan_t yyscanner ); + +int Ahuacatlget_leng (yyscan_t yyscanner ); + +char *Ahuacatlget_text (yyscan_t yyscanner ); + +int Ahuacatlget_lineno (yyscan_t yyscanner ); + +void Ahuacatlset_lineno (int line_number ,yyscan_t yyscanner ); + +/* %if-bison-bridge */ + +YYSTYPE * Ahuacatlget_lval (yyscan_t yyscanner ); + +void Ahuacatlset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + + YYLTYPE *Ahuacatlget_lloc (yyscan_t yyscanner ); + + void Ahuacatlset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner ); + +/* %endif */ + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int Ahuacatlwrap (yyscan_t yyscanner ); +#else +extern int Ahuacatlwrap (yyscan_t yyscanner ); +#endif +#endif + +/* %not-for-header */ + +/* %ok-for-header */ + +/* %endif */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT +/* %if-c-only Standard (non-C++) definition */ +/* %not-for-header */ + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif +/* %ok-for-header */ + +/* %endif */ +#endif + +/* %if-c-only */ + +/* %endif */ + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* %if-c-only Standard (non-C++) definition */ +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( yytext, yyleng, 1, yyout ) +/* %endif */ +/* %if-c++-only C++ definition */ +/* %endif */ +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ +/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + int n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ +/* %if-c++-only C++ definition \ */\ +/* %endif */ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +/* %if-c-only */ +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +#endif + +/* %if-tables-serialization structures and prototypes */ +/* %not-for-header */ + +/* %ok-for-header */ + +/* %not-for-header */ + +/* %tables-yydmap generated elements */ +/* %endif */ +/* end tables serialization structures and prototypes */ + +/* %ok-for-header */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 +/* %if-c-only Standard (non-C++) definition */ + +extern int Ahuacatllex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); + +#define YY_DECL int Ahuacatllex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only C++ definition */ +/* %endif */ +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +/* %% [6.0] YY_RULE_SETUP definition goes here */ +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/* %not-for-header */ + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +/* %% [7.0] user's declarations go here */ + + /* --------------------------------------------------------------------------- + * language keywords + * --------------------------------------------------------------------------- */ + + yylval = yylval_param; + + yylloc = yylloc_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) +/* %if-c-only */ + yyin = stdin; +/* %endif */ +/* %if-c++-only */ +/* %endif */ + + if ( ! yyout ) +/* %if-c-only */ + yyout = stdout; +/* %endif */ +/* %if-c++-only */ +/* %endif */ + + if ( ! YY_CURRENT_BUFFER ) { + Ahuacatlensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + Ahuacatl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + Ahuacatl_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { +/* %% [8.0] yymore()-related code goes here */ + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + +/* %% [9.0] code to set up and find next match goes here */ + yy_current_state = yyg->yy_start; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 120 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_current_state != 119 ); + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + +yy_find_action: +/* %% [10.0] code to find the action number goes here */ + yy_act = yy_accept[yy_current_state]; + + YY_DO_BEFORE_ACTION; + +/* %% [11.0] code for yylineno update goes here */ + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + +/* %% [12.0] debug code goes here */ + if ( yy_flex_debug ) + { + if ( yy_act == 0 ) + fprintf( stderr, "--scanner backing up\n" ); + else if ( yy_act < 47 ) + fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n", + (long)yy_rule_linenum[yy_act], yytext ); + else if ( yy_act == 47 ) + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); + else if ( yy_act == 48 ) + fprintf( stderr, "--(end of buffer or a NUL)\n" ); + else + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + } + + switch ( yy_act ) + { /* beginning of action switch */ +/* %% [13.0] actions go here */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +{ + return T_FOR; +} + YY_BREAK +case 2: +YY_RULE_SETUP +{ + return T_LET; +} + YY_BREAK +case 3: +YY_RULE_SETUP +{ + return T_FILTER; +} + YY_BREAK +case 4: +YY_RULE_SETUP +{ + return T_RETURN; +} + YY_BREAK +case 5: +YY_RULE_SETUP +{ + return T_COLLECT; +} + YY_BREAK +case 6: +YY_RULE_SETUP +{ + return T_SORT; +} + YY_BREAK +case 7: +YY_RULE_SETUP +{ + return T_LIMIT; +} + YY_BREAK +case 8: +YY_RULE_SETUP +{ + return T_ASC; +} + YY_BREAK +case 9: +YY_RULE_SETUP +{ + return T_DESC; +} + YY_BREAK +case 10: +YY_RULE_SETUP +{ + return T_IN; +} + YY_BREAK +case 11: +YY_RULE_SETUP +{ + return T_INTO; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * predefined type literals + * --------------------------------------------------------------------------- */ +case 12: +YY_RULE_SETUP +{ + return T_NULL; +} + YY_BREAK +case 13: +YY_RULE_SETUP +{ + return T_TRUE; +} + YY_BREAK +case 14: +YY_RULE_SETUP +{ + return T_FALSE; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * operators + * --------------------------------------------------------------------------- */ +case 15: +YY_RULE_SETUP +{ + return T_EQ; +} + YY_BREAK +case 16: +YY_RULE_SETUP +{ + return T_NE; +} + YY_BREAK +case 17: +YY_RULE_SETUP +{ + return T_GE; +} + YY_BREAK +case 18: +YY_RULE_SETUP +{ + return T_GT; +} + YY_BREAK +case 19: +YY_RULE_SETUP +{ + return T_LE; +} + YY_BREAK +case 20: +YY_RULE_SETUP +{ + return T_LT; +} + YY_BREAK +case 21: +YY_RULE_SETUP +{ + return T_ASSIGN; +} + YY_BREAK +case 22: +YY_RULE_SETUP +{ + return T_NOT; +} + YY_BREAK +case 23: +YY_RULE_SETUP +{ + return T_AND; +} + YY_BREAK +case 24: +YY_RULE_SETUP +{ + return T_OR; +} + YY_BREAK +case 25: +YY_RULE_SETUP +{ + return T_PLUS; +} + YY_BREAK +case 26: +YY_RULE_SETUP +{ + return T_MINUS; +} + YY_BREAK +case 27: +YY_RULE_SETUP +{ + return T_TIMES; +} + YY_BREAK +case 28: +YY_RULE_SETUP +{ + return T_DIV; +} + YY_BREAK +case 29: +YY_RULE_SETUP +{ + return T_MOD; +} + YY_BREAK +case 30: +YY_RULE_SETUP +{ + return T_QUESTION; +} + YY_BREAK +case 31: +YY_RULE_SETUP +{ + return T_COLON; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * punctuation + * --------------------------------------------------------------------------- */ +case 32: +YY_RULE_SETUP +{ + return T_COMMA; +} + YY_BREAK +case 33: +YY_RULE_SETUP +{ + return T_OPEN; +} + YY_BREAK +case 34: +YY_RULE_SETUP +{ + return T_CLOSE; +} + YY_BREAK +case 35: +YY_RULE_SETUP +{ + return T_DOC_OPEN; +} + YY_BREAK +case 36: +YY_RULE_SETUP +{ + return T_DOC_CLOSE; +} + YY_BREAK +case 37: +YY_RULE_SETUP +{ + return T_LIST_OPEN; +} + YY_BREAK +case 38: +YY_RULE_SETUP +{ + return T_LIST_CLOSE; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * literals + * --------------------------------------------------------------------------- */ +case 39: +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext, strlen(yytext)); + return T_STRING; +} + YY_BREAK +case 40: +/* rule 40 can match eol */ +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext + 1, strlen(yytext) - 2); + return T_STRING; +} + YY_BREAK +case 41: +/* rule 41 can match eol */ +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext + 1, strlen(yytext) - 2); + return T_QUOTED_STRING; +} + YY_BREAK +case 42: +/* rule 42 can match eol */ +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext + 1, strlen(yytext) - 2); + return T_QUOTED_STRING; +} + YY_BREAK +case 43: +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext, strlen(yytext)); + return T_NUMBER; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * bind parameters + * --------------------------------------------------------------------------- */ +case 44: +YY_RULE_SETUP +{ + yylval->strval = TRI_RegisterStringAql(yyextra, yytext + 1, strlen(yytext) - 1); + return T_PARAMETER; +} + YY_BREAK +/* --------------------------------------------------------------------------- + * whitespace etc. + * --------------------------------------------------------------------------- */ +case 45: +/* rule 45 can match eol */ +YY_RULE_SETUP +{ + /* whitespace */; +} + YY_BREAK +case 46: +YY_RULE_SETUP +{ + return (int) yytext[0]; +} + YY_BREAK +case 47: +YY_RULE_SETUP +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * Ahuacatllex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { +/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */ + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( Ahuacatlwrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of Ahuacatllex */ +/* %ok-for-header */ + +/* %if-c++-only */ +/* %not-for-header */ + +/* %ok-for-header */ + +/* %endif */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +/* %if-c-only */ +static int yy_get_next_buffer (yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) (yyg->yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + Ahuacatlrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + yyg->yy_n_chars, (int) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + Ahuacatlrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) Ahuacatlrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +/* %if-c-only */ +/* %not-for-header */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +/* %% [15.0] code to get the start state into yy_current_state goes here */ + yy_current_state = yyg->yy_start; + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { +/* %% [16.0] code to find the next state goes here */ + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 120 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ +/* %if-c-only */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ +/* %% [17.0] code to find the next state, and perhaps do backing up, goes here */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 120 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 119); + + return yy_is_jam ? 0 : yy_current_state; +} + +/* %if-c-only */ + +/* %endif */ + +/* %if-c-only */ +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + Ahuacatlrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( Ahuacatlwrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + +/* %% [19.0] update BOL and yylineno */ + if ( c == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + + return c; +} +/* %if-c-only */ +#endif /* ifndef YY_NO_INPUT */ +/* %endif */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ +/* %if-c-only */ + void Ahuacatlrestart (FILE * input_file , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + Ahuacatlensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + Ahuacatl_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + Ahuacatl_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + Ahuacatl_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ +/* %if-c-only */ + void Ahuacatl_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * Ahuacatlpop_buffer_state(); + * Ahuacatlpush_buffer_state(new_buffer); + */ + Ahuacatlensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + Ahuacatl_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (Ahuacatlwrap()) processing, but the only time this flag + * is looked at is after Ahuacatlwrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/* %if-c-only */ +static void Ahuacatl_load_buffer_state (yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ +/* %if-c-only */ + YY_BUFFER_STATE Ahuacatl_create_buffer (FILE * file, int size , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) Ahuacatlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatl_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) Ahuacatlalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatl_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + Ahuacatl_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with Ahuacatl_create_buffer() + * @param yyscanner The scanner object. + */ +/* %if-c-only */ + void Ahuacatl_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + Ahuacatlfree((void *) b->yy_ch_buf ,yyscanner ); + + Ahuacatlfree((void *) b ,yyscanner ); +} + +/* %if-c-only */ + +#ifndef __cplusplus +#ifndef _WIN32 +extern int isatty (int ); +#endif +#endif /* __cplusplus */ + +/* %endif */ + +/* %if-c++-only */ +/* %endif */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a Ahuacatlrestart() or at EOF. + */ +/* %if-c-only */ + static void Ahuacatl_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + Ahuacatl_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then Ahuacatl_init_buffer was _probably_ + * called from Ahuacatlrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + +/* %if-c-only */ + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + +/* %endif */ +/* %if-c++-only */ +/* %endif */ + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ +/* %if-c-only */ + void Ahuacatl_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + Ahuacatl_load_buffer_state(yyscanner ); +} + +/* %if-c-or-c++ */ +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +/* %if-c-only */ +void Ahuacatlpush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + Ahuacatlensure_buffer_stack(yyscanner); + + /* This block is copied from Ahuacatl_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from Ahuacatl_switch_to_buffer. */ + Ahuacatl_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} +/* %endif */ + +/* %if-c-or-c++ */ +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +/* %if-c-only */ +void Ahuacatlpop_buffer_state (yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + Ahuacatl_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + Ahuacatl_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} +/* %endif */ + +/* %if-c-or-c++ */ +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +/* %if-c-only */ +static void Ahuacatlensure_buffer_stack (yyscan_t yyscanner) +/* %endif */ +/* %if-c++-only */ +/* %endif */ +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)Ahuacatlalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatlensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)Ahuacatlrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatlensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} +/* %endif */ + +/* %if-c-only */ +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE Ahuacatl_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) Ahuacatlalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatl_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + Ahuacatl_switch_to_buffer(b ,yyscanner ); + + return b; +} +/* %endif */ + +/* %if-c-only */ +/** Setup the input buffer state to scan a string. The next call to Ahuacatllex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * Ahuacatl_scan_bytes() instead. + */ +YY_BUFFER_STATE Ahuacatl_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return Ahuacatl_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} +/* %endif */ + +/* %if-c-only */ +/** Setup the input buffer state to scan the given bytes. The next call to Ahuacatllex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE Ahuacatl_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) Ahuacatlalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in Ahuacatl_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = Ahuacatl_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in Ahuacatl_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} +/* %endif */ + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +/* %if-c-only */ +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} +/* %endif */ +/* %if-c++-only */ +/* %endif */ + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/* %if-c-only */ +/* %if-reentrant */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE Ahuacatlget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/* %endif */ + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int Ahuacatlget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int Ahuacatlget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *Ahuacatlget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *Ahuacatlget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int Ahuacatlget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *Ahuacatlget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/* %if-reentrant */ + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void Ahuacatlset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/* %endif */ + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void Ahuacatlset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* lineno is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "Ahuacatlset_lineno called with no buffer" , yyscanner); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void Ahuacatlset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* column is only valid if an input buffer exists. */ + if (! YY_CURRENT_BUFFER ) + yy_fatal_error( "Ahuacatlset_column called with no buffer" , yyscanner); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see Ahuacatl_switch_to_buffer + */ +void Ahuacatlset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void Ahuacatlset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int Ahuacatlget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void Ahuacatlset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* %endif */ + +/* %if-reentrant */ +/* Accessor methods for yylval and yylloc */ + +/* %if-bison-bridge */ + +YYSTYPE * Ahuacatlget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void Ahuacatlset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +YYLTYPE *Ahuacatlget_lloc (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylloc; +} + +void Ahuacatlset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylloc = yylloc_param; +} + +/* %endif */ + +/* User-visible API */ + +/* Ahuacatllex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int Ahuacatllex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) Ahuacatlalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* Ahuacatllex_init_extra has the same functionality as Ahuacatllex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to Ahuacatlalloc in + * the yyextra field. + */ + +int Ahuacatllex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + Ahuacatlset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) Ahuacatlalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + Ahuacatlset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* %endif if-c-only */ + +/* %if-c-only */ +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from Ahuacatllex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * Ahuacatllex_init() + */ + return 0; +} +/* %endif */ + +/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */ +/* Ahuacatllex_destroy is for both reentrant and non-reentrant scanners. */ +int Ahuacatllex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + Ahuacatl_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + Ahuacatlpop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + Ahuacatlfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + Ahuacatlfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * Ahuacatllex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + +/* %if-reentrant */ + /* Destroy the main struct (reentrant only). */ + Ahuacatlfree ( yyscanner , yyscanner ); + yyscanner = NULL; +/* %endif */ + return 0; +} +/* %endif */ + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *Ahuacatlalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *Ahuacatlrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void Ahuacatlfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see Ahuacatlrealloc() for (char *) cast */ +} + +/* %if-tables-serialization definitions */ +/* %define-yytables The name for this specific scanner's tables. */ +#define YYTABLES_NAME "yytables" +/* %endif */ + +/* %ok-for-header */ + diff --git a/Ahuacatl/tokens.l b/Ahuacatl/ahuacatl-tokens.l similarity index 98% rename from Ahuacatl/tokens.l rename to Ahuacatl/ahuacatl-tokens.l index 15d86aa858..88a5a53fb0 100644 --- a/Ahuacatl/tokens.l +++ b/Ahuacatl/ahuacatl-tokens.l @@ -12,8 +12,8 @@ #include #include "Ahuacatl/ast-node.h" -#include "Ahuacatl/parser.h" -#include "Ahuacatl/grammar.h" +#include "Ahuacatl/ahuacatl-parser.h" +#include "Ahuacatl/ahuacatl-grammar.h" #define YY_EXTRA_TYPE TRI_aql_parse_context_t* diff --git a/Ahuacatl/ast-node.h b/Ahuacatl/ast-node.h index fbfe8772f6..758e31228e 100644 --- a/Ahuacatl/ast-node.h +++ b/Ahuacatl/ast-node.h @@ -34,7 +34,7 @@ #include #include -#include "Ahuacatl/parser.h" +#include "Ahuacatl/ahuacatl-parser.h" #ifdef __cplusplus extern "C" { diff --git a/Ahuacatl/grammar.c b/Ahuacatl/grammar.c index a30e34e1c9..918b2e6ae9 100644 --- a/Ahuacatl/grammar.c +++ b/Ahuacatl/grammar.c @@ -216,7 +216,7 @@ typedef struct YYLTYPE //////////////////////////////////////////////////////////////////////////////// -/// @brief forward for lexer function defined in tokens.l +/// @brief forward for lexer function defined in ahuacatl-tokens.l //////////////////////////////////////////////////////////////////////////////// int Ahuacatllex (YYSTYPE*, YYLTYPE*, void*); diff --git a/Makefile.files b/Makefile.files index bc49e2d791..1623696589 100644 --- a/Makefile.files +++ b/Makefile.files @@ -149,12 +149,12 @@ avocado_SOURCES = \ Ahuacatl/ahuacatl-bind-parameter.c \ Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ + Ahuacatl/ahuacatl-grammar.c \ + Ahuacatl/ahuacatl-parser.c \ + Ahuacatl/ahuacatl-tokens.c \ Ahuacatl/ast-codegen-js.c \ Ahuacatl/ast-dump.c \ Ahuacatl/ast-node.c \ - Ahuacatl/grammar.c \ - Ahuacatl/parser.c \ - Ahuacatl/tokens.c \ QL/ast-query.c \ QL/formatter.c \ QL/optimize.c \ @@ -303,7 +303,7 @@ BUILT_SOURCES += $(FLEXXX_FILES) BISON_FILES = \ QL/parser.c \ - Ahuacatl/grammar.c + Ahuacatl/ahuacatl-grammar.c BUILT_SOURCES += $(BISON_FILES) diff --git a/Makefile.in b/Makefile.in index 84f574968d..fb01211e1c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -280,11 +280,13 @@ am_avocado_OBJECTS = Admin/ApplicationAdminServer.$(OBJEXT) \ Ahuacatl/ahuacatl-bind-parameter.$(OBJEXT) \ Ahuacatl/ahuacatl-error.$(OBJEXT) \ Ahuacatl/ahuacatl-functions.$(OBJEXT) \ + Ahuacatl/ahuacatl-grammar.$(OBJEXT) \ + Ahuacatl/ahuacatl-parser.$(OBJEXT) \ + Ahuacatl/ahuacatl-tokens.$(OBJEXT) \ Ahuacatl/ast-codegen-js.$(OBJEXT) Ahuacatl/ast-dump.$(OBJEXT) \ - Ahuacatl/ast-node.$(OBJEXT) Ahuacatl/grammar.$(OBJEXT) \ - Ahuacatl/parser.$(OBJEXT) Ahuacatl/tokens.$(OBJEXT) \ - QL/ast-query.$(OBJEXT) QL/formatter.$(OBJEXT) \ - QL/optimize.$(OBJEXT) QL/parser.$(OBJEXT) QL/tokens.$(OBJEXT) \ + Ahuacatl/ast-node.$(OBJEXT) QL/ast-query.$(OBJEXT) \ + QL/formatter.$(OBJEXT) QL/optimize.$(OBJEXT) \ + QL/parser.$(OBJEXT) QL/tokens.$(OBJEXT) \ RestHandler/RestActionHandler.$(OBJEXT) \ RestHandler/RestDocumentHandler.$(OBJEXT) \ RestHandler/RestEdgeHandler.$(OBJEXT) \ @@ -756,12 +758,12 @@ avocado_SOURCES = \ Ahuacatl/ahuacatl-bind-parameter.c \ Ahuacatl/ahuacatl-error.c \ Ahuacatl/ahuacatl-functions.c \ + Ahuacatl/ahuacatl-grammar.c \ + Ahuacatl/ahuacatl-parser.c \ + Ahuacatl/ahuacatl-tokens.c \ Ahuacatl/ast-codegen-js.c \ Ahuacatl/ast-dump.c \ Ahuacatl/ast-node.c \ - Ahuacatl/grammar.c \ - Ahuacatl/parser.c \ - Ahuacatl/tokens.c \ QL/ast-query.c \ QL/formatter.c \ QL/optimize.c \ @@ -894,7 +896,7 @@ FLEXXX_FILES = \ ################################################################################ BISON_FILES = \ QL/parser.c \ - Ahuacatl/grammar.c + Ahuacatl/ahuacatl-grammar.c ################################################################################ @@ -1658,18 +1660,18 @@ Ahuacatl/ahuacatl-error.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ahuacatl-functions.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) +Ahuacatl/ahuacatl-grammar.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ + Ahuacatl/$(DEPDIR)/$(am__dirstamp) +Ahuacatl/ahuacatl-parser.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ + Ahuacatl/$(DEPDIR)/$(am__dirstamp) +Ahuacatl/ahuacatl-tokens.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ + Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ast-codegen-js.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ast-dump.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) Ahuacatl/ast-node.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ Ahuacatl/$(DEPDIR)/$(am__dirstamp) -Ahuacatl/grammar.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ - Ahuacatl/$(DEPDIR)/$(am__dirstamp) -Ahuacatl/parser.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ - Ahuacatl/$(DEPDIR)/$(am__dirstamp) -Ahuacatl/tokens.$(OBJEXT): Ahuacatl/$(am__dirstamp) \ - Ahuacatl/$(DEPDIR)/$(am__dirstamp) QL/$(am__dirstamp): @$(MKDIR_P) QL @: > QL/$(am__dirstamp) @@ -1911,12 +1913,12 @@ mostlyclean-compile: -rm -f Ahuacatl/ahuacatl-bind-parameter.$(OBJEXT) -rm -f Ahuacatl/ahuacatl-error.$(OBJEXT) -rm -f Ahuacatl/ahuacatl-functions.$(OBJEXT) + -rm -f Ahuacatl/ahuacatl-grammar.$(OBJEXT) + -rm -f Ahuacatl/ahuacatl-parser.$(OBJEXT) + -rm -f Ahuacatl/ahuacatl-tokens.$(OBJEXT) -rm -f Ahuacatl/ast-codegen-js.$(OBJEXT) -rm -f Ahuacatl/ast-dump.$(OBJEXT) -rm -f Ahuacatl/ast-node.$(OBJEXT) - -rm -f Ahuacatl/grammar.$(OBJEXT) - -rm -f Ahuacatl/parser.$(OBJEXT) - -rm -f Ahuacatl/tokens.$(OBJEXT) -rm -f ApplicationServer/ApplicationServer.$(OBJEXT) -rm -f ApplicationServer/ApplicationServerImpl.$(OBJEXT) -rm -f ApplicationServer/ApplicationServerSchedulerImpl.$(OBJEXT) @@ -2139,12 +2141,12 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-bind-parameter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-functions.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-grammar.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-parser.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ahuacatl-tokens.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-codegen-js.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-dump.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/ast-node.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/grammar.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/parser.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@Ahuacatl/$(DEPDIR)/tokens.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ApplicationServer/$(DEPDIR)/ApplicationServer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ApplicationServer/$(DEPDIR)/ApplicationServerImpl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@ApplicationServer/$(DEPDIR)/ApplicationServerSchedulerImpl.Po@am__quote@ diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index 1f30ae1241..95ec9924ff 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -46,7 +46,7 @@ #include "SkipLists/sl-operator.h" #include "Ahuacatl/ast-node.h" #include "Ahuacatl/ast-codegen-js.h" -#include "Ahuacatl/parser.h" +#include "Ahuacatl/ahuacatl-parser.h" using namespace std; using namespace triagens::basics; From e074ed1e2a3ea973ab27a9e94c60e4e5ef7be2e9 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 17:32:20 +0200 Subject: [PATCH 10/13] free bind parameters memory --- Ahuacatl/ahuacatl-bind-parameter.c | 28 ++++++++++++++++++++++++++++ Ahuacatl/ahuacatl-bind-parameter.h | 6 ++++++ Ahuacatl/ahuacatl-parser.c | 1 + 3 files changed, 35 insertions(+) diff --git a/Ahuacatl/ahuacatl-bind-parameter.c b/Ahuacatl/ahuacatl-bind-parameter.c index a284004d82..06703fa681 100644 --- a/Ahuacatl/ahuacatl-bind-parameter.c +++ b/Ahuacatl/ahuacatl-bind-parameter.c @@ -100,6 +100,34 @@ bool TRI_EqualBindParameterAql (TRI_associative_pointer_t* array, return TRI_EqualString(key, parameter->_name); } +//////////////////////////////////////////////////////////////////////////////// +/// @brief free bind parameters +//////////////////////////////////////////////////////////////////////////////// + +void TRI_FreeBindParametersAql (TRI_aql_parse_context_t* const context) { + size_t i; + size_t n; + + // iterate thru all parameters allocated + n = context->_parameterValues._nrAlloc; + for (i = 0; i < n; ++i) { + TRI_aql_bind_parameter_t* parameter; + + parameter = (TRI_aql_bind_parameter_t*) context->_parameterValues._table[i]; + + if (!parameter) { + continue; + } + + assert(parameter->_name); + assert(parameter->_value); + + TRI_FreeString(parameter->_name); + TRI_FreeJson(parameter->_value); + TRI_Free(parameter); + } +} + //////////////////////////////////////////////////////////////////////////////// /// @brief add bind parameters //////////////////////////////////////////////////////////////////////////////// diff --git a/Ahuacatl/ahuacatl-bind-parameter.h b/Ahuacatl/ahuacatl-bind-parameter.h index 4f6349c0a0..d918b81500 100644 --- a/Ahuacatl/ahuacatl-bind-parameter.h +++ b/Ahuacatl/ahuacatl-bind-parameter.h @@ -87,6 +87,12 @@ bool TRI_EqualBindParameterAql (TRI_associative_pointer_t*, void const*, void const*); +//////////////////////////////////////////////////////////////////////////////// +/// @brief free bind parameters +//////////////////////////////////////////////////////////////////////////////// + +void TRI_FreeBindParametersAql (TRI_aql_parse_context_t* const); + //////////////////////////////////////////////////////////////////////////////// /// @brief add bind parameters //////////////////////////////////////////////////////////////////////////////// diff --git a/Ahuacatl/ahuacatl-parser.c b/Ahuacatl/ahuacatl-parser.c index 7030b1acfd..565eb0556d 100644 --- a/Ahuacatl/ahuacatl-parser.c +++ b/Ahuacatl/ahuacatl-parser.c @@ -204,6 +204,7 @@ void TRI_FreeParseContextAql (TRI_aql_parse_context_t* const context) { TRI_DestroyAssociativePointer(&context->_parameterNames); // free parameter values + TRI_FreeBindParametersAql(context); TRI_DestroyAssociativePointer(&context->_parameterValues); // free query string From d9f6b2a35b4927a67006d02b2f439a2c1cf4bb0e Mon Sep 17 00:00:00 2001 From: a-brandt Date: Tue, 24 Apr 2012 17:33:00 +0200 Subject: [PATCH 11/13] Added missing error messages --- V8Client/ImportHelper.cpp | 27 ++++++++++++++++++++++----- V8Client/ImportHelper.h | 1 + V8Client/avocimp.cpp | 1 - 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/V8Client/ImportHelper.cpp b/V8Client/ImportHelper.cpp index 751ee332a9..f787959402 100644 --- a/V8Client/ImportHelper.cpp +++ b/V8Client/ImportHelper.cpp @@ -71,6 +71,7 @@ namespace triagens { _separator = ','; regcomp(&_doubleRegex, "^[-+]?([0-9]+\\.?[0-9]*|\\.[0-9]+)([eE][-+]?[0-8]+)?$", REG_ICASE | REG_EXTENDED); regcomp(&_intRegex, "^[-+]?([0-9]+)$", REG_ICASE | REG_EXTENDED); + _hasError = false; } ImportHelper::~ImportHelper () { @@ -89,6 +90,7 @@ namespace triagens { _outputBuffer.clear(); _lineBuffer.clear(); _errorMessage = ""; + _hasError = false; // read and convert int fd; @@ -118,7 +120,7 @@ namespace triagens { char buffer[10240]; - while (true) { + while (!_hasError) { v8::HandleScope scope; ssize_t n = read(fd, buffer, sizeof (buffer)); @@ -145,7 +147,8 @@ namespace triagens { close(fd); } - return true; + _outputBuffer.clear(); + return !_hasError; } bool ImportHelper::importJson (const string& collectionName, const string& fileName) { @@ -156,6 +159,7 @@ namespace triagens { _numberError = 0; _outputBuffer.clear(); _errorMessage = ""; + _hasError = false; // read and convert int fd; @@ -174,7 +178,7 @@ namespace triagens { char buffer[10240]; - while (true) { + while (!_hasError) { ssize_t n = read(fd, buffer, sizeof(buffer)); if (n < 0) { @@ -212,7 +216,8 @@ namespace triagens { close(fd); } - return true; + _outputBuffer.clear(); + return !_hasError; } @@ -351,6 +356,10 @@ namespace triagens { } void ImportHelper::sendCsvBuffer () { + if (_hasError) { + return; + } + map headerFields; SimpleHttpResult* result = _client->request(SimpleHttpClient::POST, "/_api/import?collection=" + StringUtils::urlEncode(_collectionName), _outputBuffer.c_str(), _outputBuffer.length(), headerFields); @@ -360,6 +369,10 @@ namespace triagens { } void ImportHelper::sendJsonBuffer (char const* str, size_t len) { + if (_hasError) { + return; + } + map headerFields; SimpleHttpResult* result = _client->request(SimpleHttpClient::POST, "/_api/import?type=documents&collection=" + StringUtils::urlEncode(_collectionName), str, len, headerFields); @@ -377,7 +390,11 @@ namespace triagens { VariantBoolean* vb = va->lookupBoolean("error"); if (vb && vb->getValue()) { // is error - + _hasError = true; + VariantString* vs = va->lookupString("errorMessage"); + if (vs) { + _errorMessage = vs->getValue(); + } } VariantInt64* vi = va->lookupInt64("created"); diff --git a/V8Client/ImportHelper.h b/V8Client/ImportHelper.h index 46ef44a4b3..c904adbeb3 100644 --- a/V8Client/ImportHelper.h +++ b/V8Client/ImportHelper.h @@ -200,6 +200,7 @@ namespace triagens { regex_t _doubleRegex; regex_t _intRegex; + bool _hasError; string _errorMessage; }; } diff --git a/V8Client/avocimp.cpp b/V8Client/avocimp.cpp index cd4cc0f6e3..b1a786cd03 100644 --- a/V8Client/avocimp.cpp +++ b/V8Client/avocimp.cpp @@ -41,7 +41,6 @@ #include "Logger/Logger.h" #include "SimpleHttpClient/SimpleHttpClient.h" #include "SimpleHttpClient/SimpleHttpResult.h" - #include "ImportHelper.h" #include "V8ClientConnection.h" From 1803a18524f56904e96583e370a12afdb3546100 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 24 Apr 2012 17:40:09 +0200 Subject: [PATCH 12/13] changed variable name validation --- Ahuacatl/ahuacatl-parser.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Ahuacatl/ahuacatl-parser.c b/Ahuacatl/ahuacatl-parser.c index 565eb0556d..67278d77f8 100644 --- a/Ahuacatl/ahuacatl-parser.c +++ b/Ahuacatl/ahuacatl-parser.c @@ -648,14 +648,19 @@ bool TRI_VariableExistsAql (TRI_aql_parse_context_t* const context, //////////////////////////////////////////////////////////////////////////////// bool TRI_IsValidVariableNameAql (const char* const name) { - TRI_col_parameter_t parameter; + assert(name); - parameter._isSystem = true; - - if (TRI_IsAllowedCollectionName(¶meter, name) != 0) { + if (strlen(name) == 0) { + // name must be at least one char long return false; } + if (*name == '_') { + // name must not start with an underscore + return false; + } + + // everything else is allowed return true; } From 3c3fc7ca540e1a4f117e9b05b916e18ed26ae32d Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 25 Apr 2012 09:06:35 +0200 Subject: [PATCH 13/13] fixed compile warning --- .gitignore | 2 ++ V8/v8-vocbase.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 0378d99323..0b7414b5f0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,8 @@ build.h build.info commit.sh config/config.h +config/config.guess +config/config.sub config.h config.log config/revision.sh diff --git a/V8/v8-vocbase.cpp b/V8/v8-vocbase.cpp index 95ec9924ff..6ace80f4ec 100644 --- a/V8/v8-vocbase.cpp +++ b/V8/v8-vocbase.cpp @@ -2279,6 +2279,8 @@ static v8::Handle JS_RunAhuacatl (v8::Arguments const& argv) { } string queryString = TRI_ObjectToString(queryArg); + /* currently unused, causes compile warnings + // return number of total records in cursor? bool doCount = false; if (argv.Length() > 0) { @@ -2293,6 +2295,8 @@ static v8::Handle JS_RunAhuacatl (v8::Arguments const& argv) { max = (uint32_t) maxValue; } } + + */ v8::Handle result;