Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Dart test program for testing serialization of messages. | 5 // Dart test program for testing serialization of messages. |
| 6 // VMOptions=--enable_type_checks --enable_asserts | 6 // VMOptions=--enable_type_checks --enable_asserts |
| 7 | 7 |
| 8 library MessageTest; | 8 library MessageTest; |
| 9 import 'dart:async'; | 9 import 'dart:async'; |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 Expect.isTrue(x is Uint8List); | 165 Expect.isTrue(x is Uint8List); |
| 166 Expect.equals(2, x.length); | 166 Expect.equals(2, x.length); |
| 167 Expect.equals(0, x[0]); | 167 Expect.equals(0, x[0]); |
| 168 Expect.equals(1, x[1]); | 168 Expect.equals(1, x[1]); |
| 169 }); | 169 }); |
| 170 | 170 |
| 171 Uint16List uint16 = new Uint16List(2); | 171 Uint16List uint16 = new Uint16List(2); |
| 172 uint16[0] = 0; | 172 uint16[0] = 0; |
| 173 uint16[1] = 1; | 173 uint16[1] = 1; |
| 174 ByteBuffer byteBuffer = uint16.buffer; | 174 ByteBuffer byteBuffer = uint16.buffer; |
| 175 ping.send(byteBuffer); /// byteBuffer: ok | 175 ping.send(byteBuffer); /// byteBuffer: ok |
|
sra1
2017/03/21 01:43:48
//
| |
| 176 checks.add( /// byteBuffer: ok | 176 checks.add( // /// byteBuffer: ok |
| 177 (x) { | 177 (x) { |
| 178 Expect.isTrue(x is ByteBuffer); | 178 Expect.isTrue(x is ByteBuffer); |
| 179 Uint16List uint16View = new Uint16List.view(x); | 179 Uint16List uint16View = new Uint16List.view(x); |
| 180 Expect.equals(2, uint16View.length); | 180 Expect.equals(2, uint16View.length); |
| 181 Expect.equals(0, uint16View[0]); | 181 Expect.equals(0, uint16View[0]); |
| 182 Expect.equals(1, uint16View[1]); | 182 Expect.equals(1, uint16View[1]); |
| 183 } | 183 } |
| 184 ) /// byteBuffer: ok | 184 ) // /// byteBuffer: ok |
| 185 ; | 185 ; |
| 186 | 186 |
| 187 Int32x4List list32x4 = new Int32x4List(2); | 187 Int32x4List list32x4 = new Int32x4List(2); |
| 188 list32x4[0] = new Int32x4(1, 2, 3, 4); | 188 list32x4[0] = new Int32x4(1, 2, 3, 4); |
| 189 list32x4[1] = new Int32x4(5, 6, 7, 8); | 189 list32x4[1] = new Int32x4(5, 6, 7, 8); |
| 190 ping.send(list32x4); /// int32x4: ok | 190 ping.send(list32x4); /// int32x4: ok |
| 191 checks.add( /// int32x4: ok | 191 checks.add( // /// int32x4: ok |
| 192 (x) { | 192 (x) { |
| 193 Expect.isTrue(x is Int32x4List); | 193 Expect.isTrue(x is Int32x4List); |
| 194 Expect.equals(2, x.length); | 194 Expect.equals(2, x.length); |
| 195 Int32x4 entry1 = x[0]; | 195 Int32x4 entry1 = x[0]; |
| 196 Int32x4 entry2 = x[1]; | 196 Int32x4 entry2 = x[1]; |
| 197 Expect.equals(1, entry1.x); | 197 Expect.equals(1, entry1.x); |
| 198 Expect.equals(2, entry1.y); | 198 Expect.equals(2, entry1.y); |
| 199 Expect.equals(3, entry1.z); | 199 Expect.equals(3, entry1.z); |
| 200 Expect.equals(4, entry1.w); | 200 Expect.equals(4, entry1.w); |
| 201 Expect.equals(5, entry2.x); | 201 Expect.equals(5, entry2.x); |
| 202 Expect.equals(6, entry2.y); | 202 Expect.equals(6, entry2.y); |
| 203 Expect.equals(7, entry2.z); | 203 Expect.equals(7, entry2.z); |
| 204 Expect.equals(8, entry2.w); | 204 Expect.equals(8, entry2.w); |
| 205 } | 205 } |
| 206 ) /// int32x4: ok | 206 ) // /// int32x4: ok |
| 207 ; | 207 ; |
| 208 | 208 |
| 209 ping.send({"foo": 499, "bar": 32}); | 209 ping.send({"foo": 499, "bar": 32}); |
| 210 checks.add((x) { | 210 checks.add((x) { |
| 211 Expect.isTrue(x is LinkedHashMap); | 211 Expect.isTrue(x is LinkedHashMap); |
| 212 Expect.listEquals(["foo", "bar"], x.keys.toList()); | 212 Expect.listEquals(["foo", "bar"], x.keys.toList()); |
| 213 Expect.listEquals([499, 32], x.values.toList()); | 213 Expect.listEquals([499, 32], x.values.toList()); |
| 214 Expect.equals(499, x["foo"]); | 214 Expect.equals(499, x["foo"]); |
| 215 Expect.equals(32, x["bar"]); | 215 Expect.equals(32, x["bar"]); |
| 216 // Must be mutable. | 216 // Must be mutable. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 Expect.isTrue(x is D); | 346 Expect.isTrue(x is D); |
| 347 Expect.isTrue(x is M); | 347 Expect.isTrue(x is M); |
| 348 Expect.identical(x, x.field); | 348 Expect.identical(x, x.field); |
| 349 Expect.equals(11, x.field2); | 349 Expect.equals(11, x.field2); |
| 350 Expect.equals(499, x.superField); | 350 Expect.equals(499, x.superField); |
| 351 Expect.equals(99, x.superField2); | 351 Expect.equals(99, x.superField2); |
| 352 Expect.throws(() => x.field2 = 22); | 352 Expect.throws(() => x.field2 = 22); |
| 353 }); | 353 }); |
| 354 | 354 |
| 355 ping.send(new E(E.fooFun)); /// fun: ok | 355 ping.send(new E(E.fooFun)); /// fun: ok |
| 356 checks.add((x) { /// fun: continued | 356 checks.add((x) { // /// fun: continued |
| 357 Expect.equals(E.fooFun, x.fun); /// fun: continued | 357 Expect.equals(E.fooFun, x.fun); /// fun: continued |
| 358 Expect.equals(499, x.fun()); /// fun: continued | 358 Expect.equals(499, x.fun()); // /// fun: continued |
| 359 }); /// fun: continued | 359 }); // /// fun: continued |
| 360 | 360 |
| 361 ping.send(new E(barFun)); /// fun: continued | 361 ping.send(new E(barFun)); /// fun: continued |
| 362 checks.add((x) { /// fun: continued | 362 checks.add((x) { // /// fun: continued |
| 363 Expect.equals(barFun, x.fun); /// fun: continued | 363 Expect.equals(barFun, x.fun); /// fun: continued |
| 364 Expect.equals(42, x.fun()); /// fun: continued | 364 Expect.equals(42, x.fun()); // /// fun: continued |
| 365 }); /// fun: continued | 365 }); // /// fun: continued |
| 366 | 366 |
| 367 Expect.throws(() => ping.send(new E(new E(null).instanceFun))); | 367 Expect.throws(() => ping.send(new E(new E(null).instanceFun))); |
| 368 | 368 |
| 369 F nonConstF = new F(); | 369 F nonConstF = new F(); |
| 370 ping.send(nonConstF); | 370 ping.send(nonConstF); |
| 371 checks.add((x) { | 371 checks.add((x) { |
| 372 Expect.equals("field", x.field); | 372 Expect.equals("field", x.field); |
| 373 Expect.isFalse(identical(nonConstF, x)); | 373 Expect.isFalse(identical(nonConstF, x)); |
| 374 }); | 374 }); |
| 375 | 375 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 .spawn(echoMain, [initialReplyPort.sendPort, testPort.sendPort]) | 453 .spawn(echoMain, [initialReplyPort.sendPort, testPort.sendPort]) |
| 454 .then((_) => initialReplyPort.first) | 454 .then((_) => initialReplyPort.first) |
| 455 .then((SendPort ping) { | 455 .then((SendPort ping) { |
| 456 runTests(ping, checks); | 456 runTests(ping, checks); |
| 457 Expect.isTrue(checks.length > 0); | 457 Expect.isTrue(checks.length > 0); |
| 458 completer.future | 458 completer.future |
| 459 .then((_) => ping.send("halt")) | 459 .then((_) => ping.send("halt")) |
| 460 .then((_) => asyncEnd()); | 460 .then((_) => asyncEnd()); |
| 461 }); | 461 }); |
| 462 } | 462 } |
| OLD | NEW |