Skip to content

Commit

Permalink
Breaking change: 18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aplteam committed Sep 20, 2020
1 parent 47fad5c commit 01e6620
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 60 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
.acre/
aplcore
Dist/
change_history/
.gitignore
6 changes: 6 additions & 0 deletions APLSource/Initialize.aplf
@@ -0,0 +1,6 @@
{r}Initialize;⎕TRAP
⎕TRAP0 'S'
r
{}⎕SE.UCMD'cd ',AcreConfig.ProjectFolder
⎕SE.aplteam.InitializeAPLTreeProject ⎕THIS
Done
2 changes: 2 additions & 0 deletions APLSource/TestCases/Cleanup.aplf
@@ -0,0 +1,2 @@
Cleanup
#.⎕EX'INI'
2 changes: 1 addition & 1 deletion APLSource/TestCases/Initial.aplf
@@ -1,5 +1,5 @@
Initial;home
⎕IO0 ⎕ML3
⎕IO0 ⎕ML1
##.FilesAndDirs.PolishCurrentDir
#.INI'flat'(⎕NEW ##.IniFiles(,GetFileRoot,'Tests\INIs\TestCases_',##.WinSys.GetComputerName,'.ini')).Convert ⎕NS''
homeGetTestCasesHome
Expand Down
5 changes: 5 additions & 0 deletions APLSource/TestCases/Prepare.aplf
@@ -1,2 +1,7 @@
Prepare
⎕IO1 ⎕ML1
T⎕NEW ##.Tester2 ⎕THIS
T.codeCoverage⎕NEW ##.CodeCoverage(,'#.',{,'.',}2⎕THIS.##)
T.codeCoverage.filename(1 ⎕NPARTS''),'TestResults/CodeCoverage'
a1
Done
2 changes: 1 addition & 1 deletion APLSource/TestCases/QuadVariables.apln
@@ -1,6 +1,6 @@
:Namespace QuadVariables
##.⎕IO0
##.⎕ML3
##.⎕ML1
##.⎕WX3
:EndNamespace

12 changes: 12 additions & 0 deletions APLSource/TestCases/RunTests.aplf
@@ -0,0 +1,12 @@
RunTests;dcfFilename;htmlFilename;tno
Prepare
dcfFilename(,/¯1⎕NPARTS T.codeCoverage.filename),'.dcf'
:If ##.FilesAndDirs.IsFile dcfFilename
:AndIf ∆YesOrNo'CodeCovarge data file already exists; override?'
tnodcfFilename ⎕FTIE 0
dcfFilename ⎕FERASE tno
:EndIf
T.Run 1
htmlFilename##.CodeCoverage.ProcessDataAndCreateReport T.codeCoverage.filename
##.APLTreeUtils2.GoToWebPage'file://',htmlFilename
Done
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_002.aplf
Expand Up @@ -7,6 +7,6 @@
T.FailsIf~0v
v##.WinSys.ExpandEnv i'%WinDir%\MyDir'
T.FailsIf vi
T.FailsIf'MyDir'1##.APLTreeUtils.SplitPath v
T.FailsIf'MyDir'1##.APLTreeUtils2.SplitPath v

RT._OK
6 changes: 3 additions & 3 deletions APLSource/TestCases/Test_004.aplf
Expand Up @@ -4,9 +4,9 @@
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')

v##.WinSys.GetWindowsDirectory
set⎕CMD'set' All env variables
r'windir'{(##.APLTreeUtils.Lowercase()[1]).=}set Row
windir{-+/\' '=}'windir='{()}set[r1;]
set⎕CMD'set' All env variables
r'windir'{(##.APLTreeUtils2.Lowercase()[1]).=}set Row
windir{-+/\' '=}'windir='{()}set[r1;]
T.FailsIf windirv

RT._OK
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_007.aplf
Expand Up @@ -4,6 +4,6 @@
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')

ms##.WinSys.GetMsgFrom¨1000 Get messages for 1000 return codes
T.FailsIf 400>0+.¨ms There are at least 400 error messages defined...
T.FailsIf 400>0+.¨ms There are at least 400 error messages defined...

RT._OK
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_014.aplf
Expand Up @@ -3,7 +3,7 @@
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
RT._Failed

dllName↑↑##.FilesAndDirs.Dir(⎕IO##.APLTreeUtils.SplitPath ⎕IO ⎕IO#.GetCommandLineArgs'Dyalog'),'\dyalog*.dll'
dllName⊃⊃##.FilesAndDirs.Dir(⎕IO##.APLTreeUtils2.SplitPath ⎕IO ⎕IO#.GetCommandLineArgs'Dyalog'),'\dyalog*.dll'
r##.WinSys.GetModuleFileName dllName
T.PassesIf 0<r

Expand Down
2 changes: 1 addition & 1 deletion APLSource/TestCases/Test_016.aplf
Expand Up @@ -10,7 +10,7 @@
:EndIf
(rc path)##.WinSys.FindExecutable ##.FilesAndDirs.PWD,'\',filename
T.FailsIf 0rc
T.FailsIf'dyalog.exe'##.APLTreeUtils.Lowercase 1##.APLTreeUtils.SplitPath path
T.FailsIf'dyalog.exe'##.APLTreeUtils2.Lowercase 1##.APLTreeUtils2.SplitPath path
:EndIf

RT._OK
4 changes: 2 additions & 2 deletions APLSource/TestCases/Test_026.aplf
Expand Up @@ -7,9 +7,9 @@
Tests...
list##.WinSys.GetAllDrives
T.FailsIf~0<list
T.FailsIf~/(¨list)⎕A
T.FailsIf~/(¨list)⎕A
T.FailsIf(,':'),1¨list
T.FailsIf(,'\'),2¨list
T.FailsIf(,3)¨list
T.FailsIf(,3)¨list

RT._OK
10 changes: 5 additions & 5 deletions APLSource/TestCases/Test_027.aplf
Expand Up @@ -9,21 +9,21 @@
list##.WinSys.GetDriveAndType

T.FailsIf~0<list[;0]
T.FailsIf~/(¨list[;0])⎕A
T.FailsIf~/(¨list[;0])⎕A
T.FailsIf(,':'),1¨list[;0]
T.FailsIf(,'\'),2¨list[;0]
T.FailsIf(,3)¨list[;0]
T.FailsIf(,3)¨list[;0]
T.FailsIf~/(list[;1])9

The following tests depend on local specialties - see "Initial"
:If 0#.INI.FixedDrives
T.PassesIf(,#.INI.FixedDrives)Match¨(list[;2]¨'Fixed')/list[;0]
T.PassesIf(,#.INI.FixedDrives)Match¨(list[;2]¨'Fixed')/list[;0]
:EndIf
:If 0#.INI.NetworkDrives
T.PassesIf(,#.INI.NetworkDrives)Match¨(list[;2]¨'Remote')/list[;0]
T.PassesIf(,#.INI.NetworkDrives)Match¨(list[;2]¨'Remote')/list[;0]
:EndIf
:If 0#.INI.CDRomDrives
T.PassesIf(,#.INI.CDRomDrives)Match¨(list[;2]¨'CD-ROM')/list[;0]
T.PassesIf(,#.INI.CDRomDrives)Match¨(list[;2]¨'CD-ROM')/list[;0]
:EndIf

types'Invalid Path' 'Removable' 'Fixed' 'Remote' 'CD-ROM' 'Ram-Disk'
Expand Down
12 changes: 12 additions & 0 deletions APLSource/TestCases/Test_030.aplf
@@ -0,0 +1,12 @@
RTest_030(stopFlag batchFlag);⎕TRAP;info
Exercise `##.WinSys.GetDiskFreeSpace`
RT._Failed
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')

info##.WinSys.GetDiskFreeSpace'C'
T.PassesIf 0.<info

info##.WinSys.GetDiskFreeSpace'C:'
T.PassesIf 0.<info

RT._OK
6 changes: 3 additions & 3 deletions APLSource/TestCases/Test_ZZZ_998.aplf
@@ -1,17 +1,17 @@
RTest_ZZZ_998(stopFlag batchFlag);⎕IO;⎕ML;⎕TRAP;report;buff
Checks on two text vectors: "⍝TODO⍝" and "⍝CHECK⍝"; never fails, just reports.
⎕IO0 ⎕ML3
⎕IO1 ⎕ML1
⎕TRAP(999 'C' '. ⍝ Deliberate error')(0 'N')
RT._OK
report''

buffT.FindSpecialString'⍝CHECK⍝'
buff(buff[;0]¨⎕XSI[0])buff remove caller
buff(buff[;1]¨⎕XSI[1])buff remove caller
:If 0buff
report,(' ⍝CHECK⍝ found:'),(' '),¨buff
:EndIf
buffT.FindSpecialString'⍝TODO⍝'
buff(buff[;0]¨⎕XSI[0])buff remove caller
buff(buff[;1]¨⎕XSI[1])buff remove caller
:If 0buff
report,(' ⍝TODO⍝ found:'),(' '),¨buff
:EndIf
Expand Down
3 changes: 2 additions & 1 deletion APLSource/TestCases/Test_ZZZ_999.aplf
Expand Up @@ -7,6 +7,7 @@

First we check whether "Version" returns a valid result:
(n v d)rf.Version
d{/3>+\'-'=}d Remove trailing stuff like "-beta"
v{/3>+\'.'=}v Remove build ID
f1~5v
f12'.'+.=v
Expand All @@ -17,7 +18,7 @@
f1~/⎕Dd~'-'

publish.config must be in line with what "Version" returns of course:
xml⎕XML'flat'##.APLTreeUtils.ReadUtf8File'publish.config'
xml⎕XML⎕NGET'publish.config'
f2v(2+⎕IO)xml[xml[;1+⎕IO]'version';]
f2d(2+⎕IO)xml[xml[;1+⎕IO]'date';]

Expand Down
51 changes: 51 additions & 0 deletions APLSource/TestCases/∆YesOrNo.aplf
@@ -0,0 +1,51 @@
yesOrNo{default}∆YesOrNo question;isOkay;answer;add;dtb;answer2
Ask a simple question and allows just "Yes" or "No" as answers.
You may specify a default via the optional left argument which when specified
rules what happens when the user just presses <enter>.
`default` must be either 1 (yes) or 0 (no).
Note that this function does not work as expected when traced!
isOkay0
default{0<⎕NC : ''}'default'
isOkay0
:If ~0default
'Left argument must be a scalar'⎕SIGNAL 11/1,default
:AndIf ~default0 1
'The left argument. if specified, must be a Boolean or empty'⎕SIGNAL 11
:EndIf
:If 0=default
add' (y/n) '
:Else
:If default
add' (Y/n) '
:Else
add' (y/N) '
:EndIf
:EndIf
:If 1<question
((question)question)((question)question),add
questionquestion
:Else
questionquestion,add
:EndIf
:Repeat
question
answer
:If answerquestion Did... (since version 18.0 trailing blanks are not removed anynmore)
:OrIf (answer)=¯1+question ..the ...
:OrIf 0=answer ...user just...
dtb{-+/\' '=}
answer2dtb answer
:OrIf answer2((-answer2)(⎕UCS 10){~: ' ',dtb {1+}}question) ...press <enter>?
:If 0default
yesOrNodefault
isOkay1
:EndIf
:Else
answer¯1{-+/\' '=}answer
:If answer'YyNn'
isOkay1
yesOrNoanswer'Yy'
:EndIf
:EndIf
:Until isOkay
Done
55 changes: 21 additions & 34 deletions APLSource/WinSys.aplc
Expand Up @@ -8,31 +8,23 @@
Homepage: <http://aplwiki.com/WinSys>\\
Kai Jaeger ⋄ APL Team Ltd.

:Include APLTreeUtils

⎕IO0
⎕ML3
⎕ML1

rVersion
:Access Public shared
r({-'.'}⎕THIS)'4.0.0.11' '2020-05-11'
r'WinSys' '5.0.0.13' '2020-09-20'

History
:Access Public shared
* 4.0.0
* BREAKING CHANGE: deprecated methods removed
* New method `GetFileVersionInfo` added.
* Outdated ".C32" removed from all `⎕NA` calls.
* 3.0.0
* BREAKING CHANGE: file extension is now .aplc rather than .dyalog
* 5.0.0
* Requires Dyalog 18.0 or better now
* Internal changes:
* Uses `⎕ML←1` now
* Does not `:Include APLTreeUtils` anymore
\\
For information regarding older versions see <https://github.com/aplteam/WinSys/releases>

Note that a couple of functions are deprecated now. Search for `⍝Deprecated⍝`. \\
These functions are not mantained any more and will be removed from `WinSys`
in a future release. See the `OS` class which offers platform-independent
alternatives for these functions.

:Field Public Shared ReadOnly SM_CXSCREEN0 Screen size
Expand Down Expand Up @@ -163,14 +155,14 @@
'Info'⎕NA'U4 version∣GetFileVersionInfo* <0T U4 U4 P'
'Valu'⎕NA'U4 version∣VerQueryValue* P <0T >U4 >U4'
'copy'⎕NA'P msvcrt∣memcpy >U4[] P U4'
:If ×sizeSize filename 0 Size of info.
:If ×sizeSize filename 0 Size of info.
:AndIf ×hndlAloc 0 size Alloc memory.
:If ×addrLock hndl Lock memory.
:If ×Info filename 0 size addr Version info.
(ok buff size)Valu addr'\' 0 0 Version value.
:If ok
(retn buff)copy(size÷4)buff size Copy info.
version3,(2/2*16)2buff Encode version.
version3,(2/2*16)2buff Encode version.
:Else
('Call to "VerQueryValue" failed, rc=',ok)⎕SIGNAL 11
:EndIf
Expand Down Expand Up @@ -204,6 +196,8 @@
| r[2] | Capacity of disk in KB
| r[3] | How many KB are available in total
In case of an error `r ←→ (¯1 ¯1 ¯1)`
`drive` may be something like `C` or `C:`
drive2drive,':'
'GetDiskFreeSpaceEx'⎕NA'I KERNEL32|GetDiskFreeSpaceEx* <0T >U[2] >U[2] >U[2]'
(rc freeForCaller capacity freeInTotal)GetDiskFreeSpaceEx drive 2 2 2
:If 0rc
Expand All @@ -221,7 +215,7 @@
'∆GetComputerName'⎕NA'P KERNEL32|GetComputerName* >0T =P'
multiByte1+80=⎕DR' ' Unicode version? (used to double the buffer size)
(rc buffer size)∆GetComputerName multiByte×232
R(0=rc)buffer''
R(0=rc)buffer''

rGetDefaultBrowser;regKey1;progID;regKey2;wsh
Expand Down Expand Up @@ -299,32 +293,30 @@
:EndIf

RGetAllDrives;Values;Drives;∆GetLogicalDriveStrings;⎕IO;⎕ML
RGetAllDrives;Values;Drives;∆GetLogicalDriveStrings
Returns a vector of text vectors with the names of all drives, for example: "C:\"
:Access Public Shared
⎕IO1 ⎕ML3
'∆GetLogicalDriveStrings'⎕NA'U4 KERNEL32|GetLogicalDriveStrings* U4 >T[]'
Values∆GetLogicalDriveStrings 255 255
Drives(Values)(⎕IO+1)Values
R((~(⎕UCS 0)=Drives)Drives)
Drives(Values)(⎕IO+1)Values
R{⎕ML3 ((~(⎕UCS 0)=))}Drives

RGetDriveAndType;AllDrives;Txt;Types;∆GetDriveType;⎕IO;⎕ML
RGetDriveAndType;AllDrives;Txt;Types;∆GetDriveType
Returns a matrix with the names and the types of all drives.\\
The number of rows is defined by the number of drives found.\\
"Types" may be something like "Fixed", "CD-ROM", "Removable", "Remote".
:Access Public Shared
⎕IO1 ⎕ML3
'∆GetDriveType'⎕NA'U4 KERNEL32|GetDriveType* <0T'
Types∆GetDriveType¨AllDrivesGetAllDrives
Txt'Invalid Path' 'Removable' 'Fixed' 'Remote' 'CD-ROM' 'Ram-Disk'
RAllDrives,Types,[1.5](Txt,'Unknown')[(0,Txt)Types]
RAllDrives,Types,[0.5](Txt,'Unknown')[¯1+(0,Txt)Types]

RList_SM
:Access Public Shared
Lists all fields with names that start with "SM\_"
R⎕NL-2
R⎕NL-2
R(R[;3].='SM_')R
R(R)~¨' '
Expand All @@ -337,7 +329,7 @@
FORMAT_MESSAGE_FROM_SYSTEM4096
LangID0
'FormatMsg'⎕NA'I KERNEL32|FormatMessage* I4 I4 I4 I4 >T[] I4 I4'
:If 0>midmid
:If 0>midmid
:AndIf ¯16777216mid
mid-mid
:EndIf
Expand All @@ -355,7 +347,7 @@
:EndIf
r/FormatMsg(FORMAT_MESSAGE_FROM_HMODULE+FORMAT_MESSAGE_IGNORE_INSERTS)hModule mid LangID size size 0
{}FreeLibrary hModule
:If ×r
:If ×r
:Leave
:EndIf
:EndIf
Expand Down Expand Up @@ -458,15 +450,10 @@


RGetLastError;∆GetLastError;⎕ML;⎕IO
RGetLastError;∆GetLastError
:Access Public Shared
⎕IO1 ⎕ML3
'∆GetLastError'⎕NA'I4 kernel32|GetLastError'
R∆GetLastError

rIs64Bit
r'-64'¯3⎕IO'#'⎕WG'APLVersion'

:EndClass
2 changes: 0 additions & 2 deletions Make/Make.bat

This file was deleted.

Binary file added TestResults/CodeCoverage.dcf
Binary file not shown.

0 comments on commit 01e6620

Please sign in to comment.