-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy path004_object.xml
More file actions
279 lines (204 loc) · 5.32 KB
/
004_object.xml
File metadata and controls
279 lines (204 loc) · 5.32 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<?xml version="1.0" encoding="utf-8" ?>
<!--
/*****************************************************************************
*
* ReoScript - .NET Script Language Engine
*
* https://github.com/unvell/ReoScript
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
* PURPOSE.
*
* This software released under MIT license.
* Copyright (c) 2012-2019 Jingwood, unvell.com, all rights reserved.
*
****************************************************************************/
-->
<test-suite id="004" name="object">
<test-case id="001">
<script>
var t = debug.assert;
var obj = { a : 10 };
t( obj != null );
t( obj.a == 10 );
obj.b = 20;
t( obj.b == 20 );
t( obj.a + obj.b == 30 );
</script>
</test-case>
<test-case id="002">
<script>
var t = debug.assert;
var obj = { a : 10, b: 20, 'c': 30 };
var s = '';
for (key in obj) {
if (key == 'a' || key =='b' || key=='c') {
if (s.length>0) s += ', ';
s += key;
}
}
t( s == "a, b, c" );
</script>
</test-case>
<test-case id="003" name="index access">
<script>
var t = debug.assert;
var obj = { a : 10, b: 20, 'c': 30 };
t( obj['a'] == 10 );
t( obj['b'] == 20 );
t( obj['c'] == 30 );
var key = 'd';
obj[key] = obj.a - obj.b;
t( obj.d == -10 );
</script>
</test-case>
<test-case id="004" name="standard iterator">
<script>
var t = debug.assert;
function dump(obj) {
var o = '';
for (key in obj){
if (o.length>0) o += ', ';
o += key;
}
return o;
}
var obj = { a : 10, b: 20, 'c': 30 };
t(dump(obj) == 'a, b, c');
obj += { d: 40 };
t(dump(obj) == 'a, b, c, d');
</script>
</test-case>
<test-case id="010" name="new">
<script>
var t = debug.assert;
function A() {
this.a = 10;
}
t( new A().a == 10 );
</script>
</test-case>
<test-case id="011" desc="initializer">
<script>
var t = debug.assert;
function A() {
this.a = 10;
}
var a = new A() {
b : 20,
};
t( a.a == 10 );
t( a.b == 20 );
</script>
</test-case>
<test-case id="012">
<script>
var t = debug.assert;
function A() {
this.a = 10;
}
var obj = {
b: { Con: A },
};
var c = [null, obj];
var inst = new c[1].b.Con();
t( inst != null );
t( inst.a == 10 );
</script>
</test-case>
<test-case id="013" name="combine">
<script>
var t = debug.assert;
var a = { x: 10 };
var b = { y: 20 };
var c = a + b;
t( c.x == 10 );
t( c.y == 20 );
var d = { z: 3.14 };
t( (a + b + d).z == 3.14 );
var e = a;
e += d;
t( e.z == 3.14 );
</script>
</test-case>
<test-case id="014" name="toString">
<script>
var t = debug.assert;
t( new Object(), "[object Object]" );
</script>
</test-case>
<test-case id="015" name="toString" disabled="1">
<!-- Not supported yet -->
<script>
var t = debug.assert;
var obj = new Object();
obj.toString = () => "my object";
t( obj, "my object" );
</script>
</test-case>
<test-case id="020" name="delete property">
<script>
var t = debug.assert;
var a = { hello: 'world', b:function() {} };
t( a.hello != null );
t( a.b != 10 );
delete a.hello;
t( a.hello == null );
delete a.b;
t( a.b == null );
</script>
</test-case>
<test-case id="021" name="delete property in iteration">
<script>
var t = debug.assert;
var obj = { a:10, b:20, c:30, d:40 };
for (key in obj) {
if (key == 'b')
delete obj.c;
}
t( obj != null );
t( obj.a == 10 );
t( obj.b == 20 );
t( obj.c == null );
t( obj.d == 40 );
</script>
</test-case>
<test-case id="022" name="delete non-own property">
<script>
var t = debug.assert;
var obj = {};
t( obj != null );
t( obj.hasOwnProperty != null );
t( obj.hasOwnProperty('hasOwnProperty') == false );
obj.removeOwnProperty('hasOwnProperty');
t( obj.hasOwnProperty != null );
t( obj.hasOwnProperty('hasOwnProperty') == false );
</script>
</test-case>
<test-case id="100" name="enum">
<script>
var t = debug.assert;
var ButtonState = {
Disabled: 0x1,
Hidden: 0x2,
Focus: 0x4,
Hover: 0x8,
Pressed: 0x10,
};
var status = ButtonState.Focus | ButtonState.Hover | ButtonState.Pressed;
t( (status & ButtonState.Hover), ButtonState.Hover );
</script>
</test-case>
<test-case id="200" name="namespace">
<script>
var t = debug.assert;
var name1 = { User: function() {} };
t( name1 != null );
t( name1.User != null );
var user1 = new name1.User();
t( user1 != null );
</script>
</test-case>
</test-suite>