forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatterns.livecodescript
More file actions
164 lines (143 loc) · 4.88 KB
/
Copy pathpatterns.livecodescript
File metadata and controls
164 lines (143 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
script "CoreGraphicsPatterns"
/*
Copyright (C) 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
on TestSetup
TestSkipIfNot "ide"
get the long id of stack (TestGetIDERepositoryPath() & "/Toolset/palettes/revicons.rev")
end TestSetup
on TestPatternExistence
local tPattern
-- patternNumbers 1 to 164 are id 137 to 300
local tPI_PATTERNS = 136
repeat with tPattern = 1 to 164
resolve image id tPattern+tPI_PATTERNS relative to me
if not (tPattern+tPI_PATTERNS >= 241 and tPattern+tPI_PATTERNS <= 250) and tPattern+tPI_PATTERNS < 282 then
TestAssert "patternNumber" && tPattern && "exists", it is not empty
set the brushPattern to tPattern
TestAssert "patternNumber" && tPattern && "round trips", the brushPattern is tPattern
else
TestAssert "patternNumber" && tPattern && "documented as unavailable", it is empty
TestAssertThrow "patternNumber" && tPattern && "unavailable", \
"SetPatternToNonExistantImage", the long id of me, \
"EE_PROPERTY_BRUSHPATNOIMAGE", tPattern
end if
end repeat
end TestPatternExistence
on SetPatternToNonExistantImage pPattern
set the brushPattern to pPattern
end SetPatternToNonExistantImage
on TestPatterns
local tPattern
repeat for each word tPattern in "brushPattern penPattern backdrop"
PatternTests tPattern, "global"
end repeat
-- object patterns
repeat for each word tPattern in "backPattern shadowPattern topPattern hilitePattern forePattern focusPattern bottomPattern borderPattern"
PatternTests tPattern, "object"
end repeat
end TestPatterns
on PatternTests pPattern, pType
local tUnsetValue
if pPattern is "backdrop" then
put "none" into tUnsetValue
end if
TestAssert pType && pPattern && "is initially empty", GetPattern(pPattern) is tUnsetValue
SetPattern pPattern, 100
TestAssert pType && pPattern && "round trips <= 164", GetPattern(pPattern) is 100
SetPattern pPattern, 0
TestAssert pType && pPattern && "0 == empty", GetPattern(pPattern) is tUnsetValue
SetPattern pPattern, 360
TestAssert pType && pPattern && "round trips > 300", GetPattern(pPattern) is 360
SetPattern pPattern, empty
TestAssert pType && pPattern && "set to empty", GetPattern(pPattern) is tUnsetValue
SetPattern pPattern, 200
TestAssert pType && pPattern && ">= 136 and <= 300 subtracts 136", GetPattern(pPattern) is 64
end PatternTests
on SetPattern pPattern, pValue
switch pPattern
case "backPattern"
set the backPattern of me to pValue
break
case "shadowPattern"
set the shadowPattern of me to pValue
break
case "topPattern"
set the topPattern of me to pValue
break
case "hilitePattern"
set the hilitePattern of me to pValue
break
case "forePattern"
set the forePattern of me to pValue
break
case "focusPattern"
set the focusPattern of me to pValue
break
case "bottomPattern"
set the bottomPattern of me to pValue
break
case "borderPattern"
set the borderPattern of me to pValue
break
case "penPattern"
set the penPattern to pValue
break
case "brushPattern"
set the brushPattern to pValue
break
case "backdrop"
set the backdrop to pValue
break
end switch
end SetPattern
function GetPattern pPattern
switch pPattern
case "backPattern"
return the backPattern of me
break
case "shadowPattern"
return the shadowPattern of me
break
case "topPattern"
return the topPattern of me
break
case "hilitePattern"
return the hilitePattern of me
break
case "forePattern"
return the forePattern of me
break
case "focusPattern"
return the focusPattern of me
break
case "bottomPattern"
return the bottomPattern of me
break
case "borderPattern"
return the borderPattern of me
break
case "penPattern"
return the penPattern
break
case "brushPattern"
return the brushPattern
case "backdrop"
return the backdrop
break
end switch
end GetPattern
on TestTeardown
if "StandaloneTestRunnerMainstack" is not among the lines of the mainstacks then
delete stack "revIcons"
end if
end TestTeardown