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

Side by Side Diff: tests/compiler/dart2js/cpa_inference_test.dart

Issue 24952003: Change TypeMask.base to be a ClassElement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Moar declaration. Created 7 years, 2 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import 'dart:async'; 5 import 'dart:async';
6 import "package:expect/expect.dart"; 6 import "package:expect/expect.dart";
7 import "package:async_helper/async_helper.dart"; 7 import "package:async_helper/async_helper.dart";
8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart'; 8 import '../../../sdk/lib/_internal/compiler/implementation/source_file.dart';
9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart'; 9 import '../../../sdk/lib/_internal/compiler/implementation/types/types.dart';
10 import '../../../sdk/lib/_internal/compiler/implementation/types/concrete_types_ inferrer.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/types/concrete_types_ inferrer.dart';
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1368 var x = "__dynamic_for_test".truncate(); 1368 var x = "__dynamic_for_test".truncate();
1369 x; 1369 x;
1370 } 1370 }
1371 """; 1371 """;
1372 return analyze(source1).then((AnalysisResult result) { 1372 return analyze(source1).then((AnalysisResult result) {
1373 result.checkNodeHasType('x', []); 1373 result.checkNodeHasType('x', []);
1374 }).whenComplete(() { 1374 }).whenComplete(() {
1375 1375
1376 final String source2 = r""" 1376 final String source2 = r"""
1377 import 'dart:foreign'; 1377 import 'dart:foreign';
1378 1378
1379 main () { 1379 main () {
1380 var x = "__dynamic_for_test".truncate(); 1380 var x = "__dynamic_for_test".truncate();
1381 JS('double', 'foo'); 1381 JS('double', 'foo');
1382 x; 1382 x;
1383 } 1383 }
1384 """; 1384 """;
1385 return analyze(source2).then((AnalysisResult result) { 1385 return analyze(source2).then((AnalysisResult result) {
1386 result.checkNodeHasType('x', [result.int]); 1386 result.checkNodeHasType('x', [result.int]);
1387 }); 1387 });
1388 }); 1388 });
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 .singletonConcreteType(new ClassBaseType(element)); 1473 .singletonConcreteType(new ClassBaseType(element));
1474 } 1474 }
1475 1475
1476 ClassElement a = findElement(result.compiler, 'A'); 1476 ClassElement a = findElement(result.compiler, 'A');
1477 ClassElement b = findElement(result.compiler, 'B'); 1477 ClassElement b = findElement(result.compiler, 'B');
1478 ClassElement c = findElement(result.compiler, 'C'); 1478 ClassElement c = findElement(result.compiler, 'C');
1479 ClassElement d = findElement(result.compiler, 'D'); 1479 ClassElement d = findElement(result.compiler, 'D');
1480 1480
1481 for (ClassElement cls in [a, b, c, d]) { 1481 for (ClassElement cls in [a, b, c, d]) {
1482 Expect.equals(convert(singleton(cls)), 1482 Expect.equals(convert(singleton(cls)),
1483 new TypeMask.nonNullExact(cls.rawType)); 1483 new TypeMask.nonNullExact(cls));
1484 } 1484 }
1485 1485
1486 for (ClassElement cls in [a, b, c, d]) { 1486 for (ClassElement cls in [a, b, c, d]) {
1487 Expect.equals(convert(singleton(cls).union(nullSingleton)), 1487 Expect.equals(convert(singleton(cls).union(nullSingleton)),
1488 new TypeMask.exact(cls.rawType)); 1488 new TypeMask.exact(cls));
1489 } 1489 }
1490 1490
1491 Expect.equals(convert(singleton(a).union(singleton(b))), 1491 Expect.equals(convert(singleton(a).union(singleton(b))),
1492 new TypeMask.nonNullSubclass(a.rawType)); 1492 new TypeMask.nonNullSubclass(a));
1493 1493
1494 Expect.equals( 1494 Expect.equals(
1495 convert(singleton(a).union(singleton(b)).union(nullSingleton)), 1495 convert(singleton(a).union(singleton(b)).union(nullSingleton)),
1496 new TypeMask.subclass(a.rawType)); 1496 new TypeMask.subclass(a));
1497 1497
1498 Expect.equals( 1498 Expect.equals(
1499 convert(singleton(b).union(singleton(d))).simplify(result.compiler), 1499 convert(singleton(b).union(singleton(d))).simplify(result.compiler),
1500 new TypeMask.nonNullSubtype(a.rawType)); 1500 new TypeMask.nonNullSubtype(a));
1501 }); 1501 });
1502 } 1502 }
1503 1503
1504 testSelectors() { 1504 testSelectors() {
1505 final String source = r""" 1505 final String source = r"""
1506 // ABC <--- A 1506 // ABC <--- A
1507 // `- BC <--- B 1507 // `- BC <--- B
1508 // `- C 1508 // `- C
1509 1509
1510 class ABC {} 1510 class ABC {}
(...skipping 27 matching lines...) Expand all
1538 ClassElement c = findElement(result.compiler, 'C'); 1538 ClassElement c = findElement(result.compiler, 'C');
1539 ClassElement xy = findElement(result.compiler, 'XY'); 1539 ClassElement xy = findElement(result.compiler, 'XY');
1540 ClassElement x = findElement(result.compiler, 'X'); 1540 ClassElement x = findElement(result.compiler, 'X');
1541 ClassElement y = findElement(result.compiler, 'Y'); 1541 ClassElement y = findElement(result.compiler, 'Y');
1542 ClassElement z = findElement(result.compiler, 'Z'); 1542 ClassElement z = findElement(result.compiler, 'Z');
1543 1543
1544 Selector foo = new Selector.call(buildSourceString("foo"), null, 0); 1544 Selector foo = new Selector.call(buildSourceString("foo"), null, 0);
1545 1545
1546 Expect.equals( 1546 Expect.equals(
1547 inferredType(foo).simplify(result.compiler), 1547 inferredType(foo).simplify(result.compiler),
1548 new TypeMask.nonNullSubclass(abc.rawType)); 1548 new TypeMask.nonNullSubclass(abc));
1549 Expect.equals( 1549 Expect.equals(
1550 inferredType(new TypedSelector.subclass(x.rawType, foo)), 1550 inferredType(new TypedSelector.subclass(x, foo)),
1551 new TypeMask.nonNullExact(b.rawType)); 1551 new TypeMask.nonNullExact(b));
1552 Expect.equals( 1552 Expect.equals(
1553 inferredType(new TypedSelector.subclass(y.rawType, foo)), 1553 inferredType(new TypedSelector.subclass(y, foo)),
1554 new TypeMask.nonNullExact(c.rawType)); 1554 new TypeMask.nonNullExact(c));
1555 Expect.equals( 1555 Expect.equals(
1556 inferredType(new TypedSelector.subclass(z.rawType, foo)), 1556 inferredType(new TypedSelector.subclass(z, foo)),
1557 new TypeMask.nonNullExact(a.rawType)); 1557 new TypeMask.nonNullExact(a));
1558 Expect.equals( 1558 Expect.equals(
1559 inferredType(new TypedSelector.subclass( 1559 inferredType(new TypedSelector.subclass(
1560 xy.rawType, foo)).simplify(result.compiler), 1560 xy, foo)).simplify(result.compiler),
1561 new TypeMask.nonNullSubclass(bc.rawType)); 1561 new TypeMask.nonNullSubclass(bc));
1562 1562
1563 Selector bar = new Selector.call(buildSourceString("bar"), null, 0); 1563 Selector bar = new Selector.call(buildSourceString("bar"), null, 0);
1564 1564
1565 Expect.isNull(inferredType(bar)); 1565 Expect.isNull(inferredType(bar));
1566 }); 1566 });
1567 } 1567 }
1568 1568
1569 testMixins() { 1569 testMixins() {
1570 final String source = r""" 1570 final String source = r"""
1571 class A { 1571 class A {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1700 testIsCheck, 1700 testIsCheck,
1701 testSeenClasses, 1701 testSeenClasses,
1702 testIntDoubleNum, 1702 testIntDoubleNum,
1703 testConcreteTypeToTypeMask, 1703 testConcreteTypeToTypeMask,
1704 testSelectors, 1704 testSelectors,
1705 testMixins, 1705 testMixins,
1706 testClosures, 1706 testClosures,
1707 testNestedFunctions, 1707 testNestedFunctions,
1708 ], (f) => f())); 1708 ], (f) => f()));
1709 } 1709 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/compiler_helper.dart ('k') | tests/compiler/dart2js/field_type_simple_inferer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698