mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 11:29:27 +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);
|
||||
B:=TSQLBinaryExpression(CreateElement(TSQLBinaryExpression,AParent));
|
||||
B.Left:=Result;
|
||||
Result:=B;
|
||||
B.Right:=Right;
|
||||
Case tt of
|
||||
tsqlMul : B.Operation:=boMultiply;
|
||||
|
@ -231,6 +231,10 @@ type
|
||||
procedure TestOr;
|
||||
procedure TestNotOr;
|
||||
procedure TestCase;
|
||||
procedure TestAdd;
|
||||
procedure TestSubtract;
|
||||
procedure TestMultiply;
|
||||
procedure TestDivide;
|
||||
end;
|
||||
|
||||
{ TTestDomainParser }
|
||||
@ -2123,6 +2127,19 @@ begin
|
||||
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
||||
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;
|
||||
|
||||
Var
|
||||
@ -2177,6 +2194,19 @@ begin
|
||||
AssertLiteralExpr('Right is string',B.Right,TSQLStringLiteral);
|
||||
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;
|
||||
|
||||
Var
|
||||
@ -2264,6 +2294,19 @@ begin
|
||||
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
||||
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;
|
||||
Var
|
||||
U : TSQLUnaryExpression;
|
||||
@ -2280,6 +2323,19 @@ begin
|
||||
AssertLiteralExpr('Right is string',T.Right,TSQLStringLiteral);
|
||||
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;
|
||||
|
||||
Var
|
||||
|
Loading…
Reference in New Issue
Block a user