forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave.livecodescript
More file actions
194 lines (155 loc) · 6.23 KB
/
Copy pathsave.livecodescript
File metadata and controls
194 lines (155 loc) · 6.23 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
script "CoreFilesSave"
/*
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/>. */
constant kTestDirectory = "__CoreFilesSave"
constant kTestFile = "__CoreFilesSave/Save.livecode"
constant kVersions = "8.1:7000,8.0:7000,7.0:7000,5.5:5500,2.7:2700"
constant kVersionsWidget = "8.1:8100,8.0:8000,7.0:7000,5.5:5500,2.7:2700"
constant kVersionsBlockOverflow = "8.1:8100,8.0:8000,7.0:7000,5.5:5500,2.7:2700"
constant kMinVersion = "7.0"
constant kWidgetMinVersion = "8.0"
constant kBlockOverflowMinVersion = "8.1"
local sTestStack, sTestStackWidget, sTestStackBlockOverflow
command TestSetup
create folder kTestDirectory
create invisible stack "non-widget"
put it into sTestStack
create invisible stack "widget"
put it into sTestStackWidget
set the defaultstack to sTestStackWidget
TestLoadExtension "com.livecode.library.widgetutils" --required for clock
TestLoadExtension "com.livecode.widget.clock"
create widget as "com.livecode.widget.clock"
create invisible stack "block overflow"
put it into sTestStackBlockOverflow
set the defaultstack to sTestStackBlockOverflow
create field
local tText
repeat 40000 times
put "a" after tText
end repeat
set the text of field 1 to tText
end TestSetup
command TestTearDown
local tFile, tFolder
put the defaultfolder into tFolder
set the defaultfolder to kTestDirectory
repeat for each line tFile in the files
delete file tFile
end repeat
set the defaultfolder to tFolder
delete folder kTestDirectory
end TestTearDown
private command __TestStackFileHasFormat pVersion
local tActual, tExpected, tVersion
set the itemdelimiter to ":"
put item 1 of pVersion into tVersion
put "REVO" & item 2 of pVersion into tExpected
open file kTestFile for binary read
read from file kTestFile for 8 bytes
put it into tActual
close file kTestFile
TestAssert merge("stack file has version [[tVersion]]"), tActual is tExpected
TestDiagnostic merge("version was '[[tActual]]'")
end __TestStackFileHasFormat
private command __TestSaveAsFormat pStack, pVersion
local tVersion, tName
set the itemdelimiter to ":"
put item 1 of pVersion into tVersion
put the name of pStack into tName
save pStack as kTestFile with format tVersion
TestAssert merge("save [[tName]] stack file with version [[tVersion]]"), the result is empty
__TestStackFileHasFormat pVersion
end __TestSaveAsFormat
private command __TestSaveAsNewestFormat pStack, pVersion
local tName
put the name of pStack into tName
save pStack as kTestFile with newest format
TestAssert "save [[tName]] stack file with newest version", the result is empty
__TestStackFileHasFormat pVersion
end __TestSaveAsNewestFormat
private command __TestSaveAsGlobalFormat pStack, pVersion
local tVersion, tName
set the itemdelimiter to ":"
put item 1 of pVersion into tVersion
put the name of pStack into tName
set the stackfileversion to tVersion
save pStack as kTestFile
TestAssert merge("save [[tName]] stack file with version [[tVersion]]"), the result is empty
__TestStackFileHasFormat pVersion
end __TestSaveAsGlobalFormat
private command __TestSaveAsDefaultFormat pStack, pVersion
local tName
put the name of pStack into tName
save pStack as kTestFile
TestAssert merge("save [[tName]] stack file with default version"), the result is empty
__TestStackFileHasFormat pVersion
end __TestSaveAsDefaultFormat
private command __TestMinStackFileVersion pStack, pVersion
local tVersion, tName
set the itemdelimiter to ":"
put item 1 of pVersion into tVersion
put the short name of pStack into tName
TestAssert merge("stack [[tName]] has minStackFileVersion of [[tVersion]]"), the minStackFileVersion of pStack is tVersion
end __TestMinStackFileVersion
on TestSaveAsFormat
TestSkipIfNot "write"
local tVersion
set the itemdelimiter to ","
repeat for each item tVersion in kVersions
__TestSaveAsFormat sTestStack, tVersion
end repeat
repeat for each item tVersion in kVersionsWidget
__TestSaveAsFormat sTestStackWidget, tVersion
end repeat
repeat for each item tVersion in kVersionsBlockOverflow
__TestSaveAsFormat sTestStackBlockOverflow, tVersion
end repeat
end TestSaveAsFormat
on TestSaveAsNewestFormat
TestSkipIfNot "write"
local tVersion
set the itemdelimiter to ","
__TestSaveAsNewestFormat sTestStack, item 1 of kVersions
__TestSaveAsNewestFormat sTestStackWidget, item 1 of kVersionsWidget
__TestSaveAsNewestFormat sTestStackBlockOverflow, item 1 of kVersionsBlockOverflow
end TestSaveAsNewestFormat
on TestSaveAsGlobalFormat
TestSkipIfNot "write"
local tVersion
set the itemdelimiter to ","
repeat for each item tVersion in kVersions
__TestSaveAsGlobalFormat sTestStack, tVersion
end repeat
repeat for each item tVersion in kVersionsWidget
__TestSaveAsGlobalFormat sTestStackWidget, tVersion
end repeat
repeat for each item tVersion in kVersionsBlockOverflow
__TestSaveAsGlobalFormat sTestStackBlockOverflow, tVersion
end repeat
end TestSaveAsGlobalFormat
on TestSaveAsDefaultFormat
TestSkipIfNot "write"
local tVersion
set the itemdelimiter to ","
__TestSaveAsDefaultFormat sTestStack, item 1 of kVersions
__TestSaveAsDefaultFormat sTestStackWidget, item 1 of kVersionsWidget
__TestSaveAsDefaultFormat sTestStackBlockOverflow, item 1 of kVersionsBlockOverflow
end TestSaveAsDefaultFormat
on TestMinStackFileVersion
TestSkipIfNot "write"
set the itemdelimiter to ","
__TestMinStackFileVersion sTestStack, kMinVersion
__TestMinStackFileVersion sTestStackWidget, kWidgetMinVersion
__TestMinStackFileVersion sTestStackBlockOverflow, kBlockOverflowMinVersion
end TestMinStackFileVersion