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

Side by Side Diff: third_party/pkg/angular/test/jasmine_syntax.dart

Issue 256553002: Revert "Update all Angular libs (run update_all.sh)." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 library jasmine; 1 library jasmine;
2 2
3 import 'package:unittest/unittest.dart' as unit; 3 import 'package:unittest/unittest.dart' as unit;
4 import 'package:angular/utils.dart' as utils; 4 import 'package:angular/utils.dart' as utils;
5 5
6 var _beforeEachFnsForCurrentTest = []; 6 Function _wrapFn;
7 var _afterEachFnsForCurrentTest = [];
8 7
9 _withSetup(fn) => () { 8 _maybeWrapFn(fn) => () {
10 _beforeEachFnsForCurrentTest.sort((a, b) => Comparable.compare(b[1], a[1])); 9 if (_wrapFn != null) {
11 _beforeEachFnsForCurrentTest.forEach((fn) => fn[0]()); 10 _wrapFn(fn)();
12 try { 11 } else {
13 return fn(); 12 fn();
14 } finally {
15 _beforeEachFnsForCurrentTest = [];
16 var _aeFns = _afterEachFnsForCurrentTest;
17 _afterEachFnsForCurrentTest = [];
18 _aeFns.reversed.forEach((fn) => fn());
19 } 13 }
20 }; 14 };
21 15
22 16 it(name, fn) => unit.test(name, _maybeWrapFn(fn));
23 17 iit(name, fn) => unit.solo_test(name, _maybeWrapFn(fn));
24 it(name, fn) => unit.test(name, _withSetup(fn));
25 iit(name, fn) => unit.solo_test(name, _withSetup(fn));
26 xit(name, fn) {} 18 xit(name, fn) {}
27 xdescribe(name, fn) {} 19 xdescribe(name, fn) {}
28 ddescribe(name, fn) => describe(name, fn, true); 20 ddescribe(name, fn) => describe(name, fn, true);
29 21
22
30 class Describe { 23 class Describe {
31 Describe parent; 24 Describe parent;
32 String name; 25 String name;
33 bool exclusive; 26 bool exclusive;
34 List<List> beforeEachFns = []; 27 List<Function> beforeEachFns = [];
35 List<Function> afterEachFns = []; 28 List<Function> afterEachFns = [];
36 29
37 Describe(this.name, this.parent, [bool this.exclusive=false]) { 30 Describe(this.name, this.parent, [bool this.exclusive=false]) {
38 if (parent != null && parent.exclusive) { 31 if (parent != null && parent.exclusive) {
39 exclusive = true; 32 exclusive = true;
40 } 33 }
41 } 34 }
42 35
43 setUp() { 36 setUp() {
44 _beforeEachFnsForCurrentTest.addAll(beforeEachFns); 37 beforeEachFns.forEach((fn) => fn());
45 _afterEachFnsForCurrentTest.addAll(afterEachFns); 38 }
39
40 tearDown() {
41 afterEachFns.forEach((fn) => fn());
46 } 42 }
47 } 43 }
48 44
49 Describe currentDescribe = new Describe('', null); 45 Describe currentDescribe = new Describe('', null);
50 bool ddescribeActive = false; 46 bool ddescribeActive = false;
51 47
52 describe(name, fn, [bool exclusive=false]) { 48 describe(name, fn, [bool exclusive=false]) {
53 var lastDescribe = currentDescribe; 49 var lastDescribe = currentDescribe;
54 currentDescribe = new Describe(name, lastDescribe, exclusive); 50 currentDescribe = new Describe(name, lastDescribe, exclusive);
55 if (exclusive) { 51 if (exclusive) {
56 name = 'DDESCRIBE: $name'; 52 name = 'DDESCRIBE: $name';
57 ddescribeActive = true; 53 ddescribeActive = true;
58 } 54 }
59 try { 55 try {
60 unit.group(name, () { 56 unit.group(name, () {
61 unit.setUp(currentDescribe.setUp); 57 unit.setUp(currentDescribe.setUp);
62 fn(); 58 fn();
59 unit.tearDown(currentDescribe.tearDown);
63 }); 60 });
64 } finally { 61 } finally {
65 currentDescribe = lastDescribe; 62 currentDescribe = lastDescribe;
66 } 63 }
67 } 64 }
68 65
69 beforeEach(fn, {priority: 0}) => currentDescribe.beforeEachFns.add([fn, priority ]); 66 beforeEach(fn) => currentDescribe.beforeEachFns.add(fn);
70 afterEach(fn) => currentDescribe.afterEachFns.insert(0, fn); 67 afterEach(fn) => currentDescribe.afterEachFns.insert(0, fn);
71 68
69 wrapFn(fn) => _wrapFn = fn;
70
72 var jasmine = new Jasmine(); 71 var jasmine = new Jasmine();
73 72
74 class SpyFunctionInvocationResult { 73 class SpyFunctionInvocationResult {
75 final List args; 74 final List args;
76 SpyFunctionInvocationResult(this.args); 75 SpyFunctionInvocationResult(this.args);
77 } 76 }
78 77
79 class SpyFunction { 78 class SpyFunction {
80 String name; 79 String name;
81 List<List<dynamic>> invocations = []; 80 List<List<dynamic>> invocations = [];
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return new SpyFunction(name); 142 return new SpyFunction(name);
144 } 143 }
145 144
146 SpyFunction spyOn(receiver, methodName) { 145 SpyFunction spyOn(receiver, methodName) {
147 throw ["spyOn not implemented"]; 146 throw ["spyOn not implemented"];
148 } 147 }
149 } 148 }
150 149
151 main(){ 150 main(){
152 unit.setUp(currentDescribe.setUp); 151 unit.setUp(currentDescribe.setUp);
152 unit.tearDown(currentDescribe.tearDown);
153 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698