| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // This test reflectively enumerates all the methods in the system and tries to | 5 // This test reflectively enumerates all the methods in the system and tries to |
| 6 // invoke them with various basic values (nulls, ints, etc). This may result in | 6 // invoke them with various basic values (nulls, ints, etc). This may result in |
| 7 // Dart exceptions or hangs, but should never result in crashes or JavaScript | 7 // Dart exceptions or hangs, but should never result in crashes or JavaScript |
| 8 // exceptions. | 8 // exceptions. |
| 9 | 9 |
| 10 library test.invoke_natives; | 10 library test.invoke_natives; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 () => target.setField(m.simpleName, null); | 89 () => target.setField(m.simpleName, null); |
| 90 } else if (m.isConstructor) { | 90 } else if (m.isConstructor) { |
| 91 return; | 91 return; |
| 92 } else { | 92 } else { |
| 93 throw "Unexpected method kind"; | 93 throw "Unexpected method kind"; |
| 94 } | 94 } |
| 95 | 95 |
| 96 queue.add(task); | 96 queue.add(task); |
| 97 } | 97 } |
| 98 | 98 |
| 99 checkField(VariableMirror v, ObjectMirror target, [origin]) { |
| 100 if (isBlacklisted(v.qualifiedName)) return; |
| 101 |
| 102 var task = new Task(); |
| 103 task.name = '${MirrorSystem.getName(v.qualifiedName)} from $origin'; |
| 104 |
| 105 task.action = () => target.getField(v.simpleName); |
| 106 |
| 107 queue.add(task); |
| 108 } |
| 109 |
| 99 checkInstance(instanceMirror, origin) { | 110 checkInstance(instanceMirror, origin) { |
| 100 ClassMirror klass = instanceMirror.type; | 111 ClassMirror klass = instanceMirror.type; |
| 101 while (klass != null) { | 112 while (klass != null) { |
| 102 instanceMirror.type.declarations.values | 113 instanceMirror.type.declarations.values |
| 103 .where((d) => d is MethodMirror && !d.isStatic) | 114 .where((d) => d is MethodMirror && !d.isStatic) |
| 104 .forEach((m) => checkMethod(m, instanceMirror, origin)); | 115 .forEach((m) => checkMethod(m, instanceMirror, origin)); |
| 116 instanceMirror.type.declarations.values |
| 117 .where((d) => d is VariableMirror) |
| 118 .forEach((v) => checkField(v, instanceMirror, origin)); |
| 105 klass = klass.superclass; | 119 klass = klass.superclass; |
| 106 } | 120 } |
| 107 } | 121 } |
| 108 | 122 |
| 109 checkClass(classMirror) { | 123 checkClass(classMirror) { |
| 110 classMirror.declarations.values | 124 classMirror.declarations.values |
| 111 .where((d) => d is MethodMirror && d.isStatic) | 125 .where((d) => d is MethodMirror && d.isStatic) |
| 112 .forEach((m) => checkMethod(m, classMirror)); | 126 .forEach((m) => checkMethod(m, classMirror)); |
| 113 | 127 |
| 114 classMirror.declarations.values | 128 classMirror.declarations.values |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 fuzzArgument = false; /// false: ok | 184 fuzzArgument = false; /// false: ok |
| 171 fuzzArgument = 'string'; /// string: ok | 185 fuzzArgument = 'string'; /// string: ok |
| 172 fuzzArgument = new List(0); /// emptyarray: ok | 186 fuzzArgument = new List(0); /// emptyarray: ok |
| 173 | 187 |
| 174 print('Fuzzing with $fuzzArgument'); | 188 print('Fuzzing with $fuzzArgument'); |
| 175 | 189 |
| 176 currentMirrorSystem().libraries.values.forEach(checkLibrary); | 190 currentMirrorSystem().libraries.values.forEach(checkLibrary); |
| 177 | 191 |
| 178 var valueObjects = | 192 var valueObjects = |
| 179 [true, false, null, [], {}, dynamic, | 193 [true, false, null, [], {}, dynamic, |
| 180 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 3.14159, | 194 0, 0xEFFFFFF, 0xFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 3.14159, () {}, |
| 181 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ', "\u{1D11E}", #symbol]; | 195 "foo", 'blåbærgrød', 'Îñţérñåţîöñåļîžåţîờñ', "\u{1D11E}", #symbol]; |
| 182 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object')); | 196 valueObjects.forEach((v) => checkInstance(reflect(v), 'value object')); |
| 183 | 197 |
| 184 uncaughtErrorHandler(self, parent, zone, error, stack) {}; | 198 uncaughtErrorHandler(self, parent, zone, error, stack) {}; |
| 185 var zoneSpec = | 199 var zoneSpec = |
| 186 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler); | 200 new ZoneSpecification(handleUncaughtError: uncaughtErrorHandler); |
| 187 testZone = Zone.current.fork(specification: zoneSpec); | 201 testZone = Zone.current.fork(specification: zoneSpec); |
| 188 testZone.createTimer(Duration.ZERO, doOneTask); | 202 testZone.createTimer(Duration.ZERO, doOneTask); |
| 189 } | 203 } |
| OLD | NEW |