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

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

Issue 930703002: Constant top-level variables should not have setters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 expect(cache.setContents(source, contents), contents); 2394 expect(cache.setContents(source, contents), contents);
2395 expect(cache.setContents(source, null), contents); 2395 expect(cache.setContents(source, null), contents);
2396 expect(cache.getContents(source), isNull); 2396 expect(cache.getContents(source), isNull);
2397 expect(cache.getModificationStamp(source), isNull); 2397 expect(cache.getModificationStamp(source), isNull);
2398 expect(cache.setContents(source, null), isNull); 2398 expect(cache.setContents(source, null), isNull);
2399 } 2399 }
2400 } 2400 }
2401 2401
2402 2402
2403 @reflectiveTest 2403 @reflectiveTest
2404 class CustomUriResolverTest {
2405 void test_creation() {
2406 expect(new CustomUriResolver({}), isNotNull);
2407 }
2408
2409 void test_resolve_unknown_uri() {
2410 UriResolver resolver = new CustomUriResolver({
2411 'custom:library': '/path/to/library.dart',
2412 });
2413 Source result = resolver.resolveAbsolute(
2414 parseUriWithException("custom:non_library"));
2415 expect(result, isNull);
2416 }
2417
2418 void test_resolve_uri() {
2419 String path =
2420 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath();
2421 UriResolver resolver = new CustomUriResolver({
2422 'custom:library': path,
2423 });
2424 Source result = resolver.resolveAbsolute(
2425 parseUriWithException("custom:library"));
2426 expect(result, isNotNull);
2427 expect(result.fullName, path);
2428 }
2429 }
2430
2431
2432 @reflectiveTest
2404 class DartObjectImplTest extends EngineTestCase { 2433 class DartObjectImplTest extends EngineTestCase {
2405 TypeProvider _typeProvider = new TestTypeProvider(); 2434 TypeProvider _typeProvider = new TestTypeProvider();
2406 2435
2407 void fail_add_knownString_knownString() { 2436 void fail_add_knownString_knownString() {
2408 fail("New constant semantics are not yet enabled"); 2437 fail("New constant semantics are not yet enabled");
2409 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b")); 2438 _assertAdd(_stringValue("ab"), _stringValue("a"), _stringValue("b"));
2410 } 2439 }
2411 2440
2412 void fail_add_knownString_unknownString() { 2441 void fail_add_knownString_unknownString() {
2413 fail("New constant semantics are not yet enabled"); 2442 fail("New constant semantics are not yet enabled");
(...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after
6162 expect(variable, isNotNull); 6191 expect(variable, isNotNull);
6163 expect(variable.initializer, isNull); 6192 expect(variable.initializer, isNull);
6164 expect(variable.name, variableName); 6193 expect(variable.name, variableName);
6165 expect(variable.isConst, isFalse); 6194 expect(variable.isConst, isFalse);
6166 expect(variable.isFinal, isFalse); 6195 expect(variable.isFinal, isFalse);
6167 expect(variable.isSynthetic, isFalse); 6196 expect(variable.isSynthetic, isFalse);
6168 expect(variable.getter, isNotNull); 6197 expect(variable.getter, isNotNull);
6169 expect(variable.setter, isNotNull); 6198 expect(variable.setter, isNotNull);
6170 } 6199 }
6171 6200
6201 void test_visitVariableDeclaration_top_const_hasInitializer() {
6202 ElementHolder holder = new ElementHolder();
6203 ElementBuilder builder = new ElementBuilder(holder);
6204 String variableName = "v";
6205 VariableDeclaration variableDeclaration =
6206 AstFactory.variableDeclaration2(variableName, AstFactory.integer(42));
6207 AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]);
6208 variableDeclaration.accept(builder);
6209 List<TopLevelVariableElement> variables = holder.topLevelVariables;
6210 expect(variables, hasLength(1));
6211 TopLevelVariableElement variable = variables[0];
6212 expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>());
6213 expect(variable.initializer, isNotNull);
6214 expect(variable.name, variableName);
6215 expect(variable.isConst, isTrue);
6216 expect(variable.isFinal, isFalse);
6217 expect(variable.isSynthetic, isFalse);
6218 expect(variable.getter, isNotNull);
6219 expect(variable.setter, isNull);
6220 }
6221
6222 void test_visitVariableDeclaration_top_final() {
6223 ElementHolder holder = new ElementHolder();
6224 ElementBuilder builder = new ElementBuilder(holder);
6225 String variableName = "v";
6226 VariableDeclaration variableDeclaration =
6227 AstFactory.variableDeclaration2(variableName, null);
6228 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]);
6229 variableDeclaration.accept(builder);
6230 List<TopLevelVariableElement> variables = holder.topLevelVariables;
6231 expect(variables, hasLength(1));
6232 TopLevelVariableElement variable = variables[0];
6233 expect(variable, isNotNull);
6234 expect(variable.initializer, isNull);
6235 expect(variable.name, variableName);
6236 expect(variable.isConst, isFalse);
6237 expect(variable.isFinal, isTrue);
6238 expect(variable.isSynthetic, isFalse);
6239 expect(variable.getter, isNotNull);
6240 expect(variable.setter, isNull);
6241 }
6242
6172 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset, 6243 void _useParameterInMethod(FormalParameter formalParameter, int blockOffset,
6173 int blockEnd) { 6244 int blockEnd) {
6174 Block block = AstFactory.block(); 6245 Block block = AstFactory.block();
6175 block.leftBracket.offset = blockOffset; 6246 block.leftBracket.offset = blockOffset;
6176 block.rightBracket.offset = blockEnd - 1; 6247 block.rightBracket.offset = blockEnd - 1;
6177 BlockFunctionBody body = AstFactory.blockFunctionBody(block); 6248 BlockFunctionBody body = AstFactory.blockFunctionBody(block);
6178 AstFactory.methodDeclaration2( 6249 AstFactory.methodDeclaration2(
6179 null, 6250 null,
6180 null, 6251 null,
6181 null, 6252 null,
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
6786 new ErrorReporter(listener, firstType.element.source); 6857 new ErrorReporter(listener, firstType.element.source);
6787 reporter.reportTypeErrorForNode( 6858 reporter.reportTypeErrorForNode(
6788 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE, 6859 StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
6789 AstFactory.identifier3("x"), 6860 AstFactory.identifier3("x"),
6790 [firstType, secondType]); 6861 [firstType, secondType]);
6791 AnalysisError error = listener.errors[0]; 6862 AnalysisError error = listener.errors[0];
6792 expect(error.message.indexOf("(") >= 0, isTrue); 6863 expect(error.message.indexOf("(") >= 0, isTrue);
6793 } 6864 }
6794 } 6865 }
6795 6866
6796
6797 @reflectiveTest 6867 @reflectiveTest
6798 class ErrorSeverityTest extends EngineTestCase { 6868 class ErrorSeverityTest extends EngineTestCase {
6799 void test_max_error_error() { 6869 void test_max_error_error() {
6800 expect( 6870 expect(
6801 ErrorSeverity.ERROR.max(ErrorSeverity.ERROR), 6871 ErrorSeverity.ERROR.max(ErrorSeverity.ERROR),
6802 same(ErrorSeverity.ERROR)); 6872 same(ErrorSeverity.ERROR));
6803 } 6873 }
6804 6874
6805 void test_max_error_none() { 6875 void test_max_error_none() {
6806 expect( 6876 expect(
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
7345 void _assertHasReturn(bool expectedResult, String source) { 7415 void _assertHasReturn(bool expectedResult, String source) {
7346 Statement statement = ParserTestCase.parseStatement(source); 7416 Statement statement = ParserTestCase.parseStatement(source);
7347 expect(ExitDetector.exits(statement), expectedResult); 7417 expect(ExitDetector.exits(statement), expectedResult);
7348 } 7418 }
7349 7419
7350 void _assertTrue(String source) { 7420 void _assertTrue(String source) {
7351 _assertHasReturn(true, source); 7421 _assertHasReturn(true, source);
7352 } 7422 }
7353 } 7423 }
7354 7424
7425
7355 /** 7426 /**
7356 * Tests for the [ExitDetector] that require that the AST be resolved. 7427 * Tests for the [ExitDetector] that require that the AST be resolved.
7357 * 7428 *
7358 * See [ExitDetectorTest] for tests that do not require the AST to be resolved. 7429 * See [ExitDetectorTest] for tests that do not require the AST to be resolved.
7359 */ 7430 */
7360 @reflectiveTest 7431 @reflectiveTest
7361 class ExitDetectorTest2 extends ResolverTestCase { 7432 class ExitDetectorTest2 extends ResolverTestCase {
7362 void test_switch_withEnum_false_noDefault() { 7433 void test_switch_withEnum_false_noDefault() {
7363 Source source = addSource(r''' 7434 Source source = addSource(r'''
7364 enum E { A, B } 7435 enum E { A, B }
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
7723 void test_resolve_nonFile() { 7794 void test_resolve_nonFile() {
7724 UriResolver resolver = new FileUriResolver(); 7795 UriResolver resolver = new FileUriResolver();
7725 Source result = 7796 Source result =
7726 resolver.resolveAbsolute(parseUriWithException("dart:core")); 7797 resolver.resolveAbsolute(parseUriWithException("dart:core"));
7727 expect(result, isNull); 7798 expect(result, isNull);
7728 } 7799 }
7729 } 7800 }
7730 7801
7731 7802
7732 @reflectiveTest 7803 @reflectiveTest
7733 class CustomUriResolverTest {
7734 void test_creation() {
7735 expect(new CustomUriResolver({}), isNotNull);
7736 }
7737
7738 void test_resolve_unknown_uri() {
7739 UriResolver resolver = new CustomUriResolver({
7740 'custom:library': '/path/to/library.dart',
7741 });
7742 Source result = resolver.resolveAbsolute(
7743 parseUriWithException("custom:non_library"));
7744 expect(result, isNull);
7745 }
7746
7747 void test_resolve_uri() {
7748 String path =
7749 FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath();
7750 UriResolver resolver = new CustomUriResolver({
7751 'custom:library': path,
7752 });
7753 Source result = resolver.resolveAbsolute(
7754 parseUriWithException("custom:library"));
7755 expect(result, isNotNull);
7756 expect(result.fullName, path);
7757 }
7758 }
7759
7760
7761 @reflectiveTest
7762 class HtmlParserTest extends EngineTestCase { 7804 class HtmlParserTest extends EngineTestCase {
7763 /** 7805 /**
7764 * The name of the 'script' tag in an HTML file. 7806 * The name of the 'script' tag in an HTML file.
7765 */ 7807 */
7766 static String _TAG_SCRIPT = "script"; 7808 static String _TAG_SCRIPT = "script";
7767 void fail_parse_scriptWithComment() { 7809 void fail_parse_scriptWithComment() {
7768 String scriptBody = r''' 7810 String scriptBody = r'''
7769 /** 7811 /**
7770 * <editable-label bind-value="dartAsignableValue"> 7812 * <editable-label bind-value="dartAsignableValue">
7771 * </editable-label> 7813 * </editable-label>
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
9003 } else { 9045 } else {
9004 expect(scriptSource, isNotNull, reason: "script $scriptIndex"); 9046 expect(scriptSource, isNotNull, reason: "script $scriptIndex");
9005 String actualExternalScriptName = scriptSource.shortName; 9047 String actualExternalScriptName = scriptSource.shortName;
9006 expect( 9048 expect(
9007 actualExternalScriptName, 9049 actualExternalScriptName,
9008 _expectedExternalScriptName, 9050 _expectedExternalScriptName,
9009 reason: "script $scriptIndex"); 9051 reason: "script $scriptIndex");
9010 } 9052 }
9011 } 9053 }
9012 } 9054 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698