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

Unified Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java

Issue 376043002: Report errors when an exception would occur during const fromEnvironment calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Re-enable shared tests for dart2analyzer Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
diff --git a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
index ecba99e4c65c4699c5c23d0678f24f245fad5ab3..cc2c2c582c912fe863420b1bda6b8a38ac2fda6d 100644
--- a/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
+++ b/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/resolver/CompileTimeErrorCodeTest.java
@@ -1584,6 +1584,34 @@ public class CompileTimeErrorCodeTest extends ResolverTestCase {
verify(source);
}
+ public void test_fromEnvironment_bool_badArgs() throws Exception {
+ Source source = addSource(createSource(//
+ "var b1 = const bool.fromEnvironment(1);",
+ "var b2 = const bool.fromEnvironment('x', defaultValue: 1);"));
+ resolve(source);
+ assertErrors(
+ source,
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+ StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE,
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+ StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
+ verify(source);
+ }
+
+ public void test_fromEnvironment_bool_badDefault_whenDefined() throws Exception {
+ // The type of the defaultValue needs to be correct even when the default value
+ // isn't used (because the variable is defined in the environment).
+ analysisContext.getDeclaredVariables().define("x", "true");
+ Source source = addSource(createSource(//
+ "var b = const bool.fromEnvironment('x', defaultValue: 1);"));
+ resolve(source);
+ assertErrors(
+ source,
+ CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION,
+ StaticWarningCode.ARGUMENT_TYPE_NOT_ASSIGNABLE);
+ verify(source);
+ }
+
public void test_getterAndMethodWithSameName() throws Exception {
Source source = addSource(createSource(//
"class A {",

Powered by Google App Engine
This is Rietveld 408576698