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

Unified Diff: editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java

Issue 14161021: Generate unique names less aggressively. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
diff --git a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
index 929785dc1cb460671aa50378dcd09d779bd331e7..bb4dae7d837beab1ec9c1abe2a6e53d966af735f 100644
--- a/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
+++ b/editor/util/plugins/com.google.dart.java2dart_test/src/com/google/dart/java2dart/SemanticTest.java
@@ -1187,7 +1187,11 @@ public class SemanticTest extends AbstractSemanticTest {
"package test;",
"public class Test {",
" static int foo() {return 42;}",
- " static void bar() {",
+ " static void barA() {",
+ " int foo = foo();",
+ " baz(foo);",
+ " }",
+ " static void barB() {",
" int foo = foo();",
" baz(foo);",
" }",
@@ -1202,7 +1206,11 @@ public class SemanticTest extends AbstractSemanticTest {
toString(
"class Test {",
" static int foo() => 42;",
- " static void bar() {",
+ " static void barA() {",
+ " int foo2 = foo();",
+ " baz(foo2);",
+ " }",
+ " static void barB() {",
" int foo2 = foo();",
" baz(foo2);",
" }",
@@ -1212,6 +1220,94 @@ public class SemanticTest extends AbstractSemanticTest {
getFormattedSource(unit));
}
+ public void test_giveUniqueName_variableInitializer_localNames() throws Exception {
+ File file = setFileLines(
+ "test/Test.java",
+ toString(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "package test;",
+ "public class Test {",
+ " static int foo() {return 42;}",
+ " static void barA() {",
+ " int foo2 = 2;",
+ " int foo = foo();",
+ " baz(foo);",
+ " int foo3 = 3;",
+ " }",
+ "}",
+ ""));
+ Context context = new Context();
+ context.addSourceFolder(tmpFolder);
+ context.addSourceFile(file);
+ CompilationUnit unit = context.translate();
+ assertEquals(
+ toString(
+ "class Test {",
+ " static int foo() => 42;",
+ " static void barA() {",
+ " int foo2 = 2;",
+ " int foo4 = foo();",
+ " baz(foo4);",
+ " int foo3 = 3;",
+ " }",
+ "}"),
+ getFormattedSource(unit));
+ }
+
+ public void test_giveUniqueName_variableInitializer_onlyHierarchyNames() throws Exception {
+ setFileLines(
+ "test/A.java",
+ toString(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "package test;",
+ "public class A {",
+ " static int foo3;",
+ "}",
+ ""));
+ setFileLines(
+ "test/B.java",
+ toString(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "package test;",
+ "public class B {",
+ " static int foo2;",
+ "}",
+ ""));
+ setFileLines(
+ "test/Test.java",
+ toString(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "package test;",
+ "public class Test extends B {",
+ " static int foo() {return 42;}",
+ " static void bar() {",
+ " int foo = foo();",
+ " baz(foo);",
+ " }",
+ "}",
+ ""));
+ Context context = new Context();
+ context.addSourceFolder(tmpFolder);
+ context.addSourceFiles(tmpFolder);
+ CompilationUnit unit = context.translate();
+ assertEquals(
+ toString(
+ "class A {",
+ " static int foo3 = 0;",
+ "}",
+ "class B {",
+ " static int foo2 = 0;",
+ "}",
+ "class Test extends B {",
+ " static int foo() => 42;",
+ " static void bar() {",
+ " int foo3 = foo();",
+ " baz(foo3);",
+ " }",
+ "}"),
+ getFormattedSource(unit));
+ }
+
public void test_giveUniqueName_withStatic() throws Exception {
setFileLines(
"test/Super.java",

Powered by Google App Engine
This is Rietveld 408576698