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

Side by Side Diff: test/codegen/expect/language/async_control_structures_test.js

Issue 2128353002: Check in codegen test expectations. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 5 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
(Empty)
1 dart_library.library('language/async_control_structures_test', null, /* Imports */[
2 'dart_sdk',
3 'expect'
4 ], function load__async_control_structures_test(exports, dart_sdk, expect) {
5 'use strict';
6 const core = dart_sdk.core;
7 const async = dart_sdk.async;
8 const dart = dart_sdk.dart;
9 const dartx = dart_sdk.dartx;
10 const expect$ = expect.expect;
11 const async_control_structures_test = Object.create(null);
12 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun ctionType(dart.dynamic, [dart.dynamic])))();
13 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
14 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
15 async_control_structures_test.expectThenValue = function(future, value) {
16 expect$.Expect.isTrue(async.Future.is(future));
17 dart.dsend(future, 'then', dart.fn(result => {
18 expect$.Expect.equals(value, result);
19 }, dynamicTodynamic()));
20 };
21 dart.fn(async_control_structures_test.expectThenValue, dynamicAnddynamicTodyna mic());
22 async_control_structures_test.asyncIf = function(condition) {
23 return dart.async(function*(condition) {
24 if (dart.test(condition)) {
25 return 1;
26 } else {
27 return 2;
28 }
29 return 3;
30 }, dart.dynamic, condition);
31 };
32 dart.fn(async_control_structures_test.asyncIf, dynamicTodynamic());
33 async_control_structures_test.asyncFor = function(condition) {
34 return dart.async(function*(condition) {
35 for (let i = 0; i < 10; i++) {
36 if (i == 5 && dart.test(condition)) {
37 return 1;
38 }
39 }
40 return 2;
41 }, dart.dynamic, condition);
42 };
43 dart.fn(async_control_structures_test.asyncFor, dynamicTodynamic());
44 async_control_structures_test.asyncTryCatchFinally = function(overrideInFinall y, doThrow) {
45 return dart.async(function*(overrideInFinally, doThrow) {
46 try {
47 if (dart.test(doThrow)) dart.throw(444);
48 return 1;
49 } catch (e) {
50 return e;
51 }
52 finally {
53 if (dart.test(overrideInFinally)) return 3;
54 }
55 }, dart.dynamic, overrideInFinally, doThrow);
56 };
57 dart.fn(async_control_structures_test.asyncTryCatchFinally, dynamicAnddynamicT odynamic());
58 async_control_structures_test.asyncTryCatchLoop = function() {
59 return dart.async(function*() {
60 let i = 0;
61 let throws = 13;
62 while (true) {
63 try {
64 dart.throw(throws);
65 } catch (e) {
66 if (i == throws) {
67 return e;
68 }
69 }
70 finally {
71 i++;
72 }
73 }
74 }, dart.dynamic);
75 };
76 dart.fn(async_control_structures_test.asyncTryCatchLoop, VoidTodynamic());
77 async_control_structures_test.asyncImplicitReturn = function() {
78 return dart.async(function*() {
79 try {
80 } catch (e) {
81 }
82 finally {
83 }
84 }, dart.dynamic);
85 };
86 dart.fn(async_control_structures_test.asyncImplicitReturn, VoidTodynamic());
87 async_control_structures_test.main = function() {
88 let asyncReturn = null;
89 for (let i = 0; i < 10; i++) {
90 asyncReturn = async_control_structures_test.asyncIf(true);
91 async_control_structures_test.expectThenValue(asyncReturn, 1);
92 asyncReturn = async_control_structures_test.asyncIf(false);
93 async_control_structures_test.expectThenValue(asyncReturn, 2);
94 asyncReturn = async_control_structures_test.asyncFor(true);
95 async_control_structures_test.expectThenValue(asyncReturn, 1);
96 asyncReturn = async_control_structures_test.asyncFor(false);
97 async_control_structures_test.expectThenValue(asyncReturn, 2);
98 asyncReturn = async_control_structures_test.asyncTryCatchFinally(true, fal se);
99 async_control_structures_test.expectThenValue(asyncReturn, 3);
100 asyncReturn = async_control_structures_test.asyncTryCatchFinally(false, fa lse);
101 async_control_structures_test.expectThenValue(asyncReturn, 1);
102 asyncReturn = async_control_structures_test.asyncTryCatchFinally(true, tru e);
103 async_control_structures_test.expectThenValue(asyncReturn, 3);
104 asyncReturn = async_control_structures_test.asyncTryCatchFinally(false, tr ue);
105 async_control_structures_test.expectThenValue(asyncReturn, 444);
106 asyncReturn = async_control_structures_test.asyncTryCatchLoop();
107 async_control_structures_test.expectThenValue(asyncReturn, 13);
108 asyncReturn = async_control_structures_test.asyncImplicitReturn();
109 async_control_structures_test.expectThenValue(asyncReturn, null);
110 }
111 };
112 dart.fn(async_control_structures_test.main, VoidTodynamic());
113 // Exports:
114 exports.async_control_structures_test = async_control_structures_test;
115 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698