Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Common/FoxProCmd.xh
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@
#command COMMIT IN <(a)> => (<(a)>) -> (DbCommit())
#command UNLOCK [RECORD <rcd>] IN <(a)> => (<(a)>) -> (DbUnLock(<rcd>))

#command GOTO <n> IN <(a)> => (<a>)->(DbGoto(<n>))
#command GO [RECORD] <n> IN <(a)> => (<a>)->(DbGoto(<n>))
#command GOTO TOP IN <(a)> => (<a>)->(DbGoTop())
#command GO TOP IN <(a)> => (<a>)->(DbGoTop())
#command GOTO BOTTOM IN <(a)> => (<a>)->(DbGoBottom())
#command GO BOTTOM IN <(a)> => (<a>)->(DbGoBottom())
#command SKIP IN <(a)> => (<a>)->(DbSkip(1))
#command SKIP <n> IN <(a)> => (<a>)->(DbSkip(<n>))
#command GOTO <n> IN <(a)> => (<(a)>)->(DbGoto(<n>))
#command GO [RECORD] <n> IN <(a)> => (<(a)>)->(DbGoto(<n>))
#command GOTO TOP IN <(a)> => (<(a)>)->(DbGoTop())
#command GO TOP IN <(a)> => (<(a)>)->(DbGoTop())
#command GOTO BOTTOM IN <(a)> => (<(a)>)->(DbGoBottom())
#command GO BOTTOM IN <(a)> => (<(a)>)->(DbGoBottom())
#command SKIP IN <(a)> => (<(a)>)->(DbSkip(1))
#command SKIP <n> IN <(a)> => (<(a)>)->(DbSkip(<n>))

#command SET FILTER TO IN <(a)> => (<(a)>) -> (DbClearFilter())
#command SET FILTER TO <xpr> IN <(a)> => (<(a)>) -> (DbSetFilter( <{xpr}>, <"xpr"> ))
Expand Down
97 changes: 97 additions & 0 deletions src/Runtime/XSharp.VFP.Tests/InClauseAliasTests.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// Copyright (c) XSharp B.V. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// See License.txt in the project root for license information.
//
USING System
USING XUnit

BEGIN NAMESPACE XSharp.VFP.Tests

CLASS InClauseAliasTests

STATIC CONSTRUCTOR
XSharp.RuntimeState.Dialect := XSharpDialect.FoxPro
END CONSTRUCTOR

// Two cursors, so the IN clause has to act on the one that is NOT selected
PRIVATE METHOD CreateCursors() AS VOID
CREATE CURSOR aliasone (id I)
INSERT INTO aliasone VALUES (1)
INSERT INTO aliasone VALUES (2)
INSERT INTO aliasone VALUES (3)
GO TOP
CREATE CURSOR aliastwo (id I)
INSERT INTO aliastwo VALUES (9)
GO TOP
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD SkipInAcceptsAnUnquotedAlias AS VOID
SELF:CreateCursors()
SELECT aliastwo
SKIP 1 IN aliasone
SELECT aliasone
Assert.Equal((DWORD) 2, RECNO())
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD SkipWithoutCountInAcceptsAnUnquotedAlias AS VOID
SELF:CreateCursors()
SELECT aliastwo
SKIP IN aliasone
SELECT aliasone
Assert.Equal((DWORD) 2, RECNO())
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD GotoBottomInAcceptsAnUnquotedAlias AS VOID
SELF:CreateCursors()
SELECT aliastwo
GOTO BOTTOM IN aliasone
SELECT aliasone
Assert.Equal((DWORD) 3, RECNO())
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD GotoTopInAcceptsAnUnquotedAlias AS VOID
SELF:CreateCursors()
SELECT aliasone
GO BOTTOM
SELECT aliastwo
GOTO TOP IN aliasone
SELECT aliasone
Assert.Equal((DWORD) 1, RECNO())
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD GotoRecordInAcceptsAnUnquotedAlias AS VOID
SELF:CreateCursors()
SELECT aliastwo
GOTO 3 IN aliasone
SELECT aliasone
Assert.Equal((DWORD) 3, RECNO())
END METHOD

[Fact, Trait("Category", "InClause")];
METHOD QuotedAliasKeepsWorking AS VOID
SELF:CreateCursors()
SELECT aliastwo
SKIP 1 IN "aliasone"
SELECT aliasone
Assert.Equal((DWORD) 2, RECNO())
END METHOD

// The IN clause must not change the selected work area
[Fact, Trait("Category", "InClause")];
METHOD InClauseDoesNotChangeTheSelectedArea AS VOID
SELF:CreateCursors()
SELECT aliastwo
VAR nBefore := SELECT()
SKIP 1 IN aliasone
Assert.Equal(nBefore, SELECT())
END METHOD

END CLASS

END NAMESPACE
1 change: 1 addition & 0 deletions src/Runtime/XSharp.VFP.Tests/XSharp.VFP.Tests.xsproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
<Compile Include="CursorToXmlTests.prg" />
<Compile Include="FileVersionTests.prg" />
<Compile Include="FinancialTests.prg" />
<Compile Include="InClauseAliasTests.prg" />
<Compile Include="IndexOnTrimTests.prg" />
<Compile Include="IntrospectionTests.prg" />
<Compile Include="KeyMatchLookupTests.prg" />
Expand Down