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

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

Issue 11087018: Issue 5652. Suggest to use effective integer division ~/, warning and Quick Fix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 2 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 15da593d611dce5bdce0ce9461d0a448fe4e7753..cb8a83a399bc86e5cca0af96ddbdcc243dc9d10b 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -5304,4 +5304,22 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
result.getErrors(),
errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD, 4, 5, 3));
}
+
+ /**
+ * Developers unfamiliar with Dart frequently write (x/y).toInt() instead of x ~/ y. The editor
+ * should recognize that pattern
+ * <p>
+ * http://code.google.com/p/dart/issues/detail?id=5652
+ */
+ public void test_useEffectiveIntegerDivision() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "main() {",
+ " num x = 7;",
+ " num y = 2;",
+ " print( (x / y).toInt() );",
+ "}",
+ "");
+ assertErrors(result.getErrors(), errEx(TypeErrorCode.USE_INTEGER_DIVISION, 5, 10, 15));
+ }
}

Powered by Google App Engine
This is Rietveld 408576698