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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 10516006: Issue 3268. Support for replacing 'assert' statement with 'assert' function (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changes for review comments Created 8 years, 6 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: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 009b9666c38bf738a17e5baeb4896877a9e1751c..378f46f94ea9cb068eef8adff5c744d4e59daacf 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -803,6 +803,61 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
assertErrors(libraryResult.getTypeErrors());
}
+ public void test_assert_notUserFunction() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " assert(true);",
+ " assert(false);",
+ " assert('message');", // not 'bool'
+ " assert('null');", // not 'bool'
+ " assert(0);", // not 'bool'
+ " assert(f() {});", // OK, Dynamic
+ " assert(bool f() {});", // OK, '() -> bool'
+ " assert(Object f() {});", // OK, 'Object' compatible with 'bool'
+ " assert(String f() {});", // not '() -> bool', return type
+ " assert(bool f(x) {});", // not '() -> bool', parameter
+ " assert(true, false);", // not single argument
+ " assert;", // incomplete
+ "}",
+ "foo() => assert(true);", // 'assert' is statement, not expression
+ "");
+ assertErrors(
+ libraryResult.getErrors(),
+ errEx(TypeErrorCode.ASSERT_BOOL, 5, 10, 9),
+ errEx(TypeErrorCode.ASSERT_BOOL, 6, 10, 6),
+ errEx(TypeErrorCode.ASSERT_BOOL, 7, 10, 1),
+ errEx(TypeErrorCode.ASSERT_BOOL, 11, 10, 13),
+ errEx(TypeErrorCode.ASSERT_BOOL, 12, 10, 12),
+ errEx(TypeErrorCode.ASSERT_NUMBER_ARGUMENTS, 13, 3, 19),
+ errEx(TypeErrorCode.ASSERT_NUMBER_ARGUMENTS, 14, 3, 7),
+ errEx(TypeErrorCode.ASSERT_IS_STATEMENT, 16, 10, 12));
+ }
+
+ public void test_assert_isUserFunction() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "assert(x) {}",
+ "main() {",
+ " assert(true);",
+ " assert(false);",
+ " assert('message');",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
+ public void test_assert_asLocalVariable() throws Exception {
+ AnalyzeLibraryResult libraryResult = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " bool assert;",
+ " assert;",
+ "}",
+ "");
+ assertErrors(libraryResult.getErrors());
+ }
+
public void test_finalField_inClass() throws Exception {
AnalyzeLibraryResult libraryResult = analyzeLibrary(
getName(),

Powered by Google App Engine
This is Rietveld 408576698