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 // TODO(gram): | 5 // TODO(gram): |
| 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. | 6 // Unfortunately I can't seem to test anything that involves timeouts, e.g. |
| 7 // insufficient callbacks, because the timeout is controlled externally | 7 // insufficient callbacks, because the timeout is controlled externally |
| 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests | 8 // (test.dart?), and we would need to use a shorter timeout for the inner tests |
| 9 // so the outer timeout doesn't fire. So I removed all such tests. | 9 // so the outer timeout doesn't fire. So I removed all such tests. |
| 10 // I'd like to revisit this at some point. | 10 // I'd like to revisit this at some point. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 } | 80 } |
| 81 | 81 |
| 82 class FooSpy extends Mock implements Foo { | 82 class FooSpy extends Mock implements Foo { |
| 83 Foo real; | 83 Foo real; |
| 84 FooSpy() { | 84 FooSpy() { |
| 85 real = new Foo(); | 85 real = new Foo(); |
| 86 this.when(callsTo('sum')).alwaysCall(real.sum); | 86 this.when(callsTo('sum')).alwaysCall(real.sum); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 makeTestLogEntry(String methodName, List args, int time, | |
| 91 [String mockName]) { | |
| 92 LogEntry e = new LogEntry(mockName, methodName, args, Action.IGNORE); | |
| 93 e.time = new Date.fromMillisecondsSinceEpoch(time, true); | |
| 94 return e; | |
| 95 } | |
| 96 | |
| 97 makeTestLog() { | |
| 98 LogEntryList log = new LogEntryList('test'); | |
| 99 List args = new List(); | |
| 100 log.add(makeTestLogEntry('a', args, 1000)); | |
| 101 log.add(makeTestLogEntry('b', args, 2000)); | |
| 102 log.add(makeTestLogEntry('c', args, 3000)); | |
| 103 return log; | |
| 104 } | |
| 105 | |
| 90 runTest() { | 106 runTest() { |
| 91 port.receive((testName, sendport) { | 107 port.receive((testName, sendport) { |
| 92 configure(_testconfig = new TestConfiguration(sendport)); | 108 configure(_testconfig = new TestConfiguration(sendport)); |
| 93 if (testName == 'single correct test') { | 109 if (testName == 'single correct test') { |
| 94 test(testName, () => expect(2 + 3, equals(5))); | 110 test(testName, () => expect(2 + 3, equals(5))); |
| 95 } else if (testName == 'single failing test') { | 111 } else if (testName == 'single failing test') { |
| 96 test(testName, () => expect(2 + 2, equals(5))); | 112 test(testName, () => expect(2 + 2, equals(5))); |
| 97 } else if (testName == 'exception test') { | 113 } else if (testName == 'exception test') { |
| 98 test(testName, () { throw new Exception('Fail.'); }); | 114 test(testName, () { throw new Exception('Fail.'); }); |
| 99 } else if (testName == 'group name test') { | 115 } else if (testName == 'group name test') { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 m.when(callsTo(matches('^[A-Z]'))). | 283 m.when(callsTo(matches('^[A-Z]'))). |
| 268 alwaysThrow('Method names must start with lower case.'); | 284 alwaysThrow('Method names must start with lower case.'); |
| 269 m.Test(); | 285 m.Test(); |
| 270 }); | 286 }); |
| 271 } else if (testName.startsWith('mock test 12 ')) { | 287 } else if (testName.startsWith('mock test 12 ')) { |
| 272 test(testName, () { | 288 test(testName, () { |
| 273 var m = new Mock.custom(enableLogging:false); | 289 var m = new Mock.custom(enableLogging:false); |
| 274 m.Test(); | 290 m.Test(); |
| 275 print(m.getLogs(callsTo('Test')).toString()); | 291 print(m.getLogs(callsTo('Test')).toString()); |
| 276 }); | 292 }); |
| 293 } else if (testName.startsWith('mock test 13 ')) { | |
| 294 test(testName, () { | |
| 295 LogEntryList log = makeTestLog(); | |
| 296 // Basic behavior, with call matcher. | |
| 297 expect(log.findLogEntry(callsTo('a')), 0); | |
| 298 expect(log.findLogEntry(callsTo('b')), 1); | |
| 299 expect(log.findLogEntry(callsTo('c')), 2); | |
| 300 expect(log.findLogEntry(callsTo('d')), -1); | |
| 301 // Find using predicate. | |
| 302 expect(log.findLogEntry((le) => le.methodName == 'a'), 0); | |
| 303 expect(log.findLogEntry((le) => le.methodName == 'b'), 1); | |
| 304 expect(log.findLogEntry((le) => le.methodName == 'c'), 2); | |
| 305 // Test explicit return value. | |
| 306 expect(log.findLogEntry((le) => le.methodName == 'd', 0, 3), 3); | |
| 307 // Find from start of log. | |
| 308 expect(log.findLogEntry(callsTo('a'), 0), 0); | |
| 309 expect(log.findLogEntry(callsTo('b'), 0), 1); | |
| 310 expect(log.findLogEntry(callsTo('c'), 0), 2); | |
| 311 // Find from second entry in log. | |
| 312 expect(log.findLogEntry(callsTo('a'), 1), -1); | |
| 313 expect(log.findLogEntry(callsTo('b'), 1), 1); | |
| 314 expect(log.findLogEntry(callsTo('c'), 1), 2); | |
| 315 // Find from last entry in log. | |
| 316 expect(log.findLogEntry(callsTo('a'), 2), -1); | |
| 317 expect(log.findLogEntry(callsTo('b'), 2), -1); | |
| 318 expect(log.findLogEntry(callsTo('c'), 2), 2); | |
| 319 // Find from start position passed end of log. | |
| 320 expect(log.findLogEntry(callsTo('a'), 3), -1); | |
| 321 expect(log.findLogEntry(callsTo('b'), 3), -1); | |
| 322 expect(log.findLogEntry(callsTo('c'), 3), -1); | |
| 323 // No restriction on entry. | |
| 324 expect(log.findLogEntry(null, 0), 0); | |
| 325 expect(log.findLogEntry(null, 1), 1); | |
| 326 expect(log.findLogEntry(null, 2), 2); | |
| 327 expect(log.findLogEntry(null, 3), -1); | |
| 328 }); | |
| 329 } else if (testName.startsWith('mock test 14 ')) { | |
| 330 test(testName, () { | |
| 331 LogEntryList log = makeTestLog(); | |
| 332 LogEntryList log2; | |
| 333 Date t0 = new Date.fromMillisecondsSinceEpoch(0, true); | |
| 334 Date t1000 = new Date.fromMillisecondsSinceEpoch(1000, true); | |
| 335 Date t2000 = new Date.fromMillisecondsSinceEpoch(2000, true); | |
| 336 Date t3000 = new Date.fromMillisecondsSinceEpoch(3000, true); | |
| 337 Date t4000 = new Date.fromMillisecondsSinceEpoch(4000, true); | |
| 338 | |
| 339 log2 = log.before(t0); | |
| 340 expect(log2.logs, hasLength(0)); | |
| 341 expect(log2.filter, 'test before 1970-01-01 00:00:00.000Z'); | |
| 342 log2 = log.until(t0); | |
| 343 expect(log2.logs, hasLength(0)); | |
| 344 expect(log2.filter, 'test until 1970-01-01 00:00:00.000Z'); | |
| 345 log2 = log.from(t0); | |
| 346 expect(log2.logs, hasLength(3)); | |
| 347 expect(log2.first.methodName, 'a'); | |
| 348 expect(log2.last.methodName, 'c'); | |
| 349 expect(log2.filter, 'test from 1970-01-01 00:00:00.000Z'); | |
| 350 log2 = log.after(t0); | |
| 351 expect(log2.logs, hasLength(3)); | |
| 352 expect(log2.first.methodName, 'a'); | |
| 353 expect(log2.last.methodName, 'c'); | |
| 354 expect(log2.filter, 'test after 1970-01-01 00:00:00.000Z'); | |
| 355 | |
| 356 log2 = log.before(t1000); | |
| 357 expect(log2.logs, hasLength(0)); | |
| 358 log2 = log.until(t1000); | |
| 359 expect(log2.logs, hasLength(1)); | |
| 360 expect(log2.first.methodName, 'a'); | |
| 361 expect(log2.last.methodName, 'a'); | |
| 362 log2 = log.from(t1000); | |
| 363 expect(log2.logs, hasLength(3)); | |
| 364 expect(log2.first.methodName, 'a'); | |
| 365 expect(log2.last.methodName, 'c'); | |
| 366 log2 = log.after(t1000); | |
| 367 expect(log2.logs, hasLength(2)); | |
| 368 expect(log2.first.methodName, 'b'); | |
| 369 expect(log2.last.methodName, 'c'); | |
| 370 | |
| 371 log2 = log.before(t2000); | |
| 372 expect(log2.logs, hasLength(1)); | |
| 373 expect(log2.first.methodName, 'a'); | |
| 374 expect(log2.last.methodName, 'a'); | |
| 375 log2 = log.until(t2000); | |
| 376 expect(log2.logs, hasLength(2)); | |
| 377 expect(log2.first.methodName, 'a'); | |
| 378 expect(log2.last.methodName, 'b'); | |
| 379 log2 = log.from(t2000); | |
| 380 expect(log2.logs, hasLength(2)); | |
| 381 expect(log2.first.methodName, 'b'); | |
| 382 expect(log2.last.methodName, 'c'); | |
| 383 log2 = log.after(t2000); | |
| 384 expect(log2.logs, hasLength(1)); | |
| 385 expect(log2.first.methodName, 'c'); | |
| 386 expect(log2.last.methodName, 'c'); | |
| 387 | |
| 388 log2 = log.before(t3000); | |
| 389 expect(log2.logs, hasLength(2)); | |
| 390 expect(log2.first.methodName, 'a'); | |
| 391 expect(log2.last.methodName, 'b'); | |
| 392 log2 = log.until(t3000); | |
| 393 expect(log2.logs, hasLength(3)); | |
| 394 expect(log2.first.methodName, 'a'); | |
| 395 expect(log2.last.methodName, 'c'); | |
| 396 | |
| 397 log2 = log.from(t3000); | |
| 398 expect(log2.logs, hasLength(1)); | |
| 399 expect(log2.first.methodName, 'c'); | |
| 400 expect(log2.last.methodName, 'c'); | |
| 401 log2 = log.after(t3000); | |
| 402 expect(log2.logs, hasLength(0)); | |
| 403 | |
| 404 log2 = log.before(t4000); | |
| 405 expect(log2.logs, hasLength(3)); | |
| 406 expect(log2.first.methodName, 'a'); | |
| 407 expect(log2.last.methodName, 'c'); | |
| 408 log2 = log.until(t4000); | |
| 409 expect(log2.logs, hasLength(3)); | |
| 410 expect(log2.first.methodName, 'a'); | |
| 411 expect(log2.last.methodName, 'c'); | |
| 412 log2 = log.from(t4000); | |
| 413 expect(log2.logs, hasLength(0)); | |
| 414 log2 = log.after(t4000); | |
| 415 expect(log2.logs, hasLength(0)); | |
| 416 }); | |
| 417 } else if (testName.startsWith('mock test 15 ')) { | |
|
Siggi Cherem (dart-lang)
2012/07/19 18:05:00
(as discussed) we should eventually move out of th
gram
2012/07/19 18:52:19
Agreed; I'll move these out in a separate CL.
| |
| 418 test(testName, () { | |
| 419 Date t0 = new Date.fromMillisecondsSinceEpoch(0, true); | |
| 420 Date t1000 = new Date.fromMillisecondsSinceEpoch(1000, true); | |
| 421 Date t2000 = new Date.fromMillisecondsSinceEpoch(2000, true); | |
| 422 Date t3000 = new Date.fromMillisecondsSinceEpoch(3000, true); | |
| 423 Date t4000 = new Date.fromMillisecondsSinceEpoch(4000, true); | |
| 424 | |
| 425 LogEntryList log = makeTestLog().before(t0, true); | |
| 426 expect(log.logs, hasLength(0)); | |
| 427 expect(log.filter, 'test before 1970-01-01 00:00:00.000Z'); | |
| 428 log = makeTestLog().until(t0, true); | |
| 429 expect(log.logs, hasLength(0)); | |
| 430 expect(log.filter, 'test until 1970-01-01 00:00:00.000Z'); | |
| 431 log = makeTestLog().from(t0, true); | |
| 432 expect(log.logs, hasLength(3)); | |
| 433 expect(log.first.methodName, 'a'); | |
| 434 expect(log.last.methodName, 'c'); | |
| 435 expect(log.filter, 'test from 1970-01-01 00:00:00.000Z'); | |
| 436 log = makeTestLog().after(t0, true); | |
| 437 expect(log.logs, hasLength(3)); | |
| 438 expect(log.first.methodName, 'a'); | |
| 439 expect(log.last.methodName, 'c'); | |
| 440 expect(log.filter, 'test after 1970-01-01 00:00:00.000Z'); | |
| 441 | |
| 442 log = makeTestLog().before(t1000, true); | |
| 443 expect(log.logs, hasLength(0)); | |
| 444 log = makeTestLog().until(t1000, true); | |
| 445 expect(log.logs, hasLength(1)); | |
| 446 expect(log.first.methodName, 'a'); | |
| 447 expect(log.last.methodName, 'a'); | |
| 448 log = makeTestLog().from(t1000, true); | |
| 449 expect(log.logs, hasLength(3)); | |
| 450 expect(log.first.methodName, 'a'); | |
| 451 expect(log.last.methodName, 'c'); | |
| 452 log = makeTestLog().after(t1000, true); | |
| 453 expect(log.logs, hasLength(2)); | |
| 454 expect(log.first.methodName, 'b'); | |
| 455 expect(log.last.methodName, 'c'); | |
| 456 | |
| 457 log = makeTestLog().before(t2000, true); | |
| 458 expect(log.logs, hasLength(1)); | |
| 459 expect(log.first.methodName, 'a'); | |
| 460 expect(log.last.methodName, 'a'); | |
| 461 log = makeTestLog().until(t2000, true); | |
| 462 expect(log.logs, hasLength(2)); | |
| 463 expect(log.first.methodName, 'a'); | |
| 464 expect(log.last.methodName, 'b'); | |
| 465 log = makeTestLog().from(t2000, true); | |
| 466 expect(log.logs, hasLength(2)); | |
| 467 expect(log.first.methodName, 'b'); | |
| 468 expect(log.last.methodName, 'c'); | |
| 469 log = makeTestLog().after(t2000, true); | |
| 470 expect(log.logs, hasLength(1)); | |
| 471 expect(log.first.methodName, 'c'); | |
| 472 expect(log.last.methodName, 'c'); | |
| 473 | |
| 474 log = makeTestLog().before(t3000, true); | |
| 475 expect(log.logs, hasLength(2)); | |
| 476 expect(log.first.methodName, 'a'); | |
| 477 expect(log.last.methodName, 'b'); | |
| 478 log = makeTestLog().until(t3000, true); | |
| 479 expect(log.logs, hasLength(3)); | |
| 480 expect(log.first.methodName, 'a'); | |
| 481 expect(log.last.methodName, 'c'); | |
| 482 log = makeTestLog().from(t3000, true); | |
| 483 expect(log.logs, hasLength(1)); | |
| 484 expect(log.first.methodName, 'c'); | |
| 485 expect(log.last.methodName, 'c'); | |
| 486 log = makeTestLog().after(t3000); | |
| 487 expect(log.logs, hasLength(0)); | |
| 488 | |
| 489 log = makeTestLog().before(t4000, true); | |
| 490 expect(log.logs, hasLength(3)); | |
| 491 expect(log.first.methodName, 'a'); | |
| 492 expect(log.last.methodName, 'c'); | |
| 493 log = makeTestLog().until(t4000, true); | |
| 494 expect(log.logs, hasLength(3)); | |
| 495 expect(log.first.methodName, 'a'); | |
| 496 expect(log.last.methodName, 'c'); | |
| 497 log = makeTestLog().from(t4000, true); | |
| 498 expect(log.logs, hasLength(0)); | |
| 499 log = makeTestLog().after(t4000, true); | |
| 500 expect(log.logs, hasLength(0)); | |
| 501 }); | |
| 502 } else if (testName.startsWith('mock test 16 ')) { | |
| 503 test(testName, () { | |
| 504 LogEntryList log = new LogEntryList('test'); | |
| 505 List args0 = new List(); | |
| 506 List args1 = new List(); | |
| 507 args1.add('test'); | |
| 508 LogEntry e0 = makeTestLogEntry('foo', args0, 1000); | |
| 509 log.add(e0); | |
| 510 LogEntry e1 = makeTestLogEntry('bar1', args0, 2000, 'a'); | |
| 511 log.add(e1); | |
| 512 LogEntry e2 = makeTestLogEntry('bar1', args1, 3000, 'b'); | |
| 513 log.add(e2); | |
| 514 LogEntry e3 = makeTestLogEntry('foo', args0, 4000); | |
| 515 log.add(e3); | |
| 516 LogEntry e4 = makeTestLogEntry('hello', args0, 4500); | |
| 517 log.add(e4); | |
| 518 LogEntry e5 = makeTestLogEntry('bar2', args0, 5000, 'a'); | |
| 519 log.add(e5); | |
| 520 LogEntry e6 = makeTestLogEntry('bar2', args1, 6000, 'b'); | |
| 521 log.add(e6); | |
| 522 LogEntry e7 = makeTestLogEntry('foo', args0, 7000); | |
| 523 log.add(e7); | |
| 524 LogEntry e8 = makeTestLogEntry('bar3', args0, 8000, 'a'); | |
| 525 log.add(e8); | |
| 526 LogEntry e9 = makeTestLogEntry('bar3', args1, 9000, 'b'); | |
| 527 log.add(e9); | |
| 528 LogEntry e10 = makeTestLogEntry('foo', args0, 10000); | |
| 529 log.add(e10); | |
| 530 | |
| 531 LogEntryList keyList = new LogEntryList('keys'); | |
| 532 | |
| 533 // Test with empty key list. | |
| 534 | |
| 535 LogEntryList result; | |
| 536 result = log.preceding(keyList); | |
| 537 expect(result.logs, hasLength(0)); | |
| 538 | |
| 539 result = log.preceding(keyList, includeKeys:true); | |
| 540 expect(result.logs, hasLength(0)); | |
| 541 | |
| 542 // Single key, distance 1, no restrictions. | |
| 543 | |
| 544 keyList.add(e3); | |
| 545 result = log.preceding(keyList); | |
| 546 expect(result.logs, orderedEquals([e2])); | |
| 547 | |
| 548 result = log.following(keyList); | |
| 549 expect(result.logs, orderedEquals([e4])); | |
| 550 | |
| 551 // Single key, distance 2, no restrictions. | |
| 552 | |
| 553 result = log.preceding(keyList, distance:2); | |
| 554 expect(result.logs, orderedEquals([e1, e2])); | |
| 555 | |
| 556 result = log.following(keyList, distance:2); | |
| 557 expect(result.logs, orderedEquals([e4, e5])); | |
| 558 | |
| 559 // Single key, distance 3, no restrictions. | |
| 560 | |
| 561 result = log.preceding(keyList, distance:3); | |
| 562 expect(result.logs, orderedEquals([e0, e1, e2])); | |
| 563 | |
| 564 result = log.following(keyList, distance:3); | |
| 565 expect(result.logs, orderedEquals([e4, e5, e6])); | |
| 566 | |
| 567 // Include keys in result | |
| 568 | |
| 569 result = log.preceding(keyList, distance:3, includeKeys:true); | |
| 570 expect(result.logs, orderedEquals([e0, e1, e2, e3])); | |
| 571 | |
| 572 result = log.following(keyList, distance:3, includeKeys:true); | |
| 573 expect(result.logs, orderedEquals([e3, e4, e5, e6])); | |
| 574 | |
| 575 // Restrict the matches | |
| 576 | |
| 577 result = log.preceding(keyList, logFilter:callsTo(startsWith('bar')), | |
| 578 distance:3); | |
| 579 expect(result.logs, orderedEquals([e1, e2])); | |
| 580 | |
| 581 result = log.preceding(keyList, logFilter:callsTo(startsWith('bar')), | |
| 582 distance:3, includeKeys:true); | |
| 583 expect(result.logs, orderedEquals([e1, e2, e3])); | |
| 584 | |
| 585 result = log.preceding(keyList, equals('a'), callsTo(startsWith('bar')), | |
| 586 distance:3); | |
| 587 expect(result.logs, orderedEquals([e1])); | |
| 588 | |
| 589 result = log.preceding(keyList, equals('a'), callsTo(startsWith('bar')), | |
| 590 distance:3, includeKeys:true); | |
| 591 expect(result.logs, orderedEquals([e1, e3])); | |
| 592 | |
| 593 keyList.logs.clear(); | |
|
Siggi Cherem (dart-lang)
2012/07/19 18:05:00
BTW - whenever we move the tests into their own te
gram
2012/07/19 18:52:19
Let me do it when it gets factored out.
| |
| 594 keyList.add(e0); | |
| 595 keyList.add(e3); | |
| 596 keyList.add(e7); | |
| 597 | |
| 598 result = log.preceding(keyList); | |
| 599 expect(result.logs, orderedEquals([e2, e6])); | |
| 600 | |
| 601 result = log.following(keyList); | |
| 602 expect(result.logs, orderedEquals([e1, e4, e8])); | |
| 603 | |
| 604 result = log.preceding(keyList, includeKeys:true); | |
| 605 expect(result.logs, orderedEquals([e0, e2, e3, e6, e7])); | |
| 606 | |
| 607 result = log.following(keyList, includeKeys:true); | |
| 608 expect(result.logs, orderedEquals([e0, e1, e3, e4, e7, e8])); | |
| 609 | |
| 610 keyList.logs.clear(); | |
| 611 keyList.add(e3); | |
| 612 keyList.add(e7); | |
| 613 keyList.add(e10); | |
| 614 | |
| 615 result = log.preceding(keyList); | |
| 616 expect(result.logs, orderedEquals([e2, e6, e9])); | |
| 617 | |
| 618 result = log.following(keyList); | |
| 619 expect(result.logs, orderedEquals([e4, e8])); | |
| 620 | |
| 621 result = log.preceding(keyList, includeKeys:true); | |
| 622 expect(result.logs, orderedEquals([e2, e3, e6, e7, e9, e10])); | |
| 623 | |
| 624 result = log.following(keyList, includeKeys:true); | |
| 625 expect(result.logs, orderedEquals([e3, e4, e7, e8, e10])); | |
| 626 | |
| 627 keyList.logs.clear(); | |
| 628 keyList.add(e0); | |
| 629 keyList.add(e3); | |
| 630 keyList.add(e7); | |
| 631 keyList.add(e10); | |
| 632 | |
| 633 result = log.preceding(keyList); | |
| 634 expect(result.logs, orderedEquals([e2, e6, e9])); | |
| 635 | |
| 636 result = log.following(keyList); | |
| 637 expect(result.logs, orderedEquals([e1, e4, e8])); | |
| 638 | |
| 639 result = log.preceding(keyList, includeKeys:true); | |
| 640 expect(result.logs, orderedEquals([e0, e2, e3, e6, e7, e9, e10])); | |
| 641 | |
| 642 result = log.following(keyList, includeKeys:true); | |
| 643 expect(result.logs, orderedEquals([e0, e1, e3, e4, e7, e8, e10])); | |
| 644 | |
| 645 keyList.logs.clear(); | |
| 646 keyList.add(e0); | |
| 647 keyList.add(e3); | |
| 648 keyList.add(e7); | |
| 649 | |
| 650 result = log.preceding(keyList, distance:3); | |
| 651 expect(result.logs, orderedEquals([e1, e2, e4, e5, e6])); | |
| 652 | |
| 653 result = log.following(keyList, distance:3); | |
| 654 expect(result.logs, orderedEquals([e1, e2, e4, e5, e6, e8, e9, e10])); | |
| 655 | |
| 656 result = log.preceding(keyList, distance:3, includeKeys:true); | |
| 657 expect(result.logs, orderedEquals([e0, e1, e2, e3, e4, e5, e6, e7])); | |
| 658 | |
| 659 result = log.following(keyList, distance:3, includeKeys:true); | |
| 660 expect(result.logs, orderedEquals([e0, e1, e2, e3, e4, e5, e6, | |
| 661 e7, e8, e9, e10])); | |
| 662 | |
| 663 keyList.logs.clear(); | |
| 664 keyList.add(e3); | |
| 665 keyList.add(e7); | |
| 666 keyList.add(e10); | |
| 667 | |
| 668 result = log.preceding(keyList, distance:3); | |
| 669 expect(result.logs, orderedEquals([e0, e1, e2, e4, e5, e6, e8, e9])); | |
| 670 | |
| 671 result = log.following(keyList, distance:3); | |
| 672 expect(result.logs, orderedEquals([e4, e5, e6, e8, e9])); | |
| 673 | |
| 674 result = log.preceding(keyList, distance:3, includeKeys:true); | |
| 675 expect(result.logs, orderedEquals([e0, e1, e2, e3, e4, e5, e6, | |
| 676 e7, e8, e9, e10])); | |
| 677 | |
| 678 result = log.following(keyList, distance:3, includeKeys:true); | |
| 679 expect(result.logs, orderedEquals([e3, e4, e5, e6, e7, e8, e9, e10])); | |
| 680 | |
| 681 keyList.logs.clear(); | |
| 682 keyList.add(e0); | |
| 683 keyList.add(e3); | |
| 684 keyList.add(e7); | |
| 685 keyList.add(e10); | |
| 686 | |
| 687 result = log.preceding(keyList, distance:3); | |
| 688 expect(result.logs, orderedEquals([e1, e2, e4, e5, e6, e8, e9])); | |
| 689 | |
| 690 result = log.following(keyList, distance:3); | |
| 691 expect(result.logs, orderedEquals([e1, e2, e4, e5, e6, e8, e9])); | |
| 692 | |
| 693 result = log.preceding(keyList, distance:3, includeKeys:true); | |
| 694 expect(result.logs, orderedEquals([e0, e1, e2, e3, e4, e5, e6, | |
| 695 e7, e8, e9, e10])); | |
| 696 | |
| 697 result = log.following(keyList, distance:3, includeKeys:true); | |
| 698 expect(result.logs, orderedEquals([e0, e1, e2, e3, e4, e5, e6, | |
| 699 e7, e8, e9, e10])); | |
| 700 }); | |
| 277 } | 701 } |
| 278 }); | 702 }); |
| 279 } | 703 } |
| 280 | 704 |
| 281 void nextTest(int testNum) { | 705 void nextTest(int testNum) { |
| 282 SendPort sport = spawnFunction(runTest); | 706 SendPort sport = spawnFunction(runTest); |
| 283 sport.call(tests[testNum]).then((msg) { | 707 sport.call(tests[testNum]).then((msg) { |
| 284 actual.add(msg); | 708 actual.add(msg); |
| 285 if (actual.length == expected.length) { | 709 if (actual.length == expected.length) { |
| 286 for (var i = 0; i < tests.length; i++) { | 710 for (var i = 0; i < tests.length; i++) { |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 308 'mock test 2 (MockList)', | 732 'mock test 2 (MockList)', |
| 309 'mock test 3 (Spy)', | 733 'mock test 3 (Spy)', |
| 310 'mock test 4 (Excess calls)', | 734 'mock test 4 (Excess calls)', |
| 311 'mock test 5 (No action)', | 735 'mock test 5 (No action)', |
| 312 'mock test 6 (No matching return)', | 736 'mock test 6 (No matching return)', |
| 313 'mock test 7 (No behavior)', | 737 'mock test 7 (No behavior)', |
| 314 'mock test 8 (Shared log)', | 738 'mock test 8 (Shared log)', |
| 315 'mock test 9 (Null CallMatcher)', | 739 'mock test 9 (Null CallMatcher)', |
| 316 'mock test 10 (RegExp CallMatcher Good)', | 740 'mock test 10 (RegExp CallMatcher Good)', |
| 317 'mock test 11 (RegExp CallMatcher Bad)', | 741 'mock test 11 (RegExp CallMatcher Bad)', |
| 318 'mock test 12 (No logging)' | 742 'mock test 12 (No logging)', |
| 743 'mock test 13 (find log entry)', | |
| 744 'mock test 14 (from,after,before,until)', | |
| 745 'mock test 15 (inplace from,after,before,until)', | |
| 746 'mock test 16 (neighbors)' | |
| 319 ]; | 747 ]; |
| 320 | 748 |
| 321 expected = [ | 749 expected = [ |
| 322 buildStatusString(1, 0, 0, tests[0]), | 750 buildStatusString(1, 0, 0, tests[0]), |
| 323 buildStatusString(0, 1, 0, tests[1], | 751 buildStatusString(0, 1, 0, tests[1], |
| 324 message: 'Expected: <5> but: was <4>.'), | 752 message: 'Expected: <5> but: was <4>.'), |
| 325 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), | 753 buildStatusString(0, 1, 0, tests[2], message: 'Caught Exception: Fail.'), |
| 326 buildStatusString(2, 0, 0, 'a a::a b b'), | 754 buildStatusString(2, 0, 0, 'a a::a b b'), |
| 327 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), | 755 buildStatusString(1, 0, 0, 'a ${tests[4]}', 0, 'setup'), |
| 328 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), | 756 buildStatusString(1, 0, 0, 'a ${tests[5]}', 0, '', 'teardown'), |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 344 "Expected sum() to sometimes return <0> but: never did."), | 772 "Expected sum() to sometimes return <0> but: never did."), |
| 345 buildStatusString(0, 1, 0, tests[16], | 773 buildStatusString(0, 1, 0, tests[16], |
| 346 message: 'Caught Exception: No behavior specified for method bar.'), | 774 message: 'Caught Exception: No behavior specified for method bar.'), |
| 347 buildStatusString(1, 0, 0, tests[17]), | 775 buildStatusString(1, 0, 0, tests[17]), |
| 348 buildStatusString(1, 0, 0, tests[18]), | 776 buildStatusString(1, 0, 0, tests[18]), |
| 349 buildStatusString(1, 0, 0, tests[19]), | 777 buildStatusString(1, 0, 0, tests[19]), |
| 350 buildStatusString(0, 1, 0, tests[20], | 778 buildStatusString(0, 1, 0, tests[20], |
| 351 message:'Caught Method names must start with lower case.'), | 779 message:'Caught Method names must start with lower case.'), |
| 352 buildStatusString(0, 1, 0, tests[21], message: | 780 buildStatusString(0, 1, 0, tests[21], message: |
| 353 "Caught Exception: Can't retrieve logs when logging was never enabled."), | 781 "Caught Exception: Can't retrieve logs when logging was never enabled."), |
| 782 buildStatusString(1, 0, 0, tests[22]), | |
| 783 buildStatusString(1, 0, 0, tests[23]), | |
| 784 buildStatusString(1, 0, 0, tests[24]), | |
| 785 buildStatusString(1, 0, 0, tests[25]) | |
| 354 ]; | 786 ]; |
| 355 | 787 |
| 356 actual = []; | 788 actual = []; |
| 357 | 789 |
| 358 nextTest(0); | 790 nextTest(0); |
| 359 } | 791 } |
| 360 | 792 |
| OLD | NEW |