OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 // Test for named parameter with the name of a JavaScript property found on | 7 // Test for named parameter with the name of a JavaScript property found on |
8 // 'Object'. For such a NAME, foo.NAME may exist in an empty map, i.e. | 8 // 'Object'. For such a NAME, foo.NAME may exist in an empty map, i.e. |
9 // 'toString' in {} --> true. | 9 // 'toString' in {} --> true. |
10 | 10 |
11 | |
12 main() { | 11 main() { |
13 // Test properties found on instances of Object in Chrome 15 and Firefox 6. | 12 // Test properties found on instances of Object in Chrome 15 and Firefox 6. |
14 test_constructor(); | 13 test_constructor(); |
15 test_hasOwnProperty(); | 14 test_hasOwnProperty(); |
16 test_isPrototypeOf(); | 15 test_isPrototypeOf(); |
17 test_propertyIsEnumerable(); | 16 test_propertyIsEnumerable(); |
18 test_toSource(); | 17 test_toSource(); |
19 test_toLocaleString(); | 18 test_toLocaleString(); |
20 test_toString(); | 19 test_toString(); |
21 test_unwatch(); | 20 test_unwatch(); |
22 test_valueOf(); | 21 test_valueOf(); |
23 test_watch(); | 22 test_watch(); |
24 } | 23 } |
25 | 24 |
26 // 'constructor' property. | 25 // 'constructor' property. |
27 | 26 |
28 class TestClass_constructor { | 27 class TestClass_constructor { |
29 method({constructor}) => constructor; | 28 method({constructor}) => constructor; |
30 static staticMethod({constructor}) => constructor; | 29 static staticMethod({constructor}) => constructor; |
31 } | 30 } |
| 31 |
32 globalMethod_constructor({constructor}) => constructor; | 32 globalMethod_constructor({constructor}) => constructor; |
33 | 33 |
34 test_constructor() { | 34 test_constructor() { |
35 var obj = new TestClass_constructor(); | 35 var obj = new TestClass_constructor(); |
36 | 36 |
37 Expect.equals(null, obj.method()); | 37 Expect.equals(null, obj.method()); |
38 Expect.equals(0, obj.method(constructor: 0)); | 38 Expect.equals(0, obj.method(constructor: 0)); |
39 | 39 |
40 Expect.equals(null, TestClass_constructor.staticMethod()); | 40 Expect.equals(null, TestClass_constructor.staticMethod()); |
41 Expect.equals(0, TestClass_constructor.staticMethod(constructor: 0)); | 41 Expect.equals(0, TestClass_constructor.staticMethod(constructor: 0)); |
42 | 42 |
43 Expect.equals(null, globalMethod_constructor()); | 43 Expect.equals(null, globalMethod_constructor()); |
44 Expect.equals(0, globalMethod_constructor(constructor: 0)); | 44 Expect.equals(0, globalMethod_constructor(constructor: 0)); |
45 } | 45 } |
46 | 46 |
47 // 'hasOwnProperty' property. | 47 // 'hasOwnProperty' property. |
48 | 48 |
49 class TestClass_hasOwnProperty { | 49 class TestClass_hasOwnProperty { |
50 method({hasOwnProperty}) => hasOwnProperty; | 50 method({hasOwnProperty}) => hasOwnProperty; |
51 static staticMethod({hasOwnProperty}) => hasOwnProperty; | 51 static staticMethod({hasOwnProperty}) => hasOwnProperty; |
52 } | 52 } |
| 53 |
53 globalMethod_hasOwnProperty({hasOwnProperty}) => hasOwnProperty; | 54 globalMethod_hasOwnProperty({hasOwnProperty}) => hasOwnProperty; |
54 | 55 |
55 test_hasOwnProperty() { | 56 test_hasOwnProperty() { |
56 var obj = new TestClass_hasOwnProperty(); | 57 var obj = new TestClass_hasOwnProperty(); |
57 | 58 |
58 Expect.equals(null, obj.method()); | 59 Expect.equals(null, obj.method()); |
59 Expect.equals(0, obj.method(hasOwnProperty: 0)); | 60 Expect.equals(0, obj.method(hasOwnProperty: 0)); |
60 | 61 |
61 Expect.equals(null, TestClass_hasOwnProperty.staticMethod()); | 62 Expect.equals(null, TestClass_hasOwnProperty.staticMethod()); |
62 Expect.equals(0, TestClass_hasOwnProperty.staticMethod(hasOwnProperty: 0)); | 63 Expect.equals(0, TestClass_hasOwnProperty.staticMethod(hasOwnProperty: 0)); |
63 | 64 |
64 Expect.equals(null, globalMethod_hasOwnProperty()); | 65 Expect.equals(null, globalMethod_hasOwnProperty()); |
65 Expect.equals(0, globalMethod_hasOwnProperty(hasOwnProperty: 0)); | 66 Expect.equals(0, globalMethod_hasOwnProperty(hasOwnProperty: 0)); |
66 } | 67 } |
67 | 68 |
68 // 'isPrototypeOf' property. | 69 // 'isPrototypeOf' property. |
69 | 70 |
70 class TestClass_isPrototypeOf { | 71 class TestClass_isPrototypeOf { |
71 method({isPrototypeOf}) => isPrototypeOf; | 72 method({isPrototypeOf}) => isPrototypeOf; |
72 static staticMethod({isPrototypeOf}) => isPrototypeOf; | 73 static staticMethod({isPrototypeOf}) => isPrototypeOf; |
73 } | 74 } |
| 75 |
74 globalMethod_isPrototypeOf({isPrototypeOf}) => isPrototypeOf; | 76 globalMethod_isPrototypeOf({isPrototypeOf}) => isPrototypeOf; |
75 | 77 |
76 test_isPrototypeOf() { | 78 test_isPrototypeOf() { |
77 var obj = new TestClass_isPrototypeOf(); | 79 var obj = new TestClass_isPrototypeOf(); |
78 | 80 |
79 Expect.equals(null, obj.method()); | 81 Expect.equals(null, obj.method()); |
80 Expect.equals(0, obj.method(isPrototypeOf: 0)); | 82 Expect.equals(0, obj.method(isPrototypeOf: 0)); |
81 | 83 |
82 Expect.equals(null, TestClass_isPrototypeOf.staticMethod()); | 84 Expect.equals(null, TestClass_isPrototypeOf.staticMethod()); |
83 Expect.equals(0, TestClass_isPrototypeOf.staticMethod(isPrototypeOf: 0)); | 85 Expect.equals(0, TestClass_isPrototypeOf.staticMethod(isPrototypeOf: 0)); |
84 | 86 |
85 Expect.equals(null, globalMethod_isPrototypeOf()); | 87 Expect.equals(null, globalMethod_isPrototypeOf()); |
86 Expect.equals(0, globalMethod_isPrototypeOf(isPrototypeOf: 0)); | 88 Expect.equals(0, globalMethod_isPrototypeOf(isPrototypeOf: 0)); |
87 } | 89 } |
88 | 90 |
89 // 'propertyIsEnumerable' property. | 91 // 'propertyIsEnumerable' property. |
90 | 92 |
91 class TestClass_propertyIsEnumerable { | 93 class TestClass_propertyIsEnumerable { |
92 method({propertyIsEnumerable}) => propertyIsEnumerable; | 94 method({propertyIsEnumerable}) => propertyIsEnumerable; |
93 static staticMethod({propertyIsEnumerable}) => propertyIsEnumerable; | 95 static staticMethod({propertyIsEnumerable}) => propertyIsEnumerable; |
94 } | 96 } |
95 globalMethod_propertyIsEnumerable({propertyIsEnumerable}) => propertyIsEnumerabl
e; | 97 |
| 98 globalMethod_propertyIsEnumerable({propertyIsEnumerable}) => |
| 99 propertyIsEnumerable; |
96 | 100 |
97 test_propertyIsEnumerable() { | 101 test_propertyIsEnumerable() { |
98 var obj = new TestClass_propertyIsEnumerable(); | 102 var obj = new TestClass_propertyIsEnumerable(); |
99 | 103 |
100 Expect.equals(null, obj.method()); | 104 Expect.equals(null, obj.method()); |
101 Expect.equals(0, obj.method(propertyIsEnumerable: 0)); | 105 Expect.equals(0, obj.method(propertyIsEnumerable: 0)); |
102 | 106 |
103 Expect.equals(null, TestClass_propertyIsEnumerable.staticMethod()); | 107 Expect.equals(null, TestClass_propertyIsEnumerable.staticMethod()); |
104 Expect.equals(0, TestClass_propertyIsEnumerable.staticMethod(propertyIsEnumera
ble: 0)); | 108 Expect.equals( |
| 109 0, TestClass_propertyIsEnumerable.staticMethod(propertyIsEnumerable: 0)); |
105 | 110 |
106 Expect.equals(null, globalMethod_propertyIsEnumerable()); | 111 Expect.equals(null, globalMethod_propertyIsEnumerable()); |
107 Expect.equals(0, globalMethod_propertyIsEnumerable(propertyIsEnumerable: 0)); | 112 Expect.equals(0, globalMethod_propertyIsEnumerable(propertyIsEnumerable: 0)); |
108 } | 113 } |
109 | 114 |
110 // 'toSource' property. | 115 // 'toSource' property. |
111 | 116 |
112 class TestClass_toSource { | 117 class TestClass_toSource { |
113 method({toSource}) => toSource; | 118 method({toSource}) => toSource; |
114 static staticMethod({toSource}) => toSource; | 119 static staticMethod({toSource}) => toSource; |
115 } | 120 } |
| 121 |
116 globalMethod_toSource({toSource}) => toSource; | 122 globalMethod_toSource({toSource}) => toSource; |
117 | 123 |
118 test_toSource() { | 124 test_toSource() { |
119 var obj = new TestClass_toSource(); | 125 var obj = new TestClass_toSource(); |
120 | 126 |
121 Expect.equals(null, obj.method()); | 127 Expect.equals(null, obj.method()); |
122 Expect.equals(0, obj.method(toSource: 0)); | 128 Expect.equals(0, obj.method(toSource: 0)); |
123 | 129 |
124 Expect.equals(null, TestClass_toSource.staticMethod()); | 130 Expect.equals(null, TestClass_toSource.staticMethod()); |
125 Expect.equals(0, TestClass_toSource.staticMethod(toSource: 0)); | 131 Expect.equals(0, TestClass_toSource.staticMethod(toSource: 0)); |
126 | 132 |
127 Expect.equals(null, globalMethod_toSource()); | 133 Expect.equals(null, globalMethod_toSource()); |
128 Expect.equals(0, globalMethod_toSource(toSource: 0)); | 134 Expect.equals(0, globalMethod_toSource(toSource: 0)); |
129 } | 135 } |
130 | 136 |
131 // 'toLocaleString' property. | 137 // 'toLocaleString' property. |
132 | 138 |
133 class TestClass_toLocaleString { | 139 class TestClass_toLocaleString { |
134 method({toLocaleString}) => toLocaleString; | 140 method({toLocaleString}) => toLocaleString; |
135 static staticMethod({toLocaleString}) => toLocaleString; | 141 static staticMethod({toLocaleString}) => toLocaleString; |
136 } | 142 } |
| 143 |
137 globalMethod_toLocaleString({toLocaleString}) => toLocaleString; | 144 globalMethod_toLocaleString({toLocaleString}) => toLocaleString; |
138 | 145 |
139 test_toLocaleString() { | 146 test_toLocaleString() { |
140 var obj = new TestClass_toLocaleString(); | 147 var obj = new TestClass_toLocaleString(); |
141 | 148 |
142 Expect.equals(null, obj.method()); | 149 Expect.equals(null, obj.method()); |
143 Expect.equals(0, obj.method(toLocaleString: 0)); | 150 Expect.equals(0, obj.method(toLocaleString: 0)); |
144 | 151 |
145 Expect.equals(null, TestClass_toLocaleString.staticMethod()); | 152 Expect.equals(null, TestClass_toLocaleString.staticMethod()); |
146 Expect.equals(0, TestClass_toLocaleString.staticMethod(toLocaleString: 0)); | 153 Expect.equals(0, TestClass_toLocaleString.staticMethod(toLocaleString: 0)); |
147 | 154 |
148 Expect.equals(null, globalMethod_toLocaleString()); | 155 Expect.equals(null, globalMethod_toLocaleString()); |
149 Expect.equals(0, globalMethod_toLocaleString(toLocaleString: 0)); | 156 Expect.equals(0, globalMethod_toLocaleString(toLocaleString: 0)); |
150 } | 157 } |
151 | 158 |
152 // 'toString' property. | 159 // 'toString' property. |
153 | 160 |
154 class TestClass_toString { | 161 class TestClass_toString { |
155 method({toString}) => toString; | 162 method({toString}) => toString; |
156 static staticMethod({toString}) => toString; | 163 static staticMethod({toString}) => toString; |
157 } | 164 } |
| 165 |
158 globalMethod_toString({toString}) => toString; | 166 globalMethod_toString({toString}) => toString; |
159 | 167 |
160 test_toString() { | 168 test_toString() { |
161 var obj = new TestClass_toString(); | 169 var obj = new TestClass_toString(); |
162 | 170 |
163 Expect.equals(null, obj.method()); | 171 Expect.equals(null, obj.method()); |
164 Expect.equals(0, obj.method(toString: 0)); | 172 Expect.equals(0, obj.method(toString: 0)); |
165 | 173 |
166 Expect.equals(null, TestClass_toString.staticMethod()); | 174 Expect.equals(null, TestClass_toString.staticMethod()); |
167 Expect.equals(0, TestClass_toString.staticMethod(toString: 0)); | 175 Expect.equals(0, TestClass_toString.staticMethod(toString: 0)); |
168 | 176 |
169 Expect.equals(null, globalMethod_toString()); | 177 Expect.equals(null, globalMethod_toString()); |
170 Expect.equals(0, globalMethod_toString(toString: 0)); | 178 Expect.equals(0, globalMethod_toString(toString: 0)); |
171 } | 179 } |
172 | 180 |
173 // 'unwatch' property. | 181 // 'unwatch' property. |
174 | 182 |
175 class TestClass_unwatch { | 183 class TestClass_unwatch { |
176 method({unwatch}) => unwatch; | 184 method({unwatch}) => unwatch; |
177 static staticMethod({unwatch}) => unwatch; | 185 static staticMethod({unwatch}) => unwatch; |
178 } | 186 } |
| 187 |
179 globalMethod_unwatch({unwatch}) => unwatch; | 188 globalMethod_unwatch({unwatch}) => unwatch; |
180 | 189 |
181 test_unwatch() { | 190 test_unwatch() { |
182 var obj = new TestClass_unwatch(); | 191 var obj = new TestClass_unwatch(); |
183 | 192 |
184 Expect.equals(null, obj.method()); | 193 Expect.equals(null, obj.method()); |
185 Expect.equals(0, obj.method(unwatch: 0)); | 194 Expect.equals(0, obj.method(unwatch: 0)); |
186 | 195 |
187 Expect.equals(null, TestClass_unwatch.staticMethod()); | 196 Expect.equals(null, TestClass_unwatch.staticMethod()); |
188 Expect.equals(0, TestClass_unwatch.staticMethod(unwatch: 0)); | 197 Expect.equals(0, TestClass_unwatch.staticMethod(unwatch: 0)); |
189 | 198 |
190 Expect.equals(null, globalMethod_unwatch()); | 199 Expect.equals(null, globalMethod_unwatch()); |
191 Expect.equals(0, globalMethod_unwatch(unwatch: 0)); | 200 Expect.equals(0, globalMethod_unwatch(unwatch: 0)); |
192 } | 201 } |
193 | 202 |
194 // 'valueOf' property. | 203 // 'valueOf' property. |
195 | 204 |
196 class TestClass_valueOf { | 205 class TestClass_valueOf { |
197 method({valueOf}) => valueOf; | 206 method({valueOf}) => valueOf; |
198 static staticMethod({valueOf}) => valueOf; | 207 static staticMethod({valueOf}) => valueOf; |
199 } | 208 } |
| 209 |
200 globalMethod_valueOf({valueOf}) => valueOf; | 210 globalMethod_valueOf({valueOf}) => valueOf; |
201 | 211 |
202 test_valueOf() { | 212 test_valueOf() { |
203 var obj = new TestClass_valueOf(); | 213 var obj = new TestClass_valueOf(); |
204 | 214 |
205 Expect.equals(null, obj.method()); | 215 Expect.equals(null, obj.method()); |
206 Expect.equals(0, obj.method(valueOf: 0)); | 216 Expect.equals(0, obj.method(valueOf: 0)); |
207 | 217 |
208 Expect.equals(null, TestClass_valueOf.staticMethod()); | 218 Expect.equals(null, TestClass_valueOf.staticMethod()); |
209 Expect.equals(0, TestClass_valueOf.staticMethod(valueOf: 0)); | 219 Expect.equals(0, TestClass_valueOf.staticMethod(valueOf: 0)); |
210 | 220 |
211 Expect.equals(null, globalMethod_valueOf()); | 221 Expect.equals(null, globalMethod_valueOf()); |
212 Expect.equals(0, globalMethod_valueOf(valueOf: 0)); | 222 Expect.equals(0, globalMethod_valueOf(valueOf: 0)); |
213 } | 223 } |
214 | 224 |
215 // 'watch' property. | 225 // 'watch' property. |
216 | 226 |
217 class TestClass_watch { | 227 class TestClass_watch { |
218 method({watch}) => watch; | 228 method({watch}) => watch; |
219 static staticMethod({watch}) => watch; | 229 static staticMethod({watch}) => watch; |
220 } | 230 } |
| 231 |
221 globalMethod_watch({watch}) => watch; | 232 globalMethod_watch({watch}) => watch; |
222 | 233 |
223 test_watch() { | 234 test_watch() { |
224 var obj = new TestClass_watch(); | 235 var obj = new TestClass_watch(); |
225 | 236 |
226 Expect.equals(null, obj.method()); | 237 Expect.equals(null, obj.method()); |
227 Expect.equals(0, obj.method(watch: 0)); | 238 Expect.equals(0, obj.method(watch: 0)); |
228 | 239 |
229 Expect.equals(null, TestClass_watch.staticMethod()); | 240 Expect.equals(null, TestClass_watch.staticMethod()); |
230 Expect.equals(0, TestClass_watch.staticMethod(watch: 0)); | 241 Expect.equals(0, TestClass_watch.staticMethod(watch: 0)); |
231 | 242 |
232 Expect.equals(null, globalMethod_watch()); | 243 Expect.equals(null, globalMethod_watch()); |
233 Expect.equals(0, globalMethod_watch(watch: 0)); | 244 Expect.equals(0, globalMethod_watch(watch: 0)); |
234 } | 245 } |
OLD | NEW |