Index: test/codegen/unittest.dart |
diff --git a/test/browser/minitest.dart b/test/codegen/unittest.dart |
similarity index 69% |
rename from test/browser/minitest.dart |
rename to test/codegen/unittest.dart |
index 96f0b2fa8c1a89328516a9ebe4ba25eec87f996d..e964b80a38a393def9675266352dc6735c360e19 100644 |
--- a/test/browser/minitest.dart |
+++ b/test/codegen/unittest.dart |
@@ -3,30 +3,29 @@ |
// BSD-style license that can be found in the LICENSE file. |
// TODO(jmesserly): replace this with the real package:test. |
-// Not possible yet because it uses on async/await which we don't support. |
+// Not possible yet due to various bugs we still have. |
library minitest; |
-import 'dom.dart'; |
+import 'dart:async'; |
+import 'package:dom/dom.dart'; |
-final console = (window as dynamic).console; |
+void group(String name, void body()) => (window as dynamic).suite(name, body); |
-void group(String name, void body()) { |
- console.group(name); |
- body(); |
- console.groupEnd(name); |
-} |
- |
-void test(String name, void body(), {String skip}) { |
+void test(String name, body(), {String skip}) { |
if (skip != null) { |
- console.warn('SKIP $name: $skip'); |
+ print('SKIP $name: $skip'); |
return; |
} |
- console.log(name); |
- try { |
- body(); |
- } catch(e) { |
- console.error(e); |
- } |
+ (window as dynamic).test(name, (done) { |
+ _finishTest(f) { |
+ if (f is Future) { |
+ f.then(_finishTest); |
+ } else { |
+ done(); |
+ } |
+ } |
+ _finishTest(body()); |
+ }); |
} |
void expect(Object actual, matcher) { |
@@ -36,6 +35,10 @@ void expect(Object actual, matcher) { |
} |
} |
+void fail(String message) { |
+ throw 'TestFailure: ' + message; |
+} |
+ |
Matcher equals(Object expected) { |
return (actual) { |
if (expected is List && actual is List) { |
@@ -57,10 +60,13 @@ Matcher isNot(matcher) { |
return (actual) => !matcher(actual); |
} |
+bool isTrue(actual) => actual == true; |
bool isNull(actual) => actual == null; |
final Matcher isNotNull = isNot(isNull); |
bool isRangeError(actual) => actual is RangeError; |
bool isNoSuchMethodError(actual) => actual is NoSuchMethodError; |
+Matcher lessThan(expected) => (actual) => actual < expected; |
+Matcher greaterThan(expected) => (actual) => actual > expected; |
Matcher throwsA(matcher) { |
if (matcher is! Matcher) matcher = equals(matcher); |