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

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1331433003: Fix handling of shortcutting expressions and asserts in ExitDetector. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.all_the_rest_test; 5 library engine.all_the_rest_test;
6 6
7 import 'package:analyzer/file_system/physical_file_system.dart'; 7 import 'package:analyzer/file_system/physical_file_system.dart';
8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator; 8 import 'package:analyzer/src/generated/ast.dart' hide ConstantEvaluator;
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 7333 matching lines...) Expand 10 before | Expand all | Expand 10 after
7344 7344
7345 void test_asExpression_throw() { 7345 void test_asExpression_throw() {
7346 _assertTrue("throw '' as Object;"); 7346 _assertTrue("throw '' as Object;");
7347 } 7347 }
7348 7348
7349 void test_assertStatement() { 7349 void test_assertStatement() {
7350 _assertFalse("assert(a);"); 7350 _assertFalse("assert(a);");
7351 } 7351 }
7352 7352
7353 void test_assertStatement_throw() { 7353 void test_assertStatement_throw() {
7354 _assertTrue("assert((throw 0));"); 7354 _assertFalse("assert((throw 0));");
7355 } 7355 }
7356 7356
7357 void test_assignmentExpression() { 7357 void test_assignmentExpression() {
7358 _assertFalse("v = 1;"); 7358 _assertFalse("v = 1;");
7359 } 7359 }
7360 7360
7361 void test_assignmentExpression_lhs_throw() { 7361 void test_assignmentExpression_lhs_throw() {
7362 _assertTrue("a[throw ''] = 0;"); 7362 _assertTrue("a[throw ''] = 0;");
7363 } 7363 }
7364 7364
(...skipping 11 matching lines...) Expand all
7376 7376
7377 void test_binaryExpression_and() { 7377 void test_binaryExpression_and() {
7378 _assertFalse("a && b;"); 7378 _assertFalse("a && b;");
7379 } 7379 }
7380 7380
7381 void test_binaryExpression_and_lhs() { 7381 void test_binaryExpression_and_lhs() {
7382 _assertTrue("throw '' && b;"); 7382 _assertTrue("throw '' && b;");
7383 } 7383 }
7384 7384
7385 void test_binaryExpression_and_rhs() { 7385 void test_binaryExpression_and_rhs() {
7386 _assertTrue("a && (throw '');"); 7386 _assertFalse("a && (throw '');");
7387 } 7387 }
7388 7388
7389 void test_binaryExpression_and_rhs2() { 7389 void test_binaryExpression_and_rhs2() {
7390 _assertTrue("false && (throw '');"); 7390 _assertFalse("false && (throw '');");
7391 } 7391 }
7392 7392
7393 void test_binaryExpression_and_rhs3() { 7393 void test_binaryExpression_and_rhs3() {
7394 _assertFalse("true && (throw '');"); 7394 _assertTrue("true && (throw '');");
7395 }
7396
7397 void test_binaryExpression_ifNull() {
7398 _assertFalse("a ?? b;");
7399 }
7400
7401 void test_binaryExpression_ifNull_lhs() {
7402 _assertTrue("throw '' ?? b;");
7403 }
7404
7405 void test_binaryExpression_ifNull_rhs() {
7406 _assertFalse("a ?? (throw '');");
7407 }
7408
7409 void test_binaryExpression_ifNull_rhs2() {
7410 _assertFalse("null ?? (throw '');");
7395 } 7411 }
7396 7412
7397 void test_binaryExpression_or() { 7413 void test_binaryExpression_or() {
7398 _assertFalse("a || b;"); 7414 _assertFalse("a || b;");
7399 } 7415 }
7400 7416
7401 void test_binaryExpression_or_lhs() { 7417 void test_binaryExpression_or_lhs() {
7402 _assertTrue("throw '' || b;"); 7418 _assertTrue("throw '' || b;");
7403 } 7419 }
7404 7420
7405 void test_binaryExpression_or_rhs() { 7421 void test_binaryExpression_or_rhs() {
7406 _assertTrue("a || (throw '');"); 7422 _assertFalse("a || (throw '');");
7407 } 7423 }
7408 7424
7409 void test_binaryExpression_or_rhs2() { 7425 void test_binaryExpression_or_rhs2() {
7410 _assertTrue("true || (throw '');"); 7426 _assertFalse("true || (throw '');");
7411 } 7427 }
7412 7428
7413 void test_binaryExpression_or_rhs3() { 7429 void test_binaryExpression_or_rhs3() {
7414 _assertFalse("false || (throw '');"); 7430 _assertTrue("false || (throw '');");
7415 } 7431 }
7416 7432
7417 void test_block_empty() { 7433 void test_block_empty() {
7418 _assertFalse("{}"); 7434 _assertFalse("{}");
7419 } 7435 }
7420 7436
7421 void test_block_noReturn() { 7437 void test_block_noReturn() {
7422 _assertFalse("{ int i = 0; }"); 7438 _assertFalse("{ int i = 0; }");
7423 } 7439 }
7424 7440
(...skipping 30 matching lines...) Expand all
7455 } 7471 }
7456 7472
7457 void test_conditional_ifElse_noThrow() { 7473 void test_conditional_ifElse_noThrow() {
7458 _assertFalse("c ? i : j;"); 7474 _assertFalse("c ? i : j;");
7459 } 7475 }
7460 7476
7461 void test_conditional_ifElse_thenThrow() { 7477 void test_conditional_ifElse_thenThrow() {
7462 _assertFalse("c ? throw '' : j;"); 7478 _assertFalse("c ? throw '' : j;");
7463 } 7479 }
7464 7480
7481 void test_conditionalAccess() {
7482 _assertFalse("a?.b;");
7483 }
7484
7485 void test_conditionalAccess_lhs() {
7486 _assertTrue("(throw '')?.b;");
7487 }
7488
7489 void test_conditionalAccessAssign() {
7490 _assertFalse("a?.b = c;");
7491 }
7492
7493 void test_conditionalAccessAssign_lhs() {
7494 _assertTrue("(throw '')?.b = c;");
7495 }
7496
7497 void test_conditionalAccessAssign_rhs() {
7498 _assertFalse("a?.b = throw '';");
7499 }
7500
7501 void test_conditionalAccessAssign_rhs2() {
7502 _assertFalse("null?.b = throw '';");
7503 }
7504
7505 void test_conditionalAccessIfNullAssign() {
7506 _assertFalse("a?.b ??= c;");
7507 }
7508
7509 void test_conditionalAccessIfNullAssign_lhs() {
7510 _assertTrue("(throw '')?.b ??= c;");
7511 }
7512
7513 void test_conditionalAccessIfNullAssign_rhs() {
7514 _assertFalse("a?.b ??= throw '';");
7515 }
7516
7517 void test_conditionalAccessIfNullAssign_rhs2() {
7518 _assertFalse("null?.b ??= throw '';");
7519 }
7520
7521 void test_conditionalCall() {
7522 _assertFalse("a?.b(c);");
7523 }
7524
7525 void test_conditionalCall_lhs() {
7526 _assertTrue("(throw '')?.b(c);");
7527 }
7528
7529 void test_conditionalCall_rhs() {
7530 _assertFalse("a?.b(throw '');");
7531 }
7532
7533 void test_conditionalCall_rhs2() {
7534 _assertFalse("null?.b(throw '');");
7535 }
7536
7465 void test_creation() { 7537 void test_creation() {
7466 expect(new ExitDetector(), isNotNull); 7538 expect(new ExitDetector(), isNotNull);
7467 } 7539 }
7468 7540
7469 void test_doStatement_throwCondition() { 7541 void test_doStatement_throwCondition() {
7470 _assertTrue("{ do {} while (throw ''); }"); 7542 _assertTrue("{ do {} while (throw ''); }");
7471 } 7543 }
7472 7544
7473 void test_doStatement_true_break() { 7545 void test_doStatement_true_break() {
7474 _assertFalse("{ do { break; } while (true); }"); 7546 _assertFalse("{ do { break; } while (true); }");
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
7611 } 7683 }
7612 7684
7613 void test_ifElse_noReturn() { 7685 void test_ifElse_noReturn() {
7614 _assertFalse("if (c) i++; else j++;"); 7686 _assertFalse("if (c) i++; else j++;");
7615 } 7687 }
7616 7688
7617 void test_ifElse_thenReturn() { 7689 void test_ifElse_thenReturn() {
7618 _assertFalse("if (c) return 0; else j++;"); 7690 _assertFalse("if (c) return 0; else j++;");
7619 } 7691 }
7620 7692
7693 void test_ifNullAssign() {
7694 _assertFalse("a ??= b;");
7695 }
7696
7697 void test_ifNullAssign_rhs() {
7698 _assertFalse("a ??= throw '';");
7699 }
7700
7621 void test_indexExpression() { 7701 void test_indexExpression() {
7622 _assertFalse("a[b];"); 7702 _assertFalse("a[b];");
7623 } 7703 }
7624 7704
7625 void test_indexExpression_index() { 7705 void test_indexExpression_index() {
7626 _assertTrue("a[throw ''];"); 7706 _assertTrue("a[throw ''];");
7627 } 7707 }
7628 7708
7629 void test_indexExpression_target() { 7709 void test_indexExpression_target() {
7630 _assertTrue("throw ''[b];"); 7710 _assertTrue("throw ''[b];");
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
9218 if (_expectedExternalScriptName == null) { 9298 if (_expectedExternalScriptName == null) {
9219 expect(scriptSource, isNull, reason: "script $scriptIndex"); 9299 expect(scriptSource, isNull, reason: "script $scriptIndex");
9220 } else { 9300 } else {
9221 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9301 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9222 String actualExternalScriptName = scriptSource.shortName; 9302 String actualExternalScriptName = scriptSource.shortName;
9223 expect(actualExternalScriptName, _expectedExternalScriptName, 9303 expect(actualExternalScriptName, _expectedExternalScriptName,
9224 reason: "script $scriptIndex"); 9304 reason: "script $scriptIndex");
9225 } 9305 }
9226 } 9306 }
9227 } 9307 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698