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

Side by Side Diff: compiler/javatests/com/google/dart/compiler/resolver/CompileTimeConstantTest.java

Issue 10825335: Issue 4294. Const constructor cannot call methods (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.resolver; 5 package com.google.dart.compiler.resolver;
6 6
7 import static com.google.dart.compiler.common.ErrorExpectation.errEx; 7 import static com.google.dart.compiler.common.ErrorExpectation.errEx;
8 8
9 import com.google.common.base.Joiner; 9 import com.google.common.base.Joiner;
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 "// filler filler filler filler filler filler filler filler filler f iller", 112 "// filler filler filler filler filler filler filler filler filler f iller",
113 "class Object {}", 113 "class Object {}",
114 "foo() {}", 114 "foo() {}",
115 "class A {", 115 "class A {",
116 " final v;", 116 " final v;",
117 " const A() : v = foo();", 117 " const A() : v = foo();",
118 "}", 118 "}",
119 ""), 119 ""),
120 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 6, 18, 5)); 120 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 6, 18, 5));
121 } 121 }
122 122
123 /**
124 * <p>
125 * http://code.google.com/p/dart/issues/detail?id=4294
126 */
127 public void test_constConstructor_redirectInvocation() throws Exception {
128 resolveAndTestCtConstExpectErrors(
129 Joiner.on("\n").join(
130 "// filler filler filler filler filler filler filler filler filler f iller",
131 "class Object {}",
132 "class A {",
133 " final v;",
134 " const A(this.v);",
135 " const A.hasValue() : this(generateValue());",
136 " static generateValue() => 42;",
137 "}"),
138 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 6, 29, 15));
139 }
140
141 /**
142 * <p>
143 * http://code.google.com/p/dart/issues/detail?id=4294
144 */
145 public void test_constConstructor_superInvocation() throws Exception {
146 resolveAndTestCtConstExpectErrors(
147 Joiner.on("\n").join(
148 "// filler filler filler filler filler filler filler filler filler f iller",
149 "class Object {}",
150 "class A {",
151 " final v;",
152 " const A(this.v);",
153 "}",
154 "class B extends A {",
155 " const A() : super(generateValue());",
156 " static generateValue() => 42;",
157 "}",
158 ""),
159 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION, 8, 21, 15));
160 }
161
123 /** 162 /**
124 * At compile time we "trust" user that parameter will have correct type. 163 * At compile time we "trust" user that parameter will have correct type.
125 */ 164 */
126 public void test_constConstructor_constInitializerValue_plusDynamic() { 165 public void test_constConstructor_constInitializerValue_plusDynamic() {
127 resolveAndTestCtConstExpectErrors( 166 resolveAndTestCtConstExpectErrors(
128 Joiner.on("\n").join( 167 Joiner.on("\n").join(
129 "// filler filler filler filler filler filler filler filler filler f iller", 168 "// filler filler filler filler filler filler filler filler filler f iller",
130 "class Object {}", 169 "class Object {}",
131 "class A {", 170 "class A {",
132 " final v;", 171 " final v;",
(...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 "interface int {}", 955 "interface int {}",
917 "class A {", 956 "class A {",
918 " static final int value7 = ('Invalid') / 1;", 957 " static final int value7 = ('Invalid') / 1;",
919 " static final int value8 = value7 & 0xFFFF;", 958 " static final int value8 = value7 & 0xFFFF;",
920 "}"), 959 "}"),
921 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_NUMBER, 4, 29, 11), 960 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_NUMBER, 4, 29, 11),
922 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_NUMBER, 4, 29, 11), 961 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_NUMBER, 4, 29, 11),
923 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_INT, 5, 29, 6)) ; 962 errEx(ResolverErrorCode.EXPECTED_CONSTANT_EXPRESSION_INT, 5, 29, 6)) ;
924 } 963 }
925 } 964 }
OLDNEW
« no previous file with comments | « compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698