f97f17c76e
For now, the app only prints the location of an offset given at command line. Example usage: dart -p$BUILD_DIRECTORY/ReleaseIA32/packages/ poi.dart DART_FILE OFFSET R=kasperl@google.com Review URL: https://codereview.chromium.org//386563002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38114 260f80e4-7a28-3924-810f-c04153c831b5
62 lines
1.6 KiB
Dart
62 lines
1.6 KiB
Dart
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
library trydart.test_case;
|
|
|
|
import 'dart:html' show
|
|
document;
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:async_helper/async_helper.dart';
|
|
|
|
typedef void VoidFunction();
|
|
|
|
class TestCase {
|
|
final String description;
|
|
final VoidFunction setup;
|
|
final VoidFunction validate;
|
|
|
|
TestCase(this.description, this.setup, this.validate);
|
|
}
|
|
|
|
/**
|
|
* Executes [tests] each test in order using the following approach for each
|
|
* test:
|
|
*
|
|
* 1. Run setup synchronously.
|
|
*
|
|
* 2. Schedule a new (async) Future which runs validate followed by the next
|
|
* test's setup.
|
|
*
|
|
* 3. Repeat step 2 until there are no more tests.
|
|
*
|
|
* The purpose of this test is to simulate edits (during setup), and then let
|
|
* the the mutation observer to process the mutations followed by validation.
|
|
*/
|
|
void runTests(List<TestCase> tests) {
|
|
Completer completer = new Completer();
|
|
asyncTest(() => completer.future.then((_) {
|
|
// Clear the DOM to work around a bug in test.dart.
|
|
document.body.nodes.clear();
|
|
}));
|
|
|
|
void iterateTests(Iterator<TestCase> iterator) {
|
|
if (iterator.moveNext()) {
|
|
TestCase test = iterator.current;
|
|
print('${test.description}\nSetup.');
|
|
test.setup();
|
|
new Future(() {
|
|
test.validate();
|
|
print('${test.description}\nDone.');
|
|
iterateTests(iterator);
|
|
});
|
|
} else {
|
|
completer.complete(null);
|
|
}
|
|
}
|
|
|
|
iterateTests(tests.iterator);
|
|
}
|