Skip to content
Permalink
Browse files

[expressions] Variable length arguemnt functions accept 0 params

  • Loading branch information
m-kuhn committed Oct 27, 2016
1 parent 631db7b commit f52dfba21ed4b21a224b2a39013bf6fae101a15d
Showing with 5 additions and 3 deletions.
  1. +3 −1 src/core/qgsexpressionparser.yy
  2. +2 −2 tests/src/core/testqgsexpression.cpp
@@ -223,7 +223,9 @@ expression:
exp_error(parser_ctx, "Function is not known");
YYERROR;
}
if ( QgsExpression::Functions()[fnIndex]->params() != 0 )
// 0 parameters is expected, -1 parameters means leave it to the
// implementation
if ( QgsExpression::Functions()[fnIndex]->params() > 0 )
{
exp_error(parser_ctx, QString( "%1 function is called with wrong number of arguments" ).arg( QgsExpression::Functions()[fnIndex]->name() ).toLocal8Bit().constData() );
YYERROR;
@@ -2177,7 +2177,7 @@ class TestQgsExpression: public QObject
QgsExpressionContext context = QgsExpressionContextUtils::createFeatureBasedContext( f, QgsFields() );

QVariantList builderExpected;
QCOMPARE( QgsExpression( "array()" ).evaluate( &context ), QVariant( ) );
QCOMPARE( QgsExpression( "array()" ).evaluate( &context ), QVariant( builderExpected ) );
builderExpected << "hello";
QCOMPARE( QgsExpression( "array('hello')" ).evaluate( &context ), QVariant( builderExpected ) );
builderExpected << "world";
@@ -2303,7 +2303,7 @@ class TestQgsExpression: public QObject
QgsExpressionContext context = QgsExpressionContextUtils::createFeatureBasedContext( f, QgsFields() );

QVariantMap builderExpected;
QCOMPARE( QgsExpression( "map()" ).evaluate( &context ), QVariant( ) );
QCOMPARE( QgsExpression( "map()" ).evaluate( &context ), QVariant( builderExpected ) );
builderExpected[QStringLiteral( "1" )] = "hello";
QCOMPARE( QgsExpression( "map('1', 'hello')" ).evaluate( &context ), QVariant( builderExpected ) );
builderExpected[QStringLiteral( "2" )] = "world";

0 comments on commit f52dfba

Please sign in to comment.
You can’t perform that action at this time.