1
0
Fork 0

fixes for Ahuacatl

This commit is contained in:
Jan Steemann 2012-04-24 11:14:12 +02:00
parent f4846248a7
commit a6303223d6
7 changed files with 108 additions and 6 deletions

1
.gitignore vendored
View File

@ -86,6 +86,7 @@ stamp-h*
.svn
*.swp
tags
Ahuacatl/grammar.output
UnitTests/HttpInterface/logs
UnitTests/Jutland/CsvReaderTest.cpp
UnitTests/Jutland/Makefile.am

View File

@ -1047,14 +1047,14 @@ static void GenerateCode (TRI_aql_codegen_t* const generator,
AppendCode(generator, ")");
break;
case AQL_NODE_OPERATOR_BINARY_DIV:
AppendCode(generator, "AHUACATL_ARITHMETIC_DIV(");
AppendCode(generator, "AHUACATL_ARITHMETIC_DIVIDE(");
GenerateCode(generator, ((TRI_aql_node_operator_binary_t*) node)->_lhs);
AppendCode(generator, ", ");
GenerateCode(generator, ((TRI_aql_node_operator_binary_t*) node)->_rhs);
AppendCode(generator, ")");
break;
case AQL_NODE_OPERATOR_BINARY_MOD:
AppendCode(generator, "AHUACATL_ARITHMETIC_MOD(");
AppendCode(generator, "AHUACATL_ARITHMETIC_MODULUS(");
GenerateCode(generator, ((TRI_aql_node_operator_binary_t*) node)->_lhs);
AppendCode(generator, ", ");
GenerateCode(generator, ((TRI_aql_node_operator_binary_t*) node)->_rhs);

View File

@ -7,6 +7,9 @@
QL/%.c: @srcdir@/QL/%.y
@top_srcdir@/config/bison-c.sh $(BISON) $@ $<
Ahuacatl/%.c: @srcdir@/Ahuacatl/%.y
@top_srcdir@/config/bison-c.sh $(BISON) $@ $<
################################################################################
## BISON++
################################################################################

View File

@ -10,6 +10,9 @@ JsonParser/%.c: @srcdir@/JsonParser/%.l
QL/%.c: @srcdir@/QL/%.l
@top_srcdir@/config/flex-c.sh $(LEX) $@ $<
Ahuacatl/%.c: @srcdir@/Ahuacatl/%.l
@top_srcdir@/config/flex-c.sh $(LEX) $@ $<
################################################################################
## FLEX++
################################################################################

View File

@ -3077,6 +3077,9 @@ unittests-http-server:
@ENABLE_FLEX_TRUE@QL/%.c: @srcdir@/QL/%.l
@ENABLE_FLEX_TRUE@ @top_srcdir@/config/flex-c.sh $(LEX) $@ $<
@ENABLE_FLEX_TRUE@Ahuacatl/%.c: @srcdir@/Ahuacatl/%.l
@ENABLE_FLEX_TRUE@ @top_srcdir@/config/flex-c.sh $(LEX) $@ $<
################################################################################
################################################################################
@ -3089,6 +3092,9 @@ unittests-http-server:
@ENABLE_BISON_TRUE@QL/%.c: @srcdir@/QL/%.y
@ENABLE_BISON_TRUE@ @top_srcdir@/config/bison-c.sh $(BISON) $@ $<
@ENABLE_BISON_TRUE@Ahuacatl/%.c: @srcdir@/Ahuacatl/%.y
@ENABLE_BISON_TRUE@ @top_srcdir@/config/bison-c.sh $(BISON) $@ $<
################################################################################
################################################################################

View File

@ -13,8 +13,8 @@ unittests: unittests-verbose unittests-brief
unittests-brief: \
unittests-boost \
unittests-shell-server \
unittests-shell-server-ahuacatl \
unittests-shell-server \
unittests-http-server \
unittests-shell-client \
unittests-http-server \
@ -153,7 +153,9 @@ unittests-shell-server:
## SHELL SERVER TESTS (AHUACATL)
################################################################################
SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-queries.js
SHELL_SERVER_AHUACATL = @srcdir@/js/server/tests/ahuacatl-queries-collection.js \
@srcdir@/js/server/tests/ahuacatl-queries-noncollection.js
.PHONY: unittests-shell-server-ahuacatl

View File

@ -105,10 +105,97 @@ function ahuacatlQueryNonCollectionTestSuite () {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return a single value as part of a document
/// @brief return a single value from a list
////////////////////////////////////////////////////////////////////////////////
testFilterSingleReturnDoc : function () {
testListValueQuery : function () {
var expected = [ 2010, 2011, 2012 ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] return year", true);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return two values from a list
////////////////////////////////////////////////////////////////////////////////
testListDocumentQuery : function () {
var expected = [ { "days" : 365, "year" : 2010 }, { "days" : 365, "year" : 2011 }, { "days" : 366, "year" : 2012 } ];
var actual = getQueryResults("FOR year IN [ { \"year\" : 2010, \"days\" : 365 } , { \"year\" : 2011, \"days\" : 365 }, { \"year\" : 2012, \"days\" : 366 } ] return year", false);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return a single value from a sorted list
////////////////////////////////////////////////////////////////////////////////
testListValueQuerySort : function () {
var expected = [ 2015, 2014, 2013, 2012, 2011, 2010 ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012, 2013, 2014, 2015 ] SORT year DESC return year", true);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return a single value from a sorted limited list
////////////////////////////////////////////////////////////////////////////////
testListValueQuerySortLimit : function () {
var expected = [ 2013, 2012, 2011 ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012, 2013, 2014, 2015 ] SORT year DESC LIMIT 2,3 return year", true);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return a calculated from a list
////////////////////////////////////////////////////////////////////////////////
testListCalculated : function () {
var expected = [ { "anno" : 2010, "isLeapYear" : false }, { "anno" : 2011, "isLeapYear" : false }, { "anno" : 2012, "isLeapYear" : true }, { "anno" : 2013, "isLeapYear" : false }, { "anno" : 2014, "isLeapYear" : false } ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012, 2013, 2014 ] return { \"anno\" : year, \"isLeapYear\" : (year%4==0 && year%100!=0 || year%400==1) }", false);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return values from nested for loops
////////////////////////////////////////////////////////////////////////////////
testNestedFor1 : function () {
var expected = [ { "q" : 1, "y": 2010 }, { "q" : 1, "y": 2011 }, { "q" : 1, "y": 2012 }, { "q" : 2, "y": 2010 }, { "q" : 2, "y": 2011 }, { "q" : 2, "y": 2012 }, { "q" : 3, "y": 2010 }, { "q" : 3, "y": 2011 }, { "q" : 3, "y": 2012 }, { "q" : 4, "y": 2010 }, { "q" : 4, "y": 2011 }, { "q" : 4, "y": 2012 } ];
var actual = getQueryResults("FOR quarter IN [ 1, 2, 3, 4 ] FOR year IN [ 2010, 2011, 2012 ] return { \"q\" : quarter, \"y\" : year }", false);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return values from nested for loops
////////////////////////////////////////////////////////////////////////////////
testNestedFor2 : function () {
var expected = [ { "q" : 1, "y": 2010 }, { "q" : 2, "y": 2010 }, { "q" : 3, "y": 2010 }, { "q" : 4, "y": 2010 }, { "q" : 1, "y": 2011 }, { "q" : 2, "y": 2011 }, { "q" : 3, "y": 2011 }, { "q" : 4, "y": 2011 }, { "q" : 1, "y": 2012 }, { "q" : 2, "y": 2012 }, { "q" : 3, "y": 2012 }, { "q" : 4, "y": 2012 } ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] for quarter IN [ 1, 2, 3, 4 ] return { \"q\" : quarter, \"y\" : year }", false);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return values with let
////////////////////////////////////////////////////////////////////////////////
testNestedLet1 : function () {
var expected = [ 2010, 2011, 2012 ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] let quarters = ((for quarter IN [ 1, 2, 3, 4 ] return quarter)) RETURN year", true);
assertEqual(expected, actual);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief return values from let
////////////////////////////////////////////////////////////////////////////////
testNestedLet2 : function () {
var expected = [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ] ];
var actual = getQueryResults("FOR year IN [ 2010, 2011, 2012 ] let quarters = ((for quarter IN [ 1, 2, 3, 4 ] return quarter)) RETURN quarters", true);
assertEqual(expected, actual);
},
};