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

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

Issue 1124433007: Fix constant evaluation logic for String.length. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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) 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.all_the_rest_test; 8 library engine.all_the_rest_test;
9 9
10 import 'dart:collection'; 10 import 'dart:collection';
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after
2070 expect(ConstantValueComputer.isValidPublicSymbol("if"), isFalse); 2070 expect(ConstantValueComputer.isValidPublicSymbol("if"), isFalse);
2071 expect(ConstantValueComputer.isValidPublicSymbol("if.foo"), isFalse); 2071 expect(ConstantValueComputer.isValidPublicSymbol("if.foo"), isFalse);
2072 expect(ConstantValueComputer.isValidPublicSymbol("foo.if"), isFalse); 2072 expect(ConstantValueComputer.isValidPublicSymbol("foo.if"), isFalse);
2073 expect(ConstantValueComputer.isValidPublicSymbol("foo=.bar"), isFalse); 2073 expect(ConstantValueComputer.isValidPublicSymbol("foo=.bar"), isFalse);
2074 expect(ConstantValueComputer.isValidPublicSymbol("foo."), isFalse); 2074 expect(ConstantValueComputer.isValidPublicSymbol("foo."), isFalse);
2075 expect(ConstantValueComputer.isValidPublicSymbol("+.foo"), isFalse); 2075 expect(ConstantValueComputer.isValidPublicSymbol("+.foo"), isFalse);
2076 expect(ConstantValueComputer.isValidPublicSymbol("void.foo"), isFalse); 2076 expect(ConstantValueComputer.isValidPublicSymbol("void.foo"), isFalse);
2077 expect(ConstantValueComputer.isValidPublicSymbol("foo.void"), isFalse); 2077 expect(ConstantValueComputer.isValidPublicSymbol("foo.void"), isFalse);
2078 } 2078 }
2079 2079
2080 void test_length_of_improperly_typed_string_expression() {
2081 // Since type annotations are ignored in unchecked mode, the improper
2082 // types on s1 and s2 shouldn't prevent us from evaluating i to
2083 // 'alpha'.length.
2084 CompilationUnit compilationUnit = resolveSource('''
2085 const int s1 = 'alpha';
2086 const int s2 = 'beta';
2087 const int i = (true ? s1 : s2).length;
2088 ''');
2089 ConstTopLevelVariableElementImpl element =
2090 findTopLevelDeclaration(compilationUnit, 'i').element;
2091 EvaluationResultImpl result = element.evaluationResult;
2092 expect(_assertValidInt(result), 5);
2093 }
2094
2095 void test_length_of_improperly_typed_string_identifier() {
2096 // Since type annotations are ignored in unchecked mode, the improper type
2097 // on s shouldn't prevent us from evaluating i to 'alpha'.length.
2098 CompilationUnit compilationUnit = resolveSource('''
2099 const int s = 'alpha';
2100 const int i = s.length;
2101 ''');
2102 ConstTopLevelVariableElementImpl element =
2103 findTopLevelDeclaration(compilationUnit, 'i').element;
2104 EvaluationResultImpl result = element.evaluationResult;
2105 expect(_assertValidInt(result), 5);
2106 }
2107
2080 void test_symbolLiteral_void() { 2108 void test_symbolLiteral_void() {
2081 CompilationUnit compilationUnit = 2109 CompilationUnit compilationUnit =
2082 resolveSource("const voidSymbol = #void;"); 2110 resolveSource("const voidSymbol = #void;");
2083 VariableDeclaration voidSymbol = 2111 VariableDeclaration voidSymbol =
2084 findTopLevelDeclaration(compilationUnit, "voidSymbol"); 2112 findTopLevelDeclaration(compilationUnit, "voidSymbol");
2085 EvaluationResultImpl voidSymbolResult = 2113 EvaluationResultImpl voidSymbolResult =
2086 (voidSymbol.element as VariableElementImpl).evaluationResult; 2114 (voidSymbol.element as VariableElementImpl).evaluationResult;
2087 DartObjectImpl value = voidSymbolResult.value; 2115 DartObjectImpl value = voidSymbolResult.value;
2088 expect(value.type, typeProvider.symbolType); 2116 expect(value.type, typeProvider.symbolType);
2089 expect(value.value, "void"); 2117 expect(value.value, "void");
(...skipping 6694 matching lines...) Expand 10 before | Expand all | Expand 10 after
8784 if (_expectedExternalScriptName == null) { 8812 if (_expectedExternalScriptName == null) {
8785 expect(scriptSource, isNull, reason: "script $scriptIndex"); 8813 expect(scriptSource, isNull, reason: "script $scriptIndex");
8786 } else { 8814 } else {
8787 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 8815 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
8788 String actualExternalScriptName = scriptSource.shortName; 8816 String actualExternalScriptName = scriptSource.shortName;
8789 expect(actualExternalScriptName, _expectedExternalScriptName, 8817 expect(actualExternalScriptName, _expectedExternalScriptName,
8790 reason: "script $scriptIndex"); 8818 reason: "script $scriptIndex");
8791 } 8819 }
8792 } 8820 }
8793 } 8821 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698