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

Side by Side Diff: pkg/dev_compiler/test/browser/runtime_tests.js

Issue 2772573003: Handle casts from Number to FutureOr<double>. (Closed)
Patch Set: Created 3 years, 9 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 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 define(['dart_sdk'], function(dart_sdk) { 5 define(['dart_sdk'], function(dart_sdk) {
6 const assert = chai.assert; 6 const assert = chai.assert;
7 const async = dart_sdk.async; 7 const async = dart_sdk.async;
8 const core = dart_sdk.core; 8 const core = dart_sdk.core;
9 const collection = dart_sdk.collection; 9 const collection = dart_sdk.collection;
10 const dart = dart_sdk.dart; 10 const dart = dart_sdk.dart;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 let functionType = dart.functionType; 125 let functionType = dart.functionType;
126 let typedef = dart.typedef; 126 let typedef = dart.typedef;
127 let isSubtype = dart.isSubtype; 127 let isSubtype = dart.isSubtype;
128 128
129 let Object = core.Object; 129 let Object = core.Object;
130 let String = core.String; 130 let String = core.String;
131 let dynamic = dart.dynamic; 131 let dynamic = dart.dynamic;
132 let List = core.List; 132 let List = core.List;
133 let Map = core.Map; 133 let Map = core.Map;
134 let Map$ = core.Map$; 134 let Map$ = core.Map$;
135 let double = core.double;
135 let int = core.int; 136 let int = core.int;
136 let num = core.num; 137 let num = core.num;
137 let bool = core.bool; 138 let bool = core.bool;
138 139
139 class A {} 140 class A {}
140 class B extends A {} 141 class B extends A {}
141 class C extends B {} 142 class C extends B {}
142 143
143 let AA$ = generic((T, U) => class AA extends core.Object {}); 144 let AA$ = generic((T, U) => class AA extends core.Object {});
144 let AA = AA$(); 145 let AA = AA$();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 test('String', () => { 277 test('String', () => {
277 expect(isGroundType(String), true); 278 expect(isGroundType(String), true);
278 expect(isGroundType(getReifiedType("foo")), true); 279 expect(isGroundType(getReifiedType("foo")), true);
279 checkType("foo", String); 280 checkType("foo", String);
280 checkType("foo", Object); 281 checkType("foo", Object);
281 checkType("foo", dynamic); 282 checkType("foo", dynamic);
282 283
283 expect(cast(null, String), null); 284 expect(cast(null, String), null);
284 }); 285 });
285 286
287 test('FutureOr', () => {
288 let FutureOr = async.FutureOr$;
289
290 assert.equal(dart.as(3, FutureOr(int)), 3);
291 assert.equal(dart.as(3, FutureOr(double)), 3);
292 assert.throws(() => dart.as(3.5, FutureOr(int)));
293 assert.equal(dart.as(3.5, FutureOr(double)), 3.5);
294 assert.isTrue(dart.is(3, FutureOr(int)));
295 assert.isTrue(dart.is(3, FutureOr(double)));
296 assert.isFalse(dart.is(3.5, FutureOr(int)));
297 assert.isTrue(dart.is(3.5, FutureOr(double)));
298 });
299
286 test('Map', () => { 300 test('Map', () => {
287 let m1 = new (Map$(String, String))(); 301 let m1 = new (Map$(String, String))();
288 let m2 = new (Map$(Object, Object))(); 302 let m2 = new (Map$(Object, Object))();
289 let m3 = new Map(); 303 let m3 = new Map();
290 let m4 = new (collection.HashMap$(dart.dynamic, dart.dynamic))(); 304 let m4 = new (collection.HashMap$(dart.dynamic, dart.dynamic))();
291 let m5 = new collection.LinkedHashMap(); 305 let m5 = new collection.LinkedHashMap();
292 let m6 = new (Map$(String, dart.dynamic))(); 306 let m6 = new (Map$(String, dart.dynamic))();
293 307
294 308
295 expect(isGroundType(Map), true); 309 expect(isGroundType(Map), true);
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 list[0] = 42; 1237 list[0] = 42;
1224 assert.throws(() => list.add(42)); 1238 assert.throws(() => list.add(42));
1225 }); 1239 });
1226 1240
1227 test('toString on ES Symbol', () => { 1241 test('toString on ES Symbol', () => {
1228 let sym = Symbol('_foobar'); 1242 let sym = Symbol('_foobar');
1229 assert.equal(dart.toString(sym), 'Symbol(_foobar)'); 1243 assert.equal(dart.toString(sym), 'Symbol(_foobar)');
1230 }); 1244 });
1231 }); 1245 });
1232 }); 1246 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698