Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: test/codegen/expect/unittest/unittest.js

Issue 1355893003: Rewire DDC to use the analyzer task model (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Fix for identifiers Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 dart_library.library('unittest/unittest', null, /* Imports */[ 1 dart_library.library('unittest/unittest', null, /* Imports */[
2 "dart_runtime/dart", 2 "dart_runtime/dart",
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, opts) { 19 function test(name, body, opts) {
20 let skip = opts && 'skip' in opts ? opts.skip : null; 20 let skip = opts && 'skip' in opts ? opts.skip : null;
21 if (skip != null) { 21 if (skip != null) {
22 core.print(`SKIP ${name}: ${skip}`); 22 dart.dcall(core.print, `SKIP ${name}: ${skip}`);
23 return; 23 return;
24 } 24 }
25 dart.dsend(dom.window, 'test', name, dart.fn(done => { 25 dart.dsend(dom.window, 'test', name, dart.fn(done => {
26 function _finishTest(f) { 26 function _finishTest(f) {
27 if (dart.is(f, async.Future)) { 27 if (dart.is(f, async.Future)) {
28 dart.dsend(f, 'then', _finishTest); 28 dart.dsend(f, 'then', _finishTest);
29 } else { 29 } else {
30 dart.dcall(done); 30 dart.dcall(done);
31 } 31 }
32 } 32 }
33 dart.fn(_finishTest); 33 dart.fn(_finishTest);
34 _finishTest(body()); 34 dart.dcall(_finishTest, body());
35 })); 35 }));
36 } 36 }
37 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});
38 class TestFailure extends core.Object { 38 class TestFailure extends core.Object {
39 TestFailure(message) { 39 TestFailure(message) {
40 this.message = message; 40 this.message = message;
41 } 41 }
42 toString() { 42 toString() {
43 return this.message; 43 return this.message;
44 } 44 }
45 } 45 }
46 dart.setSignature(TestFailure, { 46 dart.setSignature(TestFailure, {
47 constructors: () => ({TestFailure: [TestFailure, [core.String]]}) 47 constructors: () => ({TestFailure: [TestFailure, [core.String]]})
48 }); 48 });
49 let ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionType(co re.String, [dart.dynamic, interfaces.Matcher, core.String, core.Map, core.bool]) ); 49 let ErrorFormatter = dart.typedef('ErrorFormatter', () => dart.functionType(co re.String, [dart.dynamic, interfaces.Matcher, core.String, core.Map, core.bool]) );
50 function expect(actual, matcher, opts) { 50 function expect(actual, matcher, opts) {
51 let reason = opts && 'reason' in opts ? opts.reason : null; 51 let reason = opts && 'reason' in opts ? opts.reason : null;
52 let verbose = opts && 'verbose' in opts ? opts.verbose : false; 52 let verbose = opts && 'verbose' in opts ? opts.verbose : false;
53 let formatter = opts && 'formatter' in opts ? opts.formatter : null; 53 let formatter = opts && 'formatter' in opts ? opts.formatter : null;
54 matcher = util.wrapMatcher(matcher); 54 matcher = dart.dcall(util.wrapMatcher, matcher);
55 let matchState = dart.map(); 55 let matchState = dart.map();
56 try { 56 try {
57 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)))
58 return; 58 return;
59 } catch (e) { 59 } catch (e) {
60 let trace = dart.stackTrace(e); 60 let trace = dart.stackTrace(e);
61 if (reason == null) { 61 if (reason == null) {
62 reason = `${typeof e == 'string' ? e : dart.toString(e)} at ${trace}`; 62 reason = `${typeof e == 'string' ? e : dart.dsend(e, 'toString')} at ${t race}`;
63 } 63 }
64 } 64 }
65 65
66 if (formatter == null) 66 if (formatter == null)
67 formatter = _defaultFailFormatter; 67 formatter = _defaultFailFormatter;
68 fail(dart.dcall(formatter, actual, matcher, reason, matchState, verbose)); 68 dart.dcall(fail, dart.dcall(formatter, actual, matcher, reason, matchState, verbose));
69 } 69 }
70 dart.fn(expect, dart.void, [dart.dynamic, dart.dynamic], {reason: core.String, verbose: core.bool, formatter: ErrorFormatter}); 70 dart.fn(expect, dart.void, [dart.dynamic, dart.dynamic], {reason: core.String, verbose: core.bool, formatter: ErrorFormatter});
71 function fail(message) { 71 function fail(message) {
72 return dart.throw(new TestFailure(message)); 72 return dart.throw(new TestFailure(message));
73 } 73 }
74 dart.fn(fail, dart.void, [core.String]); 74 dart.fn(fail, dart.void, [core.String]);
75 function _defaultFailFormatter(actual, matcher, reason, matchState, verbose) { 75 function _defaultFailFormatter(actual, matcher, reason, matchState, verbose) {
76 let description = new description$.StringDescription(); 76 let description = new description$.StringDescription();
77 description.add('Expected: ').addDescriptionOf(matcher).add('\n'); 77 dart.dcall(dart.dcall(dart.dcall(description.add, 'Expected: ').addDescripti onOf, matcher).add, '\n');
78 description.add(' Actual: ').addDescriptionOf(actual).add('\n'); 78 dart.dcall(dart.dcall(dart.dcall(description.add, ' Actual: ').addDescripti onOf, actual).add, '\n');
79 let mismatchDescription = new description$.StringDescription(); 79 let mismatchDescription = new description$.StringDescription();
80 matcher.describeMismatch(actual, mismatchDescription, matchState, verbose); 80 dart.dcall(matcher.describeMismatch, actual, mismatchDescription, matchState , verbose);
81 if (dart.notNull(mismatchDescription.length) > 0) { 81 if (dart.notNull(mismatchDescription.length) > 0) {
82 description.add(` Which: ${mismatchDescription}\n`); 82 dart.dcall(description.add, ` Which: ${mismatchDescription}\n`);
83 } 83 }
84 if (reason != null) 84 if (reason != null)
85 description.add(reason).add('\n'); 85 dart.dcall(dart.dcall(description.add, reason).add, '\n');
86 return dart.toString(description); 86 return dart.dcall(description.toString);
87 } 87 }
88 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]);
89 // Exports: 89 // Exports:
90 exports.group = group; 90 exports.group = group;
91 exports.test = test; 91 exports.test = test;
92 exports.TestFailure = TestFailure; 92 exports.TestFailure = TestFailure;
93 exports.ErrorFormatter = ErrorFormatter; 93 exports.ErrorFormatter = ErrorFormatter;
94 exports.expect = expect; 94 exports.expect = expect;
95 exports.fail = fail; 95 exports.fail = fail;
96 }); 96 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698