Skip to content

Commit 988f799

Browse files
[[ Tests ]] Changes from feedback
Remove bugfixes for 16501 and 16500 Remove duplicated tests for intersect and union Fix typo in engine/engine.livecodescript and engine/object.livecodescript
1 parent 086ca7f commit 988f799

7 files changed

Lines changed: 16 additions & 252 deletions

File tree

docs/notes/bugfix-16500.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/notes/bugfix-16501.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

engine/src/exec-strings.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,15 +2130,6 @@ void MCStringsExecFilterRegexIntoIt(MCExecContext& ctxt, MCStringRef p_source, M
21302130
void MCStringsEvalIsAscii(MCExecContext& ctxt, MCValueRef p_value, bool& r_result)
21312131
{
21322132
MCAutoStringRef t_string;
2133-
2134-
// SN-2015-11-26: [[ Bug 16500 ]] Arrays will successfully convert to an
2135-
// empty string, which is a valid ASCII string. Cut short in this case
2136-
if (MCValueIsArray(p_value))
2137-
{
2138-
r_result = false;
2139-
return;
2140-
}
2141-
21422133
if (!ctxt . ConvertToString(p_value, &t_string))
21432134
{
21442135
r_result = false;

engine/src/uidc.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,16 +1545,12 @@ void MCUIDC::siguser()
15451545

15461546
Boolean MCUIDC::lookupcolor(MCStringRef s, MCColor *color)
15471547
{
1548-
uint4 slength = MCStringGetLength(s);
1548+
uint4 slength = MCStringGetLength(s);
15491549
MCAutoPointer<char> startptr;
15501550
startptr = new char[slength + 1];
1551-
1552-
// SN-2015-11-26: [[ Bug 16501 ]] Do not use GetOldString (nativises)
1553-
MCAutoPointer<char> t_cstring;
1554-
MCStringConvertToCString(s, &t_cstring);
1555-
1556-
char* sptr = *t_cstring;
1557-
1551+
char *sptr = *startptr;
1552+
MCU_lower(sptr, MCStringGetOldString(s));
1553+
sptr[slength] = '\0';
15581554
if (*sptr == '#')
15591555
{
15601556
uint2 r, g, b;

tests/lcs/core/array/arrayop.livecodescript

Lines changed: 1 addition & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -77,225 +77,4 @@ private function __keysAreEqual pLeftKeys, pRightKeys
7777
return pLeftKeys is pRightKeys
7878
end __keysAreEqual
7979

80-
// pArrayType: one of kStringArray, kNumericArray, kSequenceArray
81-
private command __testIntersect pArrayType
82-
local tStringArray, tNumberArray, tCommonArray
83-
local tValues, tKeys, tTemplateArray
84-
85-
if pArrayType is kStringArray then
86-
put testArrayData("stringKeys") into tKeys
87-
put __stringTemplate() into tTemplateArray
88-
else if pArrayType is kNumericArray then
89-
put kNumericKeys into tKeys
90-
put __numericTemplate() into tTemplateArray
91-
else
92-
put kSequenceKeys into tKeys
93-
put __sequenceTemplate() into tTemplateArray
94-
end if
95-
96-
put testArrayData("stringValues") into tValues
97-
98-
// Only the first item will match the template
99-
put item 1 of tValues into tCommonArray[item 1 of tKeys]
100-
put item 2 of tValues into tCommonArray[item 2 of tKeys]
101-
102-
// Now add a key that will not intersect with the template array
103-
// and a matching key - even if the value is not the same as it common array)
104-
// ( we have non-matching keys in both String and Template array)
105-
put tCommonArray into tStringArray
106-
put item 3 of tValues into tStringArray[item 2 of tKeys]
107-
put item 3 of tValues into tStringArray[item 3 of tKeys & "other"]
108-
109-
intersect tStringArray with tTemplateArray
110-
111-
TestAssert merge("Intersect [[pArrayType]] arrays"), __keysAreEqual(the keys of tStringArray, the keys of tCommonArray)
112-
end __testIntersect
113-
114-
on TestIntersectString
115-
__testIntersect kStringArray
116-
end TestIntersectString
117-
118-
on TestIntersectSequence
119-
__testIntersect kSequenceArray
120-
end TestIntersectSequence
121-
122-
on TestIntersectNumeric
123-
__testIntersect kNumericArray
124-
end TestIntersectNumeric
125-
126-
// pArrayType: one of kStringArray, kNumericArray, kSequenceArray
127-
private command __testIntersectRecursive pArrayType
128-
local tLeftArray, tRightArray, tCommonArray
129-
local tKeys
130-
131-
if pArrayType is kStringArray then
132-
put testArrayData("stringKeys") into tKeys
133-
else if pArrayType is kNumericArray then
134-
put kNumericKeys into tKeys
135-
else
136-
put kSequenceKeys into tKeys
137-
end if
138-
139-
// Set the common array
140-
put __numericTemplate() into tCommonArray[item 1 of tKeys]
141-
put __sequenceTemplate() into tCommonArray[item 2 of tKeys]
142-
put __stringTemplate() into tCommonArray[item 3 of tKeys]
143-
144-
put tCommonArray into tLeftArray
145-
put tCommonArray into tRightArray
146-
147-
// Create sub-array that misses one key
148-
local tCrippledStringArray
149-
put __stringTemplate() into tCrippledStringArray
150-
delete local tCrippledStringArray[line 1 of the keys of tCrippledStringArray]
151-
152-
put tCrippledStringArray into tRightArray[item 4 of tKeys]
153-
put tCrippledStringArray into tCommonArray[item 4 of tKeys]
154-
put __stringTemplate() into tLeftArray[item 4 of tKeys]
155-
156-
intersect tLeftArray with tRightArray recursively
157-
158-
local tSuccess
159-
put __keysAreEqual(the keys of tLeftArray, the keys of tCommonArray) into tSuccess
160-
161-
if tSuccess then
162-
repeat for each key tKey in tLeftArray
163-
if not __keysAreEqual(the keys of tLeftArray[tKey], the keys of tCommonArray[tKey]) then
164-
put false into tSuccess
165-
exit repeat
166-
end if
167-
end repeat
168-
end if
169-
170-
testAssert merge("Recursice intersect for [[pArrayType]] array"), tSuccess
171-
end __testIntersectRecursive
172-
173-
// Test with string keys
174-
on TestIntersectStringRecursive
175-
__testIntersectRecursive kStringArray
176-
end TestIntersectStringRecursive
177-
178-
179-
// Test with numeric keys
180-
on TestIntersectSequenceRecursive
181-
__testIntersectRecursive kSequenceArray
182-
end TestIntersectSequenceRecursive
183-
184-
on TestIntersectNumberRecursive
185-
__testIntersectRecursive kNumericArray
186-
end TestIntersectNumberRecursive
187-
188-
189-
// pArrayType: one of kStringArray, kNumericArray, kSequenceArray
190-
private command __testUnion pArrayType
191-
local tLeftArray
192-
local tValues, tKeys, tTemplateArray, tLeftOnlyKey
193-
194-
if pArrayType is kStringArray then
195-
put testArrayData("stringKeys") into tKeys
196-
put __stringTemplate() into tTemplateArray
197-
put "other key" & the milliseconds into tLeftOnlyKey
198-
else if pArrayType is kNumericArray then
199-
put kNumericKeys into tKeys
200-
put __numericTemplate() into tTemplateArray
201-
put the milliseconds into tLeftOnlyKey
202-
else
203-
put kSequenceKeys into tKeys
204-
put __sequenceTemplate() into tTemplateArray
205-
put 6 into tLeftOnlyKey
206-
end if
207-
208-
put testArrayData("stringValues") into tValues
209-
210-
// We have a different value in the first key, and a key specific for the union'd array
211-
put the milliseconds into tLeftOnlyKey
212-
put "value" into tLeftArray[tLeftOnlyKey]
213-
put the seconds into tLeftArray[item 1 of tKeys]
214-
215-
local tUnionKeys
216-
put the keys of tTemplateArray & LF & tLeftOnlyKey into tUnionKeys
217-
218-
union tLeftArray with tTemplateArray
219-
220-
TestAssert merge("union [[pArrayType]] arrays"), __keysAreEqual(the keys of tLeftArray, tUnionKeys)
221-
TestAssert "Left array value has not been overwritten", tLeftArray[item 1 of tKeys] is not tTemplateArray[item 1 of tKeys]
222-
end __testUnion
223-
224-
on TestUnionString
225-
__testUnion kStringArray
226-
end TestUnionString
227-
228-
on TestUnionSequence
229-
__testUnion kSequenceArray
230-
end TestUnionSequence
231-
232-
on TestUnionNumeric
233-
__testUnion kNumericArray
234-
end TestUnionNumeric
235-
236-
237-
// pArrayType: one of kStringArray, kNumericArray, kSequenceArray
238-
private command __testUnionRecursive pArrayType
239-
local tLeftArray, tRightArray, tCommonArray
240-
local tKeys
241-
242-
if pArrayType is kStringArray then
243-
put testArrayData("stringKeys") into tKeys
244-
else if pArrayType is kNumericArray then
245-
put kNumericKeys into tKeys
246-
else
247-
put kSequenceKeys into tKeys
248-
end if
249-
250-
// Set the common array
251-
put __numericTemplate() into tLeftArray[item 1 of tKeys]
252-
put __numericTemplate() into tRightArray[item 1 of tKeys]
253-
put __numericTemplate() into tCommonArray[item 1 of tKeys]
254-
255-
put __sequenceTemplate() into tLeftArray[item 2 of tKeys]
256-
put __sequenceTemplate() into tCommonArray[item 2 of tKeys]
257-
258-
put __stringTemplate() into tRightArray[item 3 of tKeys]
259-
put __stringTemplate() into tCommonArray[item 3 of tKeys]
260-
261-
// Create sub-array that misses one key
262-
local tCrippledStringArray
263-
put __stringTemplate() into tCrippledStringArray
264-
delete local tCrippledStringArray[line 1 of the keys of tCrippledStringArray]
265-
266-
// The common array will have the string template, not the crippled version
267-
put tCrippledStringArray into tRightArray[item 4 of tKeys]
268-
put __stringTemplate() into tCommonArray[item 4 of tKeys]
269-
put __stringTemplate() into tLeftArray[item 4 of tKeys]
270-
271-
union tLeftArray with tRightArray recursively
272-
273-
local tSuccess
274-
put __keysAreEqual(the keys of tLeftArray, the keys of tCommonArray) into tSuccess
275-
276-
if tSuccess then
277-
repeat for each key tKey in tLeftArray
278-
if not __keysAreEqual(the keys of tLeftArray[tKey], the keys of tCommonArray[tKey]) then
279-
put false into tSuccess
280-
exit repeat
281-
end if
282-
end repeat
283-
end if
284-
285-
testAssert merge("Recursice union for [[pArrayType]] array"), tSuccess
286-
end __testUnionRecursive
287-
288-
// Test with string keys
289-
on TestUnionStringRecursive
290-
__testUnionRecursive kStringArray
291-
end TestUnionStringRecursive
292-
293-
294-
// Test with numeric keys
295-
on TestUnionSequenceRecursive
296-
__testIntersectRecursive kSequenceArray
297-
end TestUnionSequenceRecursive
298-
299-
on TestUnionNumberRecursive
300-
__testUnionRecursive kNumericArray
301-
end TestUnionNumberRecursive
80+
// Keeping the file, for non-yet-implemented tests for arrays

tests/lcs/core/engine/engine.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ end TestFrontScripts
7979

8080
on TestFunctionNames
8181
TestAssert "functionNames is not empty", the functionNames is not empty
82-
TestAssert "'functionName' is amongst the functionNames", "functionNames" is among the lines of the functionNames
82+
TestAssert "'functionNames' is amongst the functionNames", "functionNames" is among the lines of the functionNames
8383
end TestFunctionNames
8484

8585

tests/lcs/core/engine/object.livecodescript

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,52 +19,52 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1919

2020
on TestCreateButton
2121
create button "test"
22-
TestAssert "button created", there is a button"test"
22+
TestAssert "button created", there is a button "test"
2323
end TestCreateButton
2424

2525
on TestCreateCard
2626
create card "test"
27-
TestAssert "card created", there is a card"test"
27+
TestAssert "card created", there is a card "test"
2828
end TestCreateCard
2929

3030
on TestCreateEPS
3131
create EPS "test"
32-
TestAssert "EPS created", there is a EPS"test"
32+
TestAssert "EPS created", there is a EPS "test"
3333
end TestCreateEPS
3434

3535
on TestCreateField
3636
create field "test"
37-
TestAssert "field created", there is a field"test"
37+
TestAssert "field created", there is a field "test"
3838
end TestCreateField
3939

4040
on TestCreateGraphic
4141
create graphic "test"
42-
TestAssert "graphic created", there is a graphic"test"
42+
TestAssert "graphic created", there is a graphic "test"
4343
end TestCreateGraphic
4444

4545
on TestCreateGroup
4646
create group "test"
47-
TestAssert "group created", there is a group"test"
47+
TestAssert "group created", there is a group "test"
4848
end TestCreateGroup
4949

5050
on TestCreateImage
5151
create image "test"
52-
TestAssert "image created", there is a image"test"
52+
TestAssert "image created", there is a image "test"
5353
end TestCreateImage
5454

5555
on TestCreatePlayer
5656
create player "test"
57-
TestAssert "player created", there is a player"test"
57+
TestAssert "player created", there is a player "test"
5858
end TestCreatePlayer
5959

6060
on TestCreateScrollbar
6161
create scrollbar "test"
62-
TestAssert "scrollbar created", there is a scrollbar"test"
62+
TestAssert "scrollbar created", there is a scrollbar "test"
6363
end TestCreateScrollbar
6464

6565
on TestCreateStack
6666
create stack "test"
67-
TestAssert "stack created", there is a stack"test"
67+
TestAssert "stack created", there is a stack "test"
6868
end TestCreateStack
6969

7070
constant kIsA_types = "array,boolean,color,date,integer,number,point,rect,ascii string"

0 commit comments

Comments
 (0)