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

Commit d14e712

Browse files
committed
[[ CodeResources ]] Add test
1 parent 1581d1e commit d14e712

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

tests/_testlib.livecodescript

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,55 @@ private function _TestGetBuiltExtensionsFolder
138138
end _TestGetBuiltExtensionsFolder
139139

140140
private command _TestLoadExtension pFolder, pPath
141+
local tCodeFolder
142+
put pFolder & "/code" into tCodeFolder
143+
144+
if there is a folder tCodeFolder then
145+
local tCodeFolders
146+
put folders(tCodeFolder) into tCodeFolders
147+
switch the platform
148+
case "MacOS"
149+
filter tCodeFolders with "*-mac*"
150+
break
151+
case "Win32"
152+
filter tCodeFolders with "*-win*"
153+
break
154+
default
155+
filter tCodeFolders with "*-"& toLower(the platform) & "*"
156+
break
157+
end switch
158+
159+
local tFilteredCodeFolders
160+
filter tCodeFolders with the processor & "-*" into tFilteredCodeFolders
161+
split tFilteredCodeFolders by return as set
162+
if the platform is "MacOS" then
163+
-- explicit processor should take precedence over universal builds but
164+
-- in the event multiple libraries are included and some are universal
165+
-- we must merge
166+
local tUniveralFilteredCodeFolders
167+
filter tCodeFolders with "universal-*" into tUniveralFilteredCodeFolders
168+
split tUniveralFilteredCodeFolders by return as set
169+
union tFilteredCodeFolders with tUniveralFilteredCodeFolders
170+
end if
171+
172+
repeat for each key tFolder in tFilteredCodeFolders
173+
local tLibraries
174+
put files(tCodeFolder & "/" & tFolder) & return & \
175+
folders(tCodeFolder & "/" & tFolder) into tLibraries
176+
filter tLibraries without ".*"
177+
178+
if tLibraries is not empty then
179+
set the itemDelimiter to "."
180+
repeat for each line tLibrary in tLibraries
181+
-- remove extension
182+
delete the last item of tLibrary
183+
if tLibrary is not empty then
184+
set the revLibraryMapping[tLibrary] to tCodeFolder & "/" & tFolder & "/" & tLibrary
185+
end if
186+
end repeat
187+
end if
188+
end repeat
189+
end if
141190
if there is a folder (pFolder & slash & "resources") then
142191
do "load extension from file pPath with resource path (pFolder & slash & " & quote & "resources" & quote & ")"
143192
else

tests/lcs-input-files/test.ini

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
; Test config file for ini_example.c and INIReaderTest.cpp
2+
3+
[protocol] ; Protocol configuration
4+
version=6 ; IPv6
5+
6+
[user]
7+
name = Bob Smith ; Spaces around '=' are stripped
8+
email = bob@smith.com ; And comments (like this) ignored
9+
active = true ; Test a boolean
10+
pi = 3.14159 ; Test a floating point number
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
script "TestExtensionCodeLibrary"
2+
/*
3+
Copyright (C) 2017 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestSetup
20+
TestSkipIfNot "lcb"
21+
TestLoadExtension "com.livecode.library.ini"
22+
end TestSetup
23+
24+
on TestLoadCodeLibrary
25+
TestAssert "library mapping is set for code library", the revLibraryMapping["inih"] is not empty
26+
27+
local tFileData
28+
put url ("file:" & TestGetInputFile("test.ini")) into tFileData
29+
30+
local tIni
31+
put iniToArray(tFileData) into tIni
32+
33+
TestAssert "library extension can load code library", tIni["user"]["name"] is "Bob Smith"
34+
end TestLoadCodeLibrary

0 commit comments

Comments
 (0)