Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit c40e63d

Browse files
committed
[[ Tests ]] Rework input lib API slightly
1 parent aa2ab66 commit c40e63d

File tree

10 files changed

+37
-27
lines changed

10 files changed

+37
-27
lines changed

tests/_inputlib.livecodescript

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ end revLoadLibrary
2323
local sTestStrings, sTestNumbers, sTestConversionStrings, sTestFilePaths, sArrayData
2424
local sInitialised
2525

26-
function testFilesFolder
26+
function TestGetInputFilesFolder
2727
set the itemDelimiter to slash
2828
return item 1 to -2 of the filename of me & slash & "lcs-input-files"
29-
end testFilesFolder
29+
end TestGetInputFilesFolder
3030

3131
private function getTestFile pTestFile
3232
local tContent, tFilePath
3333

34-
put testFilesFolder() & slash & pTestFile into tFilePath
34+
put TestGetInputFilesFolder() & slash & pTestFile into tFilePath
3535

3636
// test files are written without BOM
3737
open file tFilePath for "utf8" text read
@@ -159,3 +159,7 @@ function testArrayData pKey
159159
setupValues
160160
return sArrayData[pKey]
161161
end testArrayData
162+
163+
function TestGetInputFile pFilename
164+
return TestGetInputFilesFolder() & slash & pFilename
165+
end TestGetInputFile

tests/lcs-input-files/tiny.gif

43 Bytes
Loading

tests/lcs-input-files/tiny.jpg

309 Bytes
Loading

tests/lcs-input-files/tiny.png

67 Bytes
Loading

tests/lcs/core/engine/clipboard.livecodescript

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,27 @@ end _TestPath
3636
-- Utility function that returns the smallest possible valid PNG image
3737
local sTinyPNG
3838
private function _TinyPNG
39-
if sTinyPNG is empty then put url format("binfile:%s/tiny.png", _TestPath()) into sTinyPNG
39+
if sTinyPNG is empty then
40+
put url ("binfile:" & TestGetInputFile("tiny.png")) into sTinyPNG
41+
end if
4042
return sTinyPNG
4143
end _TinyPNG
4244

4345
-- Utility function that returns the smallest possible valid GIF image
4446
local sTinyGIF
4547
private function _TinyGIF
46-
if sTinyGIF is empty then put url format("binfile:%s/tiny.gif", _TestPath()) into sTinyGIF
48+
if sTinyGIF is empty then
49+
put url ("binfile:" & TestGetInputFile("tiny.gif")) into sTinyGIF
50+
end if
4751
return sTinyGIF
4852
end _TinyGIF
4953

5054
-- Utility function that returns the smallest possible valid JPEG image
5155
local sTinyJPEG
5256
private function _TinyJPEG
53-
if sTinyJPEG is empty then put url format("binfile:%s/tiny.jpg", _TestPath()) into sTinyJPEG
57+
if sTinyJPEG is empty then
58+
put url ("binfile:" & TestGetInputFile("tiny.jpg")) into sTinyJPEG
59+
end if
5460
return sTinyJPEG
5561
end _TinyJPEG
5662

tests/lcs/core/files/bom.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ on TestLoadBomScriptOnlyStackFile
2525
local tUrlBinfilePath
2626
local tScriptOnlyStack
2727

28-
put "binfile:" & testFilesFolder() & slash & kTestFile \
28+
put "binfile:" & TestGetInputFilesFolder() & slash & kTestFile \
2929
into tUrlBinfilePath
3030

3131
open stack url tUrlBinfilePath

tests/lcs/core/interface/import.livecodescript

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ private function _TestPath
2323
end _TestPath
2424

2525
on TestImportPaintInGroup
26-
27-
local tTargetGroup
28-
create group
29-
put it into tTargetGroup
30-
31-
local tImportedImage, tImageFilenameFullPath
32-
put _TestPath() & "/../engine/tiny.png" into tImageFilenameFullPath
33-
import paint from file tImageFilenameFullPath in tTargetGroup
34-
put it into tImportedImage
35-
TestAssert "Now-grouped image is owned by the group", the long id of the owner of tImportedImage is tTargetGroup
36-
26+
local tTargetGroup
27+
create group
28+
put it into tTargetGroup
29+
30+
local tImportedImage, tImageFilenameFullPath
31+
put TestGetInputFile("tiny.png") into tImageFilenameFullPath
32+
import paint from file tImageFilenameFullPath in tTargetGroup
33+
put it into tImportedImage
34+
35+
TestAssert "Now-grouped image is owned by the group", \
36+
the long id of the owner of tImportedImage is tTargetGroup
3737
end TestImportPaintInGroup

tests/lcs/core/multimedia/clipmessages.livecodescript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end deleteVideoclip
2020

2121
on TestAudioclipMessages
2222
local tObject
23-
import audioclip from file (testFilesFolder() & "/testBlankAudio.wav")
23+
import audioclip from file (TestGetInputFile("testBlankAudio.wav"))
2424
put the long id of the last audioclip into tObject
2525
TestAssert "newAudioclip message", sNewObject is tObject
2626
delete tObject
@@ -29,7 +29,7 @@ end TestAudioclipMessages
2929

3030
on TestVideoclipMessages
3131
local tObject
32-
import videoclip from file (testFilesFolder() & "/testBlankVideo.mpeg")
32+
import videoclip from file (TestGetInputFile("/testBlankVideo.mpeg"))
3333
put the long id of the last videoclip into tObject
3434
TestAssert "newVideoclip message", sNewObject is tObject
3535
delete tObject

tests/lcs/core/security/encrypt.livecodescript

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ end TestSetup
2323
on TestRSA
2424

2525
local tPublicPKCS8, tPublicPKCS1, tPrivatePKCS8, tPrivatePKCS1
26-
put url ("binfile:" & testFilesFolder() & "/public_key.pkcs8") into tPublicPKCS8
27-
put url ("binfile:" & testFilesFolder() & "/public_key.pkcs1") into tPublicPKCS1
28-
put url ("binfile:" & testFilesFolder() & "/private_key.pkcs8") into tPrivatePKCS8
29-
put url ("binfile:" & testFilesFolder() & "/private_key.pkcs1") into tPrivatePKCS1
26+
put url ("binfile:" & TestGetInputFile("/public_key.pkcs8")) into tPublicPKCS8
27+
put url ("binfile:" & TestGetInputFile("/public_key.pkcs1")) into tPublicPKCS1
28+
put url ("binfile:" & TestGetInputFile("/private_key.pkcs8")) into tPrivatePKCS8
29+
put url ("binfile:" & TestGetInputFile("/private_key.pkcs1")) into tPrivatePKCS1
3030

3131
__TestRoundTripRSA "foo", tPublicPKCS1, "PKCS1", tPrivatePKCS1, "PKCS1"
3232
__TestRoundTripRSA "foo", tPublicPKCS8, "PKCS8", tPrivatePKCS8, "PKCS8"
@@ -36,8 +36,8 @@ end TestRSA
3636

3737
on TestRSAPass
3838
local tPublicPKCS8, tPrivatePKCS1
39-
put url ("binfile:" & testFilesFolder() & "/public_key_pass.pkcs8") into tPublicPKCS8
40-
put url ("binfile:" & testFilesFolder() & "/private_key_pass.pkcs1") into tPrivatePKCS1
39+
put url ("binfile:" & TestGetInputFile("/public_key_pass.pkcs8")) into tPublicPKCS8
40+
put url ("binfile:" & TestGetInputFile("/private_key_pass.pkcs1")) into tPrivatePKCS1
4141

4242
encrypt "foo" using rsa with private key tPrivatePKCS1 and passphrase "foobar"
4343
decrypt it using rsa with public key tPublicPKCS8

tests/lcs/liburl/forms.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ on TestForm
2222
set the httpHeaders to line 1 of tForm
2323
delete line 1 of tForm
2424

25-
put "<file>" & testFilesFolder() & "/last, first.txt" into tFile
25+
put "<file>" & TestGetInputFile("last, first.txt") into tFile
2626
put "text/plain" into tType
2727
put "binary" into tEnc
2828
put libURLMultipartFormAddPart(tForm,"file", tFile, tType, tEnc) into tError

0 commit comments

Comments
 (0)