mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 04:29:20 +02:00
sql parser: fix A*B, A/B and add tests
git-svn-id: trunk@46437 -
This commit is contained in:
parent
5bac4c25e0
commit
f89650c470
@ -2539,6 +2539,7 @@ begin
|
|||||||
Right:=ParseExprLevel5(AParent,EO);
|
Right:=ParseExprLevel5(AParent,EO);
|
||||||
B:=TSQLBinaryExpression(CreateElement(TSQLBinaryExpression,AParent));
|
B:=TSQLBinaryExpression(CreateElement(TSQLBinaryExpression,AParent));
|
||||||
B.Left:=Result;
|
B.Left:=Result;
|
||||||
|
Result:=B;
|
||||||
B.Right:=Right;
|
B.Right:=Right;
|
||||||
Case tt of
|
Case tt of
|
||||||
tsqlMul : B.Operation:=boMultiply;
|
tsqlMul : B.Operation:=boMultiply;
|
||||||
|
@ -231,6 +231,10 @@ type
|
|||||||
procedure TestOr;
|
procedure TestOr;
|
||||||
procedure TestNotOr;
|
procedure TestNotOr;
|
||||||
procedure TestCase;
|
procedure TestCase;
|
||||||
|
procedure TestAdd;
|
||||||
|
procedure TestSubtract;
|
||||||
|
procedure TestMultiply;
|
||||||
|
procedure TestDivide;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TTestDomainParser }
|
{ TTestDomainParser }
|
||||||
@ -2123,6 +2127,19 @@ begin
|
|||||||
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestCheckParser.TestDivide;
|
||||||
|
|
||||||
|
Var
|
||||||
|
B : TSQLBinaryExpression;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TSQLBinaryExpression(TestCheck('VALUE / 1',TSQLBinaryExpression));
|
||||||
|
AssertEquals('Correct operator', boDivide, B.Operation);
|
||||||
|
AssertLiteralExpr('Left is value',B.Left,TSQLValueLiteral);
|
||||||
|
AssertLiteralExpr('Right is integer',B.Right,TSQLIntegerLiteral);
|
||||||
|
AssertEquals('Right is 1',1, TSQLIntegerLiteral(TSQLLiteralExpression(B.Right).Literal).Value);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestCheckParser.TestNotContaining;
|
procedure TTestCheckParser.TestNotContaining;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -2177,6 +2194,19 @@ begin
|
|||||||
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestCheckParser.TestSubtract;
|
||||||
|
|
||||||
|
Var
|
||||||
|
B : TSQLBinaryExpression;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TSQLBinaryExpression(TestCheck('VALUE - 1',TSQLBinaryExpression));
|
||||||
|
AssertEquals('Correct operator', boSubtract, B.Operation);
|
||||||
|
AssertLiteralExpr('Left is value',B.Left,TSQLValueLiteral);
|
||||||
|
AssertLiteralExpr('Right is integer',B.Right,TSQLIntegerLiteral);
|
||||||
|
AssertEquals('Right is 1',1, TSQLIntegerLiteral(TSQLLiteralExpression(B.Right).Literal).Value);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestCheckParser.TestNotStartingWith;
|
procedure TTestCheckParser.TestNotStartingWith;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -2264,6 +2294,19 @@ begin
|
|||||||
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestCheckParser.TestMultiply;
|
||||||
|
|
||||||
|
Var
|
||||||
|
B : TSQLBinaryExpression;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TSQLBinaryExpression(TestCheck('VALUE * 1',TSQLBinaryExpression));
|
||||||
|
AssertEquals('Correct operator', boMultiply, B.Operation);
|
||||||
|
AssertLiteralExpr('Left is value',B.Left,TSQLValueLiteral);
|
||||||
|
AssertLiteralExpr('Right is integer',B.Right,TSQLIntegerLiteral);
|
||||||
|
AssertEquals('Right is 1',1, TSQLIntegerLiteral(TSQLLiteralExpression(B.Right).Literal).Value);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestCheckParser.TestNotLikeEscape;
|
procedure TTestCheckParser.TestNotLikeEscape;
|
||||||
Var
|
Var
|
||||||
U : TSQLUnaryExpression;
|
U : TSQLUnaryExpression;
|
||||||
@ -2280,6 +2323,19 @@ begin
|
|||||||
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TTestCheckParser.TestAdd;
|
||||||
|
|
||||||
|
Var
|
||||||
|
B : TSQLBinaryExpression;
|
||||||
|
|
||||||
|
begin
|
||||||
|
B:=TSQLBinaryExpression(TestCheck('VALUE + 1',TSQLBinaryExpression));
|
||||||
|
AssertEquals('Correct operator', boAdd, B.Operation);
|
||||||
|
AssertLiteralExpr('Left is value',B.Left,TSQLValueLiteral);
|
||||||
|
AssertLiteralExpr('Right is integer',B.Right,TSQLIntegerLiteral);
|
||||||
|
AssertEquals('Right is 1',1, TSQLIntegerLiteral(TSQLLiteralExpression(B.Right).Literal).Value);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TTestCheckParser.TestAnd;
|
procedure TTestCheckParser.TestAnd;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
|
Loading…
Reference in New Issue
Block a user