| Index: tests/compiler/dart2js/simple_inferrer_test.dart
|
| ===================================================================
|
| --- tests/compiler/dart2js/simple_inferrer_test.dart (revision 22927)
|
| +++ tests/compiler/dart2js/simple_inferrer_test.dart (working copy)
|
| @@ -236,6 +236,24 @@
|
| return topLevelGetter() as Foo;
|
| }
|
|
|
| +testDeadCode() {
|
| + return 42;
|
| + return 'foo';
|
| +}
|
| +
|
| +testLabeledIf(a) {
|
| + var c;
|
| + L1: if (a > 1) {
|
| + if (a == 2) {
|
| + break L1;
|
| + }
|
| + c = 42;
|
| + } else {
|
| + c = 38;
|
| + }
|
| + return c;
|
| +}
|
| +
|
| testSwitch1() {
|
| var a = null;
|
| switch (topLevelGetter) {
|
| @@ -266,6 +284,54 @@
|
| return b;
|
| }
|
|
|
| +testContinue1() {
|
| + var a = 42;
|
| + var b;
|
| + while (true) {
|
| + b = a + 54;
|
| + if (b == 42) continue;
|
| + a = 'foo';
|
| + }
|
| + return b;
|
| +}
|
| +
|
| +testBreak1() {
|
| + var a = 42;
|
| + var b;
|
| + while (true) {
|
| + b = a + 54;
|
| + if (b == 42) break;
|
| + b = 'foo';
|
| + }
|
| + return b;
|
| +}
|
| +
|
| +testContinue2() {
|
| + var a = 42;
|
| + var b;
|
| + while (true) {
|
| + b = a + 54;
|
| + if (b == 42) {
|
| + b = 'foo';
|
| + continue;
|
| + }
|
| + }
|
| + return b;
|
| +}
|
| +
|
| +testBreak2() {
|
| + var a = 42;
|
| + var b;
|
| + while (true) {
|
| + b = a + 54;
|
| + if (b == 42) {
|
| + a = 'foo';
|
| + break;
|
| + }
|
| + }
|
| + return b;
|
| +}
|
| +
|
| get topLevelGetter => 42;
|
| returnDynamic() => topLevelGetter(42);
|
|
|
| @@ -337,9 +403,15 @@
|
| returnAsString();
|
| returnIntAsNum();
|
| returnAsTypedef();
|
| + testDeadCode();
|
| + testLabeledIf();
|
| testSwitch1();
|
| testSwitch2();
|
| testSwitch3();
|
| + testContinue1();
|
| + testBreak1();
|
| + testContinue2();
|
| + testBreak2();
|
| new A() == null;
|
| new A()..returnInt1()
|
| ..returnInt2()
|
| @@ -412,10 +484,16 @@
|
| new TypeMask.subtype(compiler.stringClass.computeType(compiler)));
|
| checkReturn('returnIntAsNum', typesInferrer.intType);
|
| checkReturn('returnAsTypedef', typesInferrer.functionType.nullable());
|
| + checkReturn('testDeadCode', typesInferrer.intType);
|
| + checkReturn('testLabeledIf', typesInferrer.intType.nullable());
|
| checkReturn('testSwitch1',
|
| typesInferrer.intType.union(typesInferrer.doubleType, compiler).nullable());
|
| checkReturn('testSwitch2', typesInferrer.intType);
|
| checkReturn('testSwitch3', interceptorType.nullable());
|
| + checkReturn('testContinue1', interceptorType.nullable());
|
| + checkReturn('testBreak1', interceptorType.nullable());
|
| + checkReturn('testContinue2', interceptorType.nullable());
|
| + checkReturn('testBreak2', typesInferrer.intType.nullable());
|
|
|
| checkReturnInClass(String className, String methodName, type) {
|
| var cls = findElement(compiler, className);
|
|
|