| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library isolate_class_list_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'test_helper.dart'; |
| 9 import 'package:expect/expect.dart'; |
| 10 |
| 11 class BananaClassTest { |
| 12 int port; |
| 13 int isolate_id; |
| 14 int class_id; |
| 15 BananaClassTest(this.port, this.isolate_id, this.class_id); |
| 16 |
| 17 _testFieldA(Map field) { |
| 18 Expect.equals('Field', field['type']); |
| 19 Expect.equals('a', field['user_name']); |
| 20 Expect.equals('a', field['name']); |
| 21 Expect.equals(false, field['final']); |
| 22 Expect.equals(false, field['static']); |
| 23 Expect.equals(false, field['const']); |
| 24 Expect.equals('dynamic', field['guard_class']); |
| 25 Expect.equals(true, field['guard_nullable']); |
| 26 Expect.equals('variable', field['guard_length']); |
| 27 } |
| 28 |
| 29 _testFieldFinalFixedLengthList(Map field) { |
| 30 Expect.equals('Field', field['type']); |
| 31 Expect.equals('final_fixed_length_list', field['user_name']); |
| 32 Expect.equals('final_fixed_length_list', field['name']); |
| 33 Expect.equals('Float32List', field['guard_class']['user_name']); |
| 34 Expect.equals(true, field['final']); |
| 35 Expect.equals(false, field['static']); |
| 36 Expect.equals(false, field['const']); |
| 37 Expect.equals(4, field['guard_length']); |
| 38 } |
| 39 |
| 40 _testFieldFixedLengthList(Map field) { |
| 41 Expect.equals('Field', field['type']); |
| 42 Expect.equals('fixed_length_list', field['user_name']); |
| 43 Expect.equals('fixed_length_list', field['name']); |
| 44 Expect.equals(false, field['final']); |
| 45 Expect.equals(false, field['static']); |
| 46 Expect.equals(false, field['const']); |
| 47 Expect.equals('Float32List', field['guard_class']['user_name']); |
| 48 Expect.equals('variable', field['guard_length']); |
| 49 } |
| 50 |
| 51 _testFieldName(Map field) { |
| 52 Expect.equals('Field', field['type']); |
| 53 Expect.equals('name', field['user_name']); |
| 54 Expect.equals('name', field['name']); |
| 55 Expect.equals(false, field['final']); |
| 56 Expect.equals(false, field['static']); |
| 57 Expect.equals(false, field['const']); |
| 58 Expect.equals('String', field['guard_class']['user_name']); |
| 59 Expect.equals(false, field['guard_nullable']); |
| 60 Expect.equals('variable', field['guard_length']); |
| 61 } |
| 62 |
| 63 Future makeRequest() { |
| 64 var fields = ['final_fixed_length_list', 'fixed_length_list', 'name', 'a']; |
| 65 var helper = |
| 66 new ClassFieldRequestHelper(port, isolate_id, class_id, fields); |
| 67 return helper.makeRequest().then((_) { |
| 68 _testFieldA(helper.fields['a']); |
| 69 _testFieldFinalFixedLengthList(helper.fields['final_fixed_length_list']); |
| 70 _testFieldFixedLengthList(helper.fields['fixed_length_list']); |
| 71 _testFieldName(helper.fields['name']); |
| 72 }); |
| 73 } |
| 74 } |
| 75 |
| 76 class BadBananaClassTest { |
| 77 int port; |
| 78 int isolate_id; |
| 79 int class_id; |
| 80 BadBananaClassTest(this.port, this.isolate_id, this.class_id); |
| 81 |
| 82 _testFieldV(Map field) { |
| 83 Expect.equals('Field', field['type']); |
| 84 Expect.equals('v', field['user_name']); |
| 85 Expect.equals('v', field['name']); |
| 86 Expect.equals(false, field['final']); |
| 87 Expect.equals(false, field['static']); |
| 88 Expect.equals(false, field['const']); |
| 89 Expect.equals('double', field['guard_class']['user_name']); |
| 90 Expect.equals(true, field['guard_nullable']); |
| 91 Expect.equals('variable', field['guard_length']); |
| 92 } |
| 93 |
| 94 _testFieldC(Map field) { |
| 95 Expect.equals('Field', field['type']); |
| 96 Expect.equals('c', field['user_name']); |
| 97 Expect.equals('c', field['name']); |
| 98 Expect.equals(true, field['final']); |
| 99 Expect.equals(false, field['static']); |
| 100 Expect.equals(true, field['const']); |
| 101 Expect.equals('int', field['guard_class']['user_name']); |
| 102 Expect.equals(false, field['guard_nullable']); |
| 103 Expect.equals('variable', field['guard_length']); |
| 104 } |
| 105 |
| 106 _testFieldFinalFixedLengthList(Map field) { |
| 107 Expect.equals('Field', field['type']); |
| 108 Expect.equals('final_fixed_length_list', field['user_name']); |
| 109 Expect.equals('final_fixed_length_list', field['name']); |
| 110 Expect.equals('Float32List', field['guard_class']['user_name']); |
| 111 Expect.equals(true, field['final']); |
| 112 Expect.equals(false, field['static']); |
| 113 Expect.equals(false, field['const']); |
| 114 Expect.equals('variable', field['guard_length']); |
| 115 } |
| 116 |
| 117 _testFieldFixedLengthArray(Map field) { |
| 118 Expect.equals('Field', field['type']); |
| 119 Expect.equals('fixed_length_array', field['user_name']); |
| 120 Expect.equals('fixed_length_array', field['name']); |
| 121 Expect.equals('List', field['guard_class']['user_name']); |
| 122 Expect.equals(true, field['final']); |
| 123 Expect.equals(false, field['static']); |
| 124 Expect.equals(false, field['const']); |
| 125 Expect.equals(3, field['guard_length']); |
| 126 } |
| 127 |
| 128 Future makeRequest() { |
| 129 var fields = ['final_fixed_length_list', 'fixed_length_array', 'v', 'c']; |
| 130 var helper = |
| 131 new ClassFieldRequestHelper(port, isolate_id, class_id, fields); |
| 132 return helper.makeRequest().then((_) { |
| 133 _testFieldV(helper.fields['v']); |
| 134 _testFieldC(helper.fields['c']); |
| 135 _testFieldFinalFixedLengthList(helper.fields['final_fixed_length_list']); |
| 136 _testFieldFixedLengthArray(helper.fields['fixed_length_array']); |
| 137 }); |
| 138 } |
| 139 } |
| 140 |
| 141 class ClassTableTest extends VmServiceRequestHelper { |
| 142 ClassTableTest(port, id) : |
| 143 super('http://127.0.0.1:$port/isolates/$id/classes/'); |
| 144 |
| 145 int banana_class_id; |
| 146 int bad_banana_class_id; |
| 147 |
| 148 onRequestCompleted(Map reply) { |
| 149 ClassTableHelper helper = new ClassTableHelper(reply); |
| 150 Expect.isTrue(helper.classExists('Banana')); |
| 151 banana_class_id = helper.classId('Banana'); |
| 152 Expect.isTrue(helper.classExists('BadBanana')); |
| 153 bad_banana_class_id = helper.classId('BadBanana'); |
| 154 } |
| 155 } |
| 156 |
| 157 class IsolateListTest extends VmServiceRequestHelper { |
| 158 IsolateListTest(port) : super('http://127.0.0.1:$port/isolates'); |
| 159 |
| 160 int _isolateId; |
| 161 onRequestCompleted(Map reply) { |
| 162 IsolateListTester tester = new IsolateListTester(reply); |
| 163 tester.checkIsolateCount(1); |
| 164 tester.checkIsolateNameContains('field_script.dart'); |
| 165 _isolateId = tester.checkIsolateNameContains('field_script'); |
| 166 } |
| 167 } |
| 168 |
| 169 main() { |
| 170 var process = new TestLauncher('field_script.dart'); |
| 171 process.launch().then((port) { |
| 172 var test = new IsolateListTest(port); |
| 173 test.makeRequest().then((_) { |
| 174 var classTableTest = new ClassTableTest(port, test._isolateId); |
| 175 classTableTest.makeRequest().then((_) { |
| 176 var bananaClassTest = |
| 177 new BananaClassTest(port, test._isolateId, |
| 178 classTableTest.banana_class_id); |
| 179 var badBananaClassTest = |
| 180 new BadBananaClassTest(port, test._isolateId, |
| 181 classTableTest.bad_banana_class_id); |
| 182 Future.wait([bananaClassTest.makeRequest(), |
| 183 badBananaClassTest.makeRequest()]).then((_) { |
| 184 process.requestExit(); |
| 185 }); |
| 186 }); |
| 187 }); |
| 188 }); |
| 189 } |
| OLD | NEW |