OLD | NEW |
1 dart_library.library('unittest/unittest', null, /* Imports */[ | 1 dart_library.library('unittest/unittest', null, /* Imports */[ |
2 "dart/_runtime", | 2 "dart/_runtime", |
3 'matcher/matcher', | 3 'matcher/matcher', |
4 'dom/dom', | 4 'dom/dom', |
5 'dart/core', | 5 'dart/core', |
6 'dart/async', | 6 'dart/async', |
7 'matcher/src/interfaces', | 7 'matcher/src/interfaces', |
8 'matcher/src/util', | 8 'matcher/src/util', |
9 'matcher/src/description' | 9 'matcher/src/description' |
10 ], /* Lazy imports */[ | 10 ], /* Lazy imports */[ |
11 ], function(exports, dart, matcher, dom, core, async, interfaces, util, descript
ion$) { | 11 ], function(exports, dart, matcher, dom, core, async, interfaces, util, descript
ion$) { |
12 'use strict'; | 12 'use strict'; |
13 let dartx = dart.dartx; | 13 let dartx = dart.dartx; |
14 dart.export_(exports, matcher); | 14 dart.export_(exports, matcher); |
15 function group(name, body) { | 15 function group(name, body) { |
16 return dart.dsend(dom.window, 'suite', name, body); | 16 return dart.dsend(dom.window, 'suite', name, body); |
17 } | 17 } |
18 dart.fn(group, dart.void, [core.String, dart.functionType(dart.void, [])]); | 18 dart.fn(group, dart.void, [core.String, dart.functionType(dart.void, [])]); |
19 function test(name, body, {skip = null} = {}) { | 19 function test(name, body, opts) { |
| 20 let skip = opts && 'skip' in opts ? opts.skip : null; |
20 if (skip != null) { | 21 if (skip != null) { |
21 core.print(`SKIP ${name}: ${skip}`); | 22 core.print(`SKIP ${name}: ${skip}`); |
22 return; | 23 return; |
23 } | 24 } |
24 dart.dsend(dom.window, 'test', name, dart.fn(done => { | 25 dart.dsend(dom.window, 'test', name, dart.fn(done => { |
25 function _finishTest(f) { | 26 function _finishTest(f) { |
26 if (dart.is(f, async.Future)) { | 27 if (dart.is(f, async.Future)) { |
27 dart.dsend(f, 'then', _finishTest); | 28 dart.dsend(f, 'then', _finishTest); |
28 } else { | 29 } else { |
29 dart.dcall(done); | 30 dart.dcall(done); |
30 } | 31 } |
31 } | 32 } |
32 dart.fn(_finishTest); | 33 dart.fn(_finishTest); |
33 _finishTest(body()); | 34 _finishTest(body()); |
34 })); | 35 })); |
35 } | 36 } |
36 dart.fn(test, dart.void, [core.String, dart.functionType(dart.dynamic, [])], {
skip: core.String}); | 37 dart.fn(test, dart.void, [core.String, dart.functionType(dart.dynamic, [])], {
skip: core.String}); |
37 class TestFailure extends core.Object { | 38 class TestFailure extends core.Object { |
38 TestFailure(message) { | 39 TestFailure(message) { |
39 this.message = message; | 40 this.message = message; |
40 } | 41 } |
41 toString() { | 42 toString() { |
42 return this.message; | 43 return this.message; |
43 } | 44 } |
44 } | 45 } |
45 dart.setSignature(TestFailure, { | 46 dart.setSignature(TestFailure, { |
46 constructors: () => ({TestFailure: [TestFailure, [core.String]]}) | 47 constructors: () => ({TestFailure: [TestFailure, [core.String]]}) |
47 }); | 48 }); |
48 const ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionType(
core.String, [dart.dynamic, interfaces.Matcher, core.String, core.Map, core.bool
])); | 49 const ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionType(
core.String, [dart.dynamic, interfaces.Matcher, core.String, core.Map, core.bool
])); |
49 function expect(actual, matcher, {reason = null, verbose = false, formatter =
null} = {}) { | 50 function expect(actual, matcher, opts) { |
| 51 let reason = opts && 'reason' in opts ? opts.reason : null; |
| 52 let verbose = opts && 'verbose' in opts ? opts.verbose : false; |
| 53 let formatter = opts && 'formatter' in opts ? opts.formatter : null; |
50 matcher = util.wrapMatcher(matcher); | 54 matcher = util.wrapMatcher(matcher); |
51 let matchState = dart.map(); | 55 let matchState = dart.map(); |
52 try { | 56 try { |
53 if (dart.notNull(dart.as(dart.dsend(matcher, 'matches', actual, matchState
), core.bool))) | 57 if (dart.notNull(dart.as(dart.dsend(matcher, 'matches', actual, matchState
), core.bool))) |
54 return; | 58 return; |
55 } catch (e) { | 59 } catch (e) { |
56 let trace = dart.stackTrace(e); | 60 let trace = dart.stackTrace(e); |
57 if (reason == null) { | 61 if (reason == null) { |
58 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; | 62 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; |
59 } | 63 } |
(...skipping 23 matching lines...) Expand all Loading... |
83 } | 87 } |
84 dart.fn(_defaultFailFormatter, core.String, [dart.dynamic, interfaces.Matcher,
core.String, core.Map, core.bool]); | 88 dart.fn(_defaultFailFormatter, core.String, [dart.dynamic, interfaces.Matcher,
core.String, core.Map, core.bool]); |
85 // Exports: | 89 // Exports: |
86 exports.group = group; | 90 exports.group = group; |
87 exports.test = test; | 91 exports.test = test; |
88 exports.TestFailure = TestFailure; | 92 exports.TestFailure = TestFailure; |
89 exports.ErrorFormatter = ErrorFormatter; | 93 exports.ErrorFormatter = ErrorFormatter; |
90 exports.expect = expect; | 94 exports.expect = expect; |
91 exports.fail = fail; | 95 exports.fail = fail; |
92 }); | 96 }); |
OLD | NEW |