Fix for issue #774. Deleted several archaic tests that are not relevant anymore. Moved a two tests into user and cleaned them up big time. git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@583 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/test/com/google/gwt/dev/jjs/JavaToJavaScriptCompilerTest.java b/dev/core/test/com/google/gwt/dev/jjs/JavaToJavaScriptCompilerTest.java deleted file mode 100644 index 5b137c8..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/JavaToJavaScriptCompilerTest.java +++ /dev/null
@@ -1,57 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.dev.jdt.RebindOracle; -import com.google.gwt.dev.jdt.RebindPermutationOracle; -import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd; -import com.google.gwt.dev.util.log.AbstractTreeLogger; -import com.google.gwt.dev.util.log.PrintWriterTreeLogger; - -import java.util.HashMap; -import java.util.Map; - -public class JavaToJavaScriptCompilerTest { - - public static void main(String[] args) throws UnableToCompleteException { - if (args.length < 1) { - System.err.println("Usage: root-class [[rebind] ...]\n" - + " mainClass must implement public void appMain()\n" - + " rebind is of the form com.before.class:com.after.class\n"); - System.exit(1); - } - - Map rebinds = new HashMap(); - - for (int i = 1; i < args.length; ++i) { - String[] split = args[i].split(":"); - if (split.length != 2) { - System.err - .println("Rebinds must be of the form com.before.class:com.after.class\n"); - System.exit(1); - } - rebinds.put(split[0], split[1]); - } - - AbstractTreeLogger logger = new PrintWriterTreeLogger(); - logger.setMaxDetail(TreeLogger.INFO); - SourceOracleImpl soi = new SourceOracleImpl(); - WebModeCompilerFrontEnd compiler = new WebModeCompilerFrontEnd(soi, new RebindPermutationOracle() { - public String[] getAllPossibleRebindAnswers(TreeLogger logger, String sourceTypeName) throws UnableToCompleteException { - return new String[] { sourceTypeName }; - } - }); - - JavaToJavaScriptCompiler jjs = new JavaToJavaScriptCompiler(logger, - compiler, new String[]{args[0]}); - - - jjs.compile(logger, new RebindOracle() { - public String rebind(TreeLogger logger, String sourceTypeName) throws UnableToCompleteException { - return sourceTypeName; - } - }); - System.exit(0); - } -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/RebindPermOracleImpl.java b/dev/core/test/com/google/gwt/dev/jjs/RebindPermOracleImpl.java deleted file mode 100644 index d281f5a..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/RebindPermOracleImpl.java +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.dev.jdt.RebindOracle; -import com.google.gwt.dev.jdt.RebindPermutationOracle; - -import java.util.Map; - -final class RebindPermOracleImpl implements RebindPermutationOracle, - RebindOracle { - - public RebindPermOracleImpl(Map rebinds) { - this.rebinds = rebinds; - } - - public String[] getAllPossibleRebindAnswers(TreeLogger logger, - String sourceTypeName) throws UnableToCompleteException { - return new String[]{rebind(logger, sourceTypeName)}; - } - - public String rebind(TreeLogger logger, String sourceTypeName) - throws UnableToCompleteException { - String result = (String) rebinds.get(sourceTypeName); - if (result != null) { - return result; - } else { - return sourceTypeName; - } - } - - private final Map rebinds; -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/ReflectiveWebModeCompilerTestCase.java b/dev/core/test/com/google/gwt/dev/jjs/ReflectiveWebModeCompilerTestCase.java deleted file mode 100644 index 45af4aa..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/ReflectiveWebModeCompilerTestCase.java +++ /dev/null
@@ -1,198 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.core.ext.typeinfo.CompilationUnitProvider; -import com.google.gwt.dev.jdt.SourceOracle; -import com.google.gwt.dev.jdt.StaticCompilationUnitProvider; -import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd; -import com.google.gwt.dev.util.log.AbstractTreeLogger; -import com.google.gwt.dev.util.log.PrintWriterTreeLogger; - -import junit.framework.TestCase; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -public class ReflectiveWebModeCompilerTestCase extends TestCase { - - public ReflectiveWebModeCompilerTestCase() { - // Build a map of packages and classes. - // Each package P is represented by a nested class named - // "Package_P", whose methods are declared as "src_T()", - // where T is the name of a type within logical package P. - // Calling src_T() produces the source for type T. - // The default package class should be called "Package_". - // - ctorMapPackagesInTestCase(getClass()); - } - - public void compile(String appClass, Map rebinds) - throws UnableToCompleteException { - rebinds = rebinds != null ? rebinds : new HashMap(); - AbstractTreeLogger logger = new PrintWriterTreeLogger(); - logger.setMaxDetail(TreeLogger.INFO); - RebindPermOracleImpl rpoi = new RebindPermOracleImpl(rebinds); - SourceOracleReflectiveDecorator soi = new SourceOracleReflectiveDecorator(); - WebModeCompilerFrontEnd astCompiler = new WebModeCompilerFrontEnd(soi, rpoi); - JavaToJavaScriptCompiler jjs = new JavaToJavaScriptCompiler(logger, - astCompiler, new String[]{appClass}); - jjs.compile(logger, rpoi); - } - - private class SourceOracleReflectiveDecorator implements SourceOracle { - - private final SourceOracle inner = new SourceOracleImpl(); - - public CompilationUnitProvider findCompilationUnit(TreeLogger logger, - String sourceTypeName) throws UnableToCompleteException { - CompilationUnitProvider result = inner.findCompilationUnit(logger, - sourceTypeName); - if (result == null) { - int lastDot = sourceTypeName.lastIndexOf('.'); - String packageName = ""; - String simpleName = sourceTypeName; - if (lastDot != -1) { - packageName = sourceTypeName.substring(0, lastDot); - simpleName = sourceTypeName.substring(lastDot + 1); - } - - String mangledPackageName = makeMangledPackageName(packageName); - Map methodsByMangledClassName = (Map) methodMapByPackageName - .get(mangledPackageName); - - if (methodsByMangledClassName != null) { - String mangledSimpleName = makeMangledSimpleName(simpleName); - Method method = (Method) methodsByMangledClassName - .get(mangledSimpleName); - if (method != null) { - try { - String source = (String) method.invoke(null, new Object[0]); - result = new StaticCompilationUnitProvider(packageName, - simpleName, source.toCharArray()); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - return null; - } catch (IllegalAccessException e) { - e.printStackTrace(); - return null; - } catch (InvocationTargetException e) { - e.printStackTrace(); - return null; - } - } - } - } - return result; - } - - public boolean isPackage(String possiblePackageName) { - boolean result = inner.isPackage(possiblePackageName); - if (!result) { - String mangledName = makeMangledPackageName(possiblePackageName); - - // Any matching prefix qualifies. - // - for (Iterator iter = methodMapByPackageName.keySet().iterator(); iter - .hasNext();) { - String testMangledPackageName = (String) iter.next(); - if (testMangledPackageName.startsWith(mangledName)) - return true; - } - } - return result; - } - - } - - private void ctorMapMethodsInPackage(Class packageClass, - Map/* <String, Method> */methodByName) { - // We build the map from the top of the hierachy downward, so that map - // inserts in derived classes will override those in superclasses. - // - Class superClass = packageClass.getSuperclass(); - if (superClass != null) - ctorMapMethodsInPackage(superClass, methodByName); - - // Now contribute to the map on behalf of packageClass. - // - Method[] methods = packageClass.getDeclaredMethods(); - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - String methodName = method.getName(); - if (methodName.startsWith("src_")) { - if (method.getParameterTypes().length == 0) { - int modifiers = method.getModifiers(); - if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { - // This counts as a source-producing method. - // - method.setAccessible(true); - methodByName.put(methodName, method); - } else { - System.err.println("Source method " + methodName + " in class " - + packageClass.getName() + " should be 'public' and 'static'"); - } - } - } - } - } - - private void ctorMapPackagesInTestCase(Class testCaseClass) { - // We build the map from the top of the hierachy downward, so that map - // inserts in derived classes will override those in superclasses. - // - if (!testCaseClass.equals(ReflectiveWebModeCompilerTestCase.class)) { - Class superClass = testCaseClass.getSuperclass(); - if (superClass != null) - ctorMapPackagesInTestCase(superClass); - } - - // Now contribute to the map on behalf of containingClass. - // - Class[] nestedClasses = testCaseClass.getDeclaredClasses(); - - for (int i = 0; i < nestedClasses.length; i++) { - Class nestedClass = nestedClasses[i]; - String nestedClassName = nestedClass.getName(); - int indexOfSimpleName = nestedClassName.lastIndexOf('$') + 1; - nestedClassName = nestedClassName.substring(indexOfSimpleName); - if (nestedClassName.startsWith("Package_")) { - int modifiers = nestedClass.getModifiers(); - if (Modifier.isStatic(modifiers) && Modifier.isPublic(modifiers)) { - // This counts as a package. - // - Map/* <String, Method> */methodMap = (Map) methodMapByPackageName - .get(nestedClassName); - if (methodMap == null) { - methodMap = new HashMap(); - methodMapByPackageName.put(nestedClassName, methodMap); - } - - // Add source-producing methods. - // - ctorMapMethodsInPackage(nestedClass, methodMap); - } else { - System.err.println("Package class " + nestedClassName + " in class " - + testCaseClass.getName() + " should be 'public' and 'static'"); - } - } - } - } - - private String makeMangledPackageName(String packageName) { - packageName = "Package_" + packageName.replace('.', '_'); - return packageName; - } - - private String makeMangledSimpleName(String typeName) { - return "src_" + typeName; - } - - private final Map/* <String, Map<String, Method>> */methodMapByPackageName = new HashMap(); - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/SimpleWebModeCompilerTestCase.java b/dev/core/test/com/google/gwt/dev/jjs/SimpleWebModeCompilerTestCase.java deleted file mode 100644 index e389db8..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/SimpleWebModeCompilerTestCase.java +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.UnableToCompleteException; -import com.google.gwt.dev.jdt.WebModeCompilerFrontEnd; -import com.google.gwt.dev.util.log.AbstractTreeLogger; -import com.google.gwt.dev.util.log.PrintWriterTreeLogger; - -import junit.framework.TestCase; - -import java.util.HashMap; -import java.util.Map; - -public abstract class SimpleWebModeCompilerTestCase extends TestCase { - - protected void compile(String appClass, Map rebinds) - throws UnableToCompleteException { - rebinds = rebinds != null ? rebinds : new HashMap(); - AbstractTreeLogger logger = new PrintWriterTreeLogger(); - logger.setMaxDetail(TreeLogger.INFO); - SourceOracleImpl soi = new SourceOracleImpl(); - RebindPermOracleImpl rpoi = new RebindPermOracleImpl(rebinds); - WebModeCompilerFrontEnd astCompiler = new WebModeCompilerFrontEnd(soi, rpoi); - JavaToJavaScriptCompiler jjs = new JavaToJavaScriptCompiler(logger, - astCompiler, new String[]{appClass}, false, false); - String result = jjs.compile(logger, rpoi); - - // print source - if (true) { - System.out.println("<html><head></head>"); - System.out.println("<body onload=\'init()\'>"); - System.out.println("<script>"); - System.out.println(result); - System.out.println("</script>"); - System.out.println("</body></html>"); - } - - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/SourceOracleImpl.java b/dev/core/test/com/google/gwt/dev/jjs/SourceOracleImpl.java deleted file mode 100644 index da3455a..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/SourceOracleImpl.java +++ /dev/null
@@ -1,38 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.TreeLogger; -import com.google.gwt.core.ext.typeinfo.CompilationUnitProvider; -import com.google.gwt.dev.jdt.SourceOracle; -import com.google.gwt.dev.jdt.URLCompilationUnitProvider; - -import java.net.URL; - -final class SourceOracleImpl implements SourceOracle { - - public CompilationUnitProvider findCompilationUnit(TreeLogger logger, - String sourceTypeName) { - ClassLoader cl = getClass().getClassLoader(); - URL url = cl.getResource(sourceTypeName.replace('.', '/') + ".java"); - if (url != null) { - String packageName = ""; - int i = sourceTypeName.lastIndexOf('.'); - if (i != -1) { - packageName = sourceTypeName.substring(0, i); - } - return new URLCompilationUnitProvider(url, packageName); - } else { - return null; - } - } - - public boolean isPackage(String maybePackage) { - ClassLoader cl = getClass().getClassLoader(); - URL url = cl.getResource(maybePackage.replace('.', '/').concat("/")); - if (url != null) - return true; - else - return false; - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerNoRebind.java b/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerNoRebind.java deleted file mode 100644 index 0cc1404..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerNoRebind.java +++ /dev/null
@@ -1,24 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -/** - * - */ -public class WebModeCompilerNoRebind extends ReflectiveWebModeCompilerTestCase { - - public void testCompile() throws Exception { - compile("test.TestNoRebind", null); - } - - public static class Package_test { - public static String src_TestNoRebind() { - StringBuffer sb = new StringBuffer(); - sb.append("package test;\n"); - sb.append("public class TestNoRebind {\n"); - sb.append(" public void onModuleLoad() {\n"); - sb.append(" }\n"); - sb.append("}\n"); - return sb.toString(); - } - } -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerSamePackageRebind.java b/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerSamePackageRebind.java deleted file mode 100644 index cf122ac..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/WebModeCompilerSamePackageRebind.java +++ /dev/null
@@ -1,53 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs; - -import com.google.gwt.core.ext.UnableToCompleteException; - -import java.util.HashMap; -import java.util.Map; - -public class WebModeCompilerSamePackageRebind extends ReflectiveWebModeCompilerTestCase { - - public void testCompile() throws UnableToCompleteException { - Map rebinds = new HashMap(); - rebinds.put("test.rebind.SamePackageRebindBefore", "test.rebind.SamePackageRebindAfter"); - compile("test.rebind.TestRebind", rebinds); - } - - public static class Package_test_rebind { - - public static String src_SamePackageRebindBefore() { - StringBuffer sb = new StringBuffer(); - sb.append("package test.rebind;\n"); - sb.append("public class SamePackageRebindBefore {\n"); - sb.append(" protected void foo() {\n"); - sb.append(" }\n"); - sb.append("}\n"); - return sb.toString(); - } - - public static String src_SamePackageRebindAfter() { - StringBuffer sb = new StringBuffer(); - sb.append("package test.rebind;\n"); - sb.append("public class SamePackageRebindAfter {\n"); - sb.append(" protected void foo() {\n"); - sb.append(" }\n"); - sb.append("}\n"); - return sb.toString(); - } - - public static String src_TestRebind() { - StringBuffer sb = new StringBuffer(); - sb.append("package test.rebind;\n"); - sb.append("import com.google.gwt.core.client.Rebind;"); - sb.append("public class TestRebind {\n"); - sb.append(" public void onModuleLoad() {\n"); - sb.append(" SamePackageRebindBefore b;\n"); - sb.append(" b = (SamePackageRebindBefore)GWT.create(SamePackageRebindBefore.class);\n"); - sb.append(" }\n"); - sb.append("}\n"); - return sb.toString(); - } - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Test.java b/dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Test.java deleted file mode 100644 index 3a9d288..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Test.java +++ /dev/null
@@ -1,12 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.inneroutersuper; - -import com.google.gwt.dev.jjs.SimpleWebModeCompilerTestCase; - -public class Test extends SimpleWebModeCompilerTestCase { - - public void testCompile() throws Exception { - compile(Main.class.getName(), null); - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Main.java b/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Main.java deleted file mode 100644 index cf1f056..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Main.java +++ /dev/null
@@ -1,490 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.jdtcoverage; - -/** - * This test is intended to exercise as many code paths and node types as - * possible in the Java to JavaScript compiler. This test is not at all intended - * to execute correctly. - */ -public class Main extends MainSuper { - - public static int i = 1 + 2 + 3; - public static final int j = 2; - public static long l; - public static int[] ia; - public static int[][] iaa; - public static int[][][] iaaa; - public static Object o; - public static boolean z; - public static double d; - public static float f; - public static String s = "foo"; - public static Main singleton; - - public int x = 3; - public final int y = 4; - public Main next; - - public void onModuleLoad() { - new Inner().go(); - } - - public Main getNext() { - return next; - } - - public void foo() { - } - - protected static void sfoo() { - } - - public static class Super { - // Initializer - static { - Super.i = 1; - } - - public static int i = 2; - public static final int j = 2; - - // Initializer - static { - Super.i = 3; - } - - // Initializer - { - x = 1; - } - - public int x = 2; - public final int y = 4; - - // Initializer - { - x = 3; - } - - - public Super() { - } - - public Super(int i) { - } - - public void foo() { - } - - protected static void sfoo() { - } - - } - - public class Inner extends Super { - - public int x = 3; - public final int y = 4; - - public Inner() { - // ExplicitConstructorCall - this(4); - } - - public Inner(int i) { - // ExplicitConstructorCall - super(i); - } - - public void go() { - - // AllocationExpression - o = new Super(); - o = new Super(42); - - // AND_AND_Expression - z = i == 1 && j == 2; - - // ArrayAllocationExpression - ia = new int[4]; - iaa = new int[4][3]; - iaaa = new int[4][3][]; - - // ArrayInitializer - ia = new int[]{i, j}; - iaa = new int[][]{{i, j}}; - iaa = new int[][]{{i, j}, ia}; - - // ArrayQualifiedTypeReference - // TODO: ??? - - // ArrayReference - i = ia[0]; - ia[0] = i; - - // Assignment - i = j; - - // BinaryExpression - i = i + j; - i = i - j; - i = i * j; - i = i / j; - i = i % j; - i = i & j; - i = i | j; - i = i ^ j; - i = i << j; - i = i >> j; - i = i >>> j; - - // CastExpression - o = (Super) o; - - // CharLiteral - i = 'c'; - - // ClassLiteralAccess - o = Super.class; - - // ConditionalExpression - i = z ? i : j; - - // CompoundAssignment - i += j; - i -= j; - i *= j; - i /= j; - i %= j; - i &= j; - i |= j; - i ^= j; - i <<= j; - i >>= j; - i >>>= j; - - // DoubleLiteral - d = 3.141592653589793; - - // EqualExpression - z = i == j; - z = i != j; - z = i < j; - z = i <= j; - z = i > j; - z = i >= j; - - // ExtendedStringLiteral - // TODO: ???? - - // FalseLiteral - z = false; - - // FieldReference, QualifiedSuperReference, QualifiedThisReference, - // SuperReference, ThisReference - Inner other = new Inner(); - i = i + j + x + y; - i = this.i + this.j + this.x + this.y; - i = Main.i + Main.j; - i = Inner.i + Inner.j; - i = Super.i + Super.j; - i = other.i + other.j + other.x + other.y; - i = Inner.this.i + Inner.this.j + Inner.this.x + Inner.this.y; - i = Main.this.i + Main.this.j + Main.this.x + Main.this.y; - i = super.i + super.j + super.x + super.y; - i = Inner.super.i + Inner.super.j + Inner.super.x + Inner.super.y; - i = Main.super.i + Main.super.j + Main.super.x + Main.super.y; - - // FloatLiteral - f = 3.1415927f; - - // InstanceOfExpression - z = o instanceof Super; - - // IntLiteral - i = 4; - - // IntLiteralMinValue - i = -2147483648; - - // LongLiteral - l = 4L; - - // LongLiteralMinValue - l = -9223372036854775808L; - - // MessageSend, QualifiedSuperReference, QualifiedThisReference, - // SuperReference, ThisReference - foo(); - this.foo(); - other.foo(); - Main.this.foo(); - super.foo(); - Inner.super.foo(); - Main.super.foo(); - - sfoo(); - this.sfoo(); - Main.sfoo(); - Inner.sfoo(); - Super.sfoo(); - other.sfoo(); - Main.this.sfoo(); - super.sfoo(); - Inner.super.sfoo(); - Main.super.sfoo(); - - // NullLiteral - o = null; - - // OR_OR_Expression - z = i == 1 || j == 2; - - // PostfixExpression - i++; - i--; - - // PrefixExpression - ++i; - --i; - - // QualifiedAllocationExpression - o = new Inner(); - o = Main.this.new Inner(); - o = new Main().new Inner(); - - // QualifiedNameReference - // TODO: fields???? - Main m = new Main(); - i = ia.length; - i = m.j; - i = m.y; - i = new Main().j; - i = new Main().y; - i = m.next.j; - i = m.next.y; - i = new Main().next.j; - i = new Main().next.y; - i = m.getNext().j; - i = m.getNext().y; - i = new Main().getNext().j; - i = new Main().getNext().y; - - // QualifiedTypeReference - // TODO: ???? - - // SingleNameReference - int asdf; - asdf = i; - i = asdf; - - // StringLiteral - s = "f'oo\b\t\n\f\r\"\\"; - - // TrueLiteral - z = true; - - // TypeReference - // TODO: ???? - - // UnaryExpression - i = -i; - i = ~i; - z = !z; - - // AssertStatement - assert i == 2; - assert i == 3 : null; - - // BreakStatement, ContinueStatement - outer : while (z) { - inner : while (z) { - if (i == 1) - break; - if (i == 2) - break outer; - if (i == 3) - continue; - if (i == 4) - continue outer; - } - } - - // CaseStatement, SwitchStatement - switch (j) { - case 1: ++i; - case 2: ++i; - case 3: ++i; - case 4: ++i; - default: ++i; - } - - // DoStatement - do - i = j; - while(z); - - do { - i = j; - x = y; - } while(z); - - // EmptyStatement - ; - -// // ForeachStatement; 5.0 only -// for (int q : ia) { -// i = q; -// } - - // ForStatement - for (int q = 0, v = j; q < v; ++q) - i = q; - - // IfStatement - if (z) - i = j; - else - i = x; - - // LabeledStatement - label: i = j; - - // LocalDeclaration - int aaa; - int bbb = j; - int ccc, ddd; - int eee = 4, fff = 5; - - // ReturnStatement - if (z) - return; - - // SynchronizedStatement - synchronized (other) { - other.x = i; - } - - // ThrowStatement, TryStatement - try { - throw new Exception(); - } catch (Exception e) { - i = j; - } catch (Throwable t) { - x = y; - } - - try { - i = j; - } finally { - x = y; - } - - try { - try { - i = j; - } catch (Throwable t) { - throw t; - } - } catch (Throwable t) { - i = j; - } finally { - x = y; - } - - // WhileStatement - while (z) - i = j; - - while (z) { - i = j; - x = y; - } - - } - - public void foo() { - final int z = this.y; - - new Inner() { - { - x = z; - this.x = z; - Inner.this.x = z; - next = Main.this.next; - next.foo(); - Main.this.next.foo(); - Main.this.x = z; - Main.super.x = z; // inexpressible in Java without name mangling - } - public void foo() { - x = z; - this.x = z; - Inner.this.x = z; - next = Main.this.next; - next.foo(); - Main.this.next.foo(); - Main.this.x = z; - Main.super.x = z; // inexpressible in Java without name mangling - } - }; - - class NamedLocal extends Inner { - public void foo() { - Main.this.getNext(); - Inner.this.foo(); - super.foo(); - int x = z; - } - // JDT bug? This works in 5.0 but not in 1.4 - // TODO: will javac compile it? -// class NamedLocalSub extends NamedLocal { -// public void foo() { -// Main.this.getNext(); -// Inner.this.foo(); -// NamedLocal.this.foo(); -// super.foo(); -// int x = z; -// } -// } - }; - -// new NamedLocal().new NamedLocalSub().foo(); - new InnerSub().new InnerSubSub().fda(); - new SecondMain().new FunkyInner(); - } - - } - - private static class InnerSub extends Inner { - InnerSub() { - new Main().super(); - } - - private int asdfasdfasdf = 3; - - private class InnerSubSub extends InnerSub { - { - asdfasdfasdf = InnerSub.this.asdfasdfasdf; - InnerSub.this.asdfasdfasdf = asdfasdfasdf; - asdfasdfasdf = super.asdfasdfasdf; - super.asdfasdfasdf = asdfasdfasdf; - } - void fda() { - asdfasdfasdf = InnerSub.this.asdfasdfasdf; - InnerSub.this.asdfasdfasdf = asdfasdfasdf; - asdfasdfasdf = super.asdfasdfasdf; - super.asdfasdfasdf = asdfasdfasdf; - } - } - } - - private static class SecondMain { - private class FunkyInner extends Inner { - FunkyInner() { - new Main().super(); - } - } - } - -} \ No newline at end of file
diff --git a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/MainSuper.java b/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/MainSuper.java deleted file mode 100644 index 2aa3910..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/MainSuper.java +++ /dev/null
@@ -1,18 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.jdtcoverage; - -public class MainSuper { - - public static int i = 1; - public static final int j = 2; - - public int x = 3; - public final int y = 4; - - public void foo() { - } - - protected static void sfoo() { - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Test.java b/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Test.java deleted file mode 100644 index 44c956d..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/jdtcoverage/Test.java +++ /dev/null
@@ -1,12 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.jdtcoverage; - -import com.google.gwt.dev.jjs.SimpleWebModeCompilerTestCase; - -public class Test extends SimpleWebModeCompilerTestCase { - - public void testCompile() throws Exception { - compile(Main.class.getName(), null); - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/uprefs/Main.java b/dev/core/test/com/google/gwt/dev/jjs/uprefs/Main.java deleted file mode 100644 index 8ecdf78..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/uprefs/Main.java +++ /dev/null
@@ -1,156 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.uprefs; - -public class Main { - - interface I1 { - public void a(int noprune); - public void b(int prune); - public void c(int prune); - public void d(int prune); - public void e(int prune); - public void f(int prune); - public void g(int prune); - public void h(int prune); - public void i(int noprune); - public void j(int prune); - public void k(int noprune); - public void l(int prune); - public void m(int prune); - public void n(int prune); - public void o(int prune); - public void p(int prune); - } - - interface I2 { - public void a(int prune); - public void b(int noprune); - public void c(int prune); - public void d(int noprune); - public void e(int prune); - public void f(int prune); - public void g(int prune); - public void h(int prune); - public void i(int prune); - public void j(int noprune); - public void k(int prune); - public void l(int prune); - public void m(int prune); - public void n(int prune); - public void o(int prune); - public void p(int prune); - } - - interface I3 extends I1 { - public void a(int noprune); - public void b(int prune); - public void c(int noprune); - public void d(int prune); - public void e(int prune); - public void f(int prune); - public void g(int prune); - public void h(int prune); - } - - interface I4 extends I2 { - public void j(int noprune); - public void k(int prune); - public void l(int noprune); - public void m(int prune); - public void n(int prune); - public void o(int prune); - public void p(int prune); - } - - - static abstract class A1 { - public void a(int prune){ } - public void c(int prune){ } - public void e(int noprune){ } - public void g(int prune){ } - abstract public void i(int prune); - abstract public void k(int prune); - abstract public void m(int noprune); - abstract public void o(int prune); - } - - static abstract class A2 extends A1 implements I3 { - abstract public void b(int prune); - abstract public void d(int prune); - abstract public void f(int noprune); - abstract public void h(int prune); - public void j(int prune){ } - public void l(int prune){ } - public void n(int noprune){ } - public void p(int prune){ } - } - - static class A3 extends A2 implements I3 { - public void a(int noprune){ } - public void b(int noprune){ } - public void c(int noprune){ } - public void d(int noprune){ } - public void e(int noprune){ } - public void f(int noprune){ } - public void g(int noprune){ } - public void h(int prune){ } - public void i(int noprune){ } - public void j(int noprune){ } - public void k(int noprune){ } - public void l(int noprune){ } - public void m(int noprune){ } - public void n(int noprune){ } - public void o(int noprune){ } - public void p(int prune){ } - } - - static class A4 extends A2 implements I4 { - public void a(int noprune){ } - public void b(int noprune){ } - public void c(int noprune){ } - public void d(int noprune){ } - public void e(int noprune){ } - public void f(int noprune){ } - public void g(int prune){ } - public void h(int noprune){ } - public void i(int noprune){ } - public void j(int noprune){ } - public void k(int noprune){ } - public void l(int noprune){ } - public void m(int noprune){ } - public void n(int noprune){ } - public void o(int prune){ } - public void p(int noprune){ } - } - - - public void onModuleLoad() { - A4 a4 = new A4(); - A3 a3 = new A3(); - A2 a2 = a4; - A1 a1 = a4; - I1 i1 = a4; - I2 i2 = a4; - I3 i3 = a4; - I4 i4 = a4; - - i1.a(0); - i2.b(0); - i3.c(0); - i4.d(0); - a1.e(0); - a2.f(0); - a3.g(0); - a4.h(0); - - i1.i(0); - i2.j(0); - i3.k(0); - i4.l(0); - a1.m(0); - a2.n(0); - a3.o(0); - a4.p(0); -} - -}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/uprefs/Test.java b/dev/core/test/com/google/gwt/dev/jjs/uprefs/Test.java deleted file mode 100644 index 1f697f2..0000000 --- a/dev/core/test/com/google/gwt/dev/jjs/uprefs/Test.java +++ /dev/null
@@ -1,12 +0,0 @@ -// Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.uprefs; - -import com.google.gwt.dev.jjs.SimpleWebModeCompilerTestCase; - -public class Test extends SimpleWebModeCompilerTestCase { - - public void testCompile() throws Exception { - compile(Main.class.getName(), null); - } - -}
diff --git a/dev/core/test/com/google/gwt/dev/typeinfo/test/TypeOracleBuilderTest.java b/dev/core/test/com/google/gwt/dev/typeinfo/test/TypeOracleBuilderTest.java index badeca2..89044f4 100644 --- a/dev/core/test/com/google/gwt/dev/typeinfo/test/TypeOracleBuilderTest.java +++ b/dev/core/test/com/google/gwt/dev/typeinfo/test/TypeOracleBuilderTest.java
@@ -233,7 +233,7 @@ * Tweak this if you want to see the log output. */ private TreeLogger createTreeLogger() { - boolean reallyLog = true; + boolean reallyLog = false; if (reallyLog) { AbstractTreeLogger logger = new PrintWriterTreeLogger(); logger.setMaxDetail(TreeLogger.ALL);
diff --git a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java index 2cb94a2..b893286 100644 --- a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java +++ b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
@@ -3,8 +3,10 @@ import com.google.gwt.dev.jjs.test.ClassCastTestCase; import com.google.gwt.dev.jjs.test.CompilerTest; +import com.google.gwt.dev.jjs.test.Coverage; import com.google.gwt.dev.jjs.test.HostedTest; import com.google.gwt.dev.jjs.test.InnerClassTest; +import com.google.gwt.dev.jjs.test.InnerOuterSuperTest; import com.google.gwt.dev.jjs.test.MethodBindTest; import com.google.gwt.dev.jjs.test.MethodCallTest; import com.google.gwt.dev.jjs.test.MethodInterfaceTest; @@ -31,6 +33,8 @@ suite.addTestSuite(MethodBindTest.class); suite.addTestSuite(MiscellaneousTest.class); suite.addTestSuite(TestBlankInterface.class); + suite.addTestSuite(InnerOuterSuperTest.class); + suite.addTestSuite(Coverage.class); // $JUnit-END$ return suite;
diff --git a/user/test/com/google/gwt/dev/jjs/test/Coverage.java b/user/test/com/google/gwt/dev/jjs/test/Coverage.java new file mode 100644 index 0000000..21dc286 --- /dev/null +++ b/user/test/com/google/gwt/dev/jjs/test/Coverage.java
@@ -0,0 +1,850 @@ +// Copyright 2006 Google Inc. All Rights Reserved. +package com.google.gwt.dev.jjs.test; + +import com.google.gwt.junit.client.GWTTestCase; + +/** + * This test is intended to exercise as many code paths and node types as + * possible in the Java to JavaScript compiler. This test is not at all intended + * to execute correctly. + */ +public class Coverage extends CoverageSuper { + + public class Inner extends Super { + + public int x = 3; + public final int y = 4; + + public Inner() { + // ExplicitConstructorCall + this(4); + } + + public Inner(int i) { + // ExplicitConstructorCall + super(i); + } + + public void foo() { + final int z = this.y; + + new Inner() { + { + x = z; + this.x = z; + Inner.this.x = z; + next = Coverage.this.next; + next.foo(); + Coverage.this.next.foo(); + Coverage.this.x = z; + Coverage.super.x = z; // inexpressible in Java without name mangling + } + + public void foo() { + x = z; + this.x = z; + Inner.this.x = z; + next = Coverage.this.next; + next.foo(); + Coverage.this.next.foo(); + Coverage.this.x = z; + Coverage.super.x = z; // inexpressible in Java without name mangling + } + }; + + class NamedLocal extends Inner { + public void foo() { + Coverage.this.getNext(); + Inner.this.foo(); + super.foo(); + int x = z; + } + // JDT bug? This works in 5.0 but not in 1.4 + // TODO: will javac compile it? + // class NamedLocalSub extends NamedLocal { + // public void foo() { + // Main.this.getNext(); + // Inner.this.foo(); + // NamedLocal.this.foo(); + // super.foo(); + // int x = z; + // } + // } + } + testEmptyStatement(); + + // new NamedLocal().new NamedLocalSub().foo(); + new InnerSub().new InnerSubSub().fda(); + new SecondMain().new FunkyInner(); + } + + private void testAllocationExpression() { + // AllocationExpression + o = new Super(); + assertEquals("3", o.toString()); + o = new Super(42); + assertEquals("42", o.toString()); + } + + private void testAndAndExpression() { + // AND_AND_Expression + z = i == 1 && betterNotEval(); + assertFalse(z); + } + + private void testArrayAllocationExpression() { + // ArrayAllocationExpression + ia = new int[4]; + assertEquals(4, ia.length); + iaa = new int[4][3]; + assertEquals(4, iaa.length); + assertEquals(3, iaa[2].length); + iaaa = new int[4][3][]; + assertEquals(4, iaaa.length); + assertEquals(3, iaaa[2].length); + assertNull(iaaa[2][2]); + } + + private void testArrayInitializer() { + // ArrayInitializer + ia = new int[] {i, j}; + assertEquals(2, ia.length); + assertEquals(j, ia[1]); + iaa = new int[][] {{i, j}}; + assertEquals(1, iaa.length); + assertEquals(2, iaa[0].length); + assertEquals(j, iaa[0][1]); + iaa = new int[][] { {i, j}, ia}; + assertEquals(2, iaa.length); + assertEquals(2, iaa[0].length); + assertEquals(j, iaa[0][1]); + assertEquals(ia, iaa[1]); + } + + private void testArrayReference() { + // ArrayReference + i = ia[0]; + assertEquals(ia[0], i); + ia[0] = i; + } + + /** + * TODO(later): implement asserts + */ + private void testAssertStatement() { + // i = 1; + // try { + // assert i == 2; + // fail(); + // } catch (AssertionError e) { + // } + // try { + // assert i == 3 : "foo"; + // fail(); + // } catch (AssertionError e) { + // assertEquals("foo", e.getMessage()); + // } + } + + private void testAssignment() { + // Assignment + i = j; + assertEquals(j, i); + } + + private void testBinaryExpression() { + // BinaryExpression + i = 4; + i = i + j; + assertEquals(6, i); + i = i - j; + assertEquals(4, i); + i = i * j; + assertEquals(8, i); + i = i / j; + assertEquals(4, i); + i = i % j; + assertEquals(0, i); + i = 7; + i = i & j; + assertEquals(2, i); + i = 0; + i = i | j; + assertEquals(2, i); + i = 7; + i = i ^ j; + assertEquals(5, i); + i = i << j; + assertEquals(20, i); + i = i >> j; + assertEquals(5, i); + i = i >>> j; + assertEquals(1, i); + } + + private void testBreakContinueLabelStatement() { + // BreakStatement, ContinueStatement + z = true; + i = 0; + x = 0; + outer : while (z) { + ++x; + inner : while (z) { + ++i; + if (i == 1) + continue; + if (i == 2) + continue outer; + if (i == 3) + break; + if (i == 4) + break outer; + } + } + assertEquals(4, i); + assertEquals(3, x); + } + + private void testCaseSwitchStatement() { + // CaseStatement, SwitchStatement + i = 6; + switch (j) { + case 1: + ++i; + case 2: + i += 2; + case 3: + i += 3; + case 4: + i += 4; + default: + i += 0; + } + assertEquals(15, i); + } + + private void testCastExpression() { + // CastExpression + o = (Super) o; + } + + private void testCharLiteral() { + // CharLiteral + i = 'c'; + assertEquals("c", String.valueOf((char) i)); + } + + private void testClassLiteralAccess() { + // ClassLiteralAccess + o = Super.class; + assertEquals("class com.google.gwt.dev.jjs.test.Coverage$Super", + o.toString()); + } + + private void testCompoundAssignment() { + // CompoundAssignment + i = 4; + i += j; + assertEquals(6, i); + i -= j; + assertEquals(4, i); + i *= j; + assertEquals(8, i); + i /= j; + assertEquals(4, i); + i %= j; + assertEquals(0, i); + i = 7; + i &= j; + assertEquals(2, i); + i = 0; + i |= j; + assertEquals(2, i); + i = 7; + i ^= j; + assertEquals(5, i); + i <<= j; + assertEquals(20, i); + i >>= j; + assertEquals(5, i); + i >>>= j; + assertEquals(1, i); + } + + private void testConditionalExpression() { + // ConditionalExpression + z = false; + i = z ? 7 : j; + assertEquals(j, i); + } + + private void testDoStatement() { + // DoStatement + i = 3; + z = false; + do + i += j; + while (z); + assertEquals(5, i); + } + + private void testEmptyStatement() { + // EmptyStatement + ; + } + + private void testEqualExpression() { + // EqualExpression + i = 3; + assertFalse(i == j); + assertTrue(i != j); + assertFalse(i < j); + assertFalse(i <= j); + assertTrue(i > j); + assertTrue(i >= j); + } + + /** + * TODO(5.0) implement for each + */ + private void testForeachStatement() { + // for (int q : ia) { + // i = q; + // } + } + + private void testForStatement() { + // ForStatement + i = 0; + for (int q = 0, v = 4; q < v; ++q) + i += q; + assertEquals(6, i); + for (i = 0; i < 4; ++i) { + } + assertEquals(4, i); + } + + private void testIfStatement() { + // IfStatement + z = false; + if (z) + fail(); + if (z) + fail(); + else + assertFalse(z); + if (!z) + assertFalse(z); + else + fail(); + } + + private void testInstanceOfExpression() { + // InstanceOfExpression + Object o = Inner.super; + assertTrue(o instanceof Super); + } + + private void testLiterals() { + // DoubleLiteral + d = 3.141592653589793; + assertEquals(3, (int) d); + + // FalseLiteral + assertFalse(false); + + // FloatLiteral + f = 3.1415927f; + assertEquals(3, (int) f); + + // IntLiteral + i = 4; + + // IntLiteralMinValue + i = -2147483648; + + // LongLiteral + l = 4L; + + // LongLiteralMinValue + l = -9223372036854775808L; + + // NullLiteral + o = null; + + // StringLiteral + s = "f'oo\b\t\n\f\r\"\\"; + assertEquals(s, "f" + '\'' + 'o' + 'o' + '\b' + '\t' + '\n' + '\f' + '\r' + + '"' + '\\'); + + // TrueLiteral + assertTrue(true); + } + + private void testOrOrExpression() { + // OR_OR_Expression + i = 1; + assertTrue(i == 1 || betterNotEval()); + } + + private void testPostfixExpression() { + // PostfixExpression + assertEquals(1, i++); + assertEquals(2, i--); + } + + private void testPrefixExpression() { + // PrefixExpression + assertEquals(2, ++i); + assertEquals(1, --i); + } + + private void testQualifiedAllocationExpression() { + // QualifiedAllocationExpression + o = new Inner(); + o = Coverage.this.new Inner(); + o = new Coverage().new Inner(); + } + + private void testQualifiedNameReference() { + // QualifiedNameReference + // TODO: fields???? + Coverage m = new Coverage(); + ia = new int[2]; + assertEquals("1", 2, ia.length); + assertEquals("2", 2, m.j); + assertEquals("3", 4, m.y); + assertEquals("4", 2, new Coverage().j); + assertEquals("5", 4, new Coverage().y); + assertEquals("6", 2, m.next.j); + assertEquals("7", 4, m.next.y); + assertEquals("8", 2, new Coverage().next.j); + assertEquals("9", 4, new Coverage().next.y); + assertEquals("A", 2, m.getNext().j); + assertEquals("B", 4, m.getNext().y); + assertEquals("C", 2, new Coverage().getNext().j); + assertEquals("D", 4, new Coverage().getNext().y); + } + + private void testReferenceCalls() { + // MessageSend, QualifiedSuperReference, QualifiedThisReference, + // SuperReference, ThisReference + Inner other = new Inner(); + foo(); + this.foo(); + other.foo(); + Coverage.this.foo(); + super.foo(); + Inner.super.foo(); + Coverage.super.foo(); + + sfoo(); + this.sfoo(); + Coverage.sfoo(); + Inner.sfoo(); + Super.sfoo(); + other.sfoo(); + Coverage.this.sfoo(); + super.sfoo(); + Inner.super.sfoo(); + Coverage.super.sfoo(); + + } + + private Inner testReferences() { + // FieldReference, QualifiedSuperReference, QualifiedThisReference, + // SuperReference, ThisReference + Inner other = new Inner(); + i = 3; + i = i + j + x + y; + assertEquals(12, i); + i = this.i + this.j + this.x + this.y; + assertEquals(21, i); + i = Coverage.i + Coverage.j; + assertEquals(8, i); + i = Inner.i + Inner.j; + assertEquals(10, i); + i = Super.i + Super.j; + assertEquals(12, i); + i = other.i + other.j + other.x + other.y; + assertEquals(21, i); + i = Inner.this.i + Inner.this.j + Inner.this.x + Inner.this.y; + assertEquals(30, i); + i = Coverage.this.i + Coverage.this.j + Coverage.this.x + Coverage.this.y; + assertEquals(15, i); + i = super.i + super.j + super.x + super.y; + assertEquals(25, i); + i = Inner.super.i + Inner.super.j + Inner.super.x + Inner.super.y; + assertEquals(35, i); + i = Coverage.super.i + Coverage.super.j + Coverage.super.x + + Coverage.super.y; + assertEquals(10, i); + return other; + } + + private void testReturnStatement() { + // ReturnStatement + assertEquals("foo", doReturnFoo()); + if (true) + return; + fail(); + } + + private void testSynchronizedStatement() { + // SynchronizedStatement + synchronized (inner) { + inner.i = i; + } + } + + private void testTryCatchFinallyThrowStatement() { + // ThrowStatement, TryStatement + try { + i = 3; + if (true) { + throw new Exception(); + } + fail(); + } catch (Exception e) { + } finally { + i = 7; + } + assertEquals(7, i); + + try { + try { + i = 3; + } catch (Throwable t) { + fail(); + } + } catch (Throwable t) { + fail(); + } finally { + i = 7; + } + assertEquals(7, i); + + } + + private void testUnaryExpression() { + // UnaryExpression + i = 4; + assertEquals(-4, -i); + assertEquals(-5, ~i); + z = true; + assertFalse(!z); + } + + private void testWhileStatement() { + // WhileStatement + z = false; + while (z) + fail(); + + while (z) { + fail(); + } + } + + } + + public static class Super { + public static int i = 2; + public static final int j = 2; + + // Initializer + static { + Super.i = 1; + } + + // Initializer + static { + Super.i = 3; + } + + protected static void sfoo() { + } + + public int x = 2; + public final int y = 4; + + // Initializer + { + x = 1; + } + + // Initializer + { + x = 3; + } + + public Super() { + } + + public Super(int i) { + x = i; + } + + public void foo() { + } + + public String toString() { + return String.valueOf(x); + } + + } + + private static class InnerSub extends Inner { + private class InnerSubSub extends InnerSub { + { + asdfasdfasdf = InnerSub.this.asdfasdfasdf; + InnerSub.this.asdfasdfasdf = asdfasdfasdf; + asdfasdfasdf = super.asdfasdfasdf; + super.asdfasdfasdf = asdfasdfasdf; + } + + void fda() { + asdfasdfasdf = InnerSub.this.asdfasdfasdf; + InnerSub.this.asdfasdfasdf = asdfasdfasdf; + asdfasdfasdf = super.asdfasdfasdf; + super.asdfasdfasdf = asdfasdfasdf; + } + } + + private int asdfasdfasdf = 3; + + InnerSub() { + new Coverage().super(); + } + } + + private static class SecondMain { + private class FunkyInner extends Inner { + FunkyInner() { + new Coverage().super(); + } + } + } + + public static double d; + + public static float f; + + public static int i = 1 + 2 + 3; + + public static int[] ia; + + public static int[][] iaa; + + public static int[][][] iaaa; + + public static final int j = 2; + + public static long l; + + public static Object o; + + public static String s = "foo"; + + public static Coverage singleton; + + public static boolean z; + + public static boolean betterNotEval() { + fail(); + return false; + } + + protected static void sfoo() { + } + + private static String doReturnFoo() { + if (true) + return "foo"; + fail(); + return "bar"; + } + + public final Inner inner = new Inner(); + + public Coverage next; + + public int x = 3; + + public final int y = 4; + + public Coverage() { + if (singleton == null) { + singleton = this; + } + next = this; + } + + public void foo() { + } + + public String getModuleName() { + return "com.google.gwt.dev.jjs.CompilerSuite"; + } + + public Coverage getNext() { + return next; + } + + public void testAllocationExpression() { + inner.testAllocationExpression(); + } + + public void testAndAndExpression() { + inner.testAndAndExpression(); + } + + public void testArrayAllocationExpression() { + inner.testArrayAllocationExpression(); + } + + public void testArrayInitializer() { + inner.testArrayInitializer(); + } + + public void testArrayReference() { + inner.testArrayReference(); + } + + public void testAssertStatement() { + inner.testAssertStatement(); + } + + public void testAssignment() { + inner.testAssignment(); + } + + public void testBinaryExpression() { + inner.testBinaryExpression(); + } + + public void testBreakContinueLabelStatement() { + inner.testBreakContinueLabelStatement(); + } + + public void testCaseSwitchStatement() { + inner.testCaseSwitchStatement(); + } + + public void testCastExpression() { + inner.testCastExpression(); + } + + public void testCharLiteral() { + inner.testCharLiteral(); + } + + public void testClassLiteralAccess() { + inner.testClassLiteralAccess(); + } + + public void testCompoundAssignment() { + inner.testCompoundAssignment(); + } + + public void testConditionalExpression() { + inner.testConditionalExpression(); + } + + public void testDoStatement() { + inner.testDoStatement(); + } + + public void testEmptyStatement() { + inner.testEmptyStatement(); + } + + public void testEqualExpression() { + inner.testEqualExpression(); + } + + public void testForeachStatement() { + inner.testForeachStatement(); + } + + public void testForStatement() { + inner.testForStatement(); + } + + public void testIfStatement() { + inner.testIfStatement(); + } + + public void testInstanceOfExpression() { + inner.testInstanceOfExpression(); + } + + public void testLiterals() { + inner.testLiterals(); + } + + public void testOrOrExpression() { + inner.testOrOrExpression(); + } + + public void testPostfixExpression() { + inner.testPostfixExpression(); + } + + public void testPrefixExpression() { + inner.testPrefixExpression(); + } + + public void testQualifiedAllocationExpression() { + inner.testQualifiedAllocationExpression(); + } + + public void testQualifiedNameReference() { + inner.testQualifiedNameReference(); + } + + public void testReferenceCalls() { + inner.testReferenceCalls(); + } + + public void testReferences() { + inner.testReferences(); + } + + public void testReturnStatement() { + inner.testReturnStatement(); + } + + public void testSynchronizedStatement() { + inner.testSynchronizedStatement(); + } + + public void testTryCatchFinallyThrowStatement() { + inner.testTryCatchFinallyThrowStatement(); + } + + public void testUnaryExpression() { + inner.testUnaryExpression(); + } + + public void testWhileStatement() { + inner.testWhileStatement(); + } + +} + +abstract class CoverageSuper extends GWTTestCase { + + public static int i = 1; + public static final int j = 2; + + protected static void sfoo() { + } + + public int x = 3; + public final int y = 4; + + public void foo() { + } + +}
diff --git a/dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Main.java b/user/test/com/google/gwt/dev/jjs/test/InnerOuterSuperTest.java similarity index 81% rename from dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Main.java rename to user/test/com/google/gwt/dev/jjs/test/InnerOuterSuperTest.java index 9a0f01a..95734c3 100644 --- a/dev/core/test/com/google/gwt/dev/jjs/inneroutersuper/Main.java +++ b/user/test/com/google/gwt/dev/jjs/test/InnerOuterSuperTest.java
@@ -1,55 +1,18 @@ // Copyright 2006 Google Inc. All Rights Reserved. -package com.google.gwt.dev.jjs.inneroutersuper; +package com.google.gwt.dev.jjs.test; -public class Main { +import com.google.gwt.junit.client.GWTTestCase; - public void onModuleLoad() { - main(null); - } - - public static void print(int x) { -// System.out.println(x); - } - - public static void main(String[] args) { - Outer outer = new Outer(1); - Outer.OuterIsSuper outerIsSuper = outer.new OuterIsSuper(2); - - { - // QualifiedAlloc: outer becomes Outer or OuterIsSuper??? - Outer.OuterIsNotSuper outerIsNotSuper = outerIsSuper.new OuterIsNotSuper(); - int whatIsIt = outerIsNotSuper.getValue(); - print(whatIsIt); - } - - { - // [unqualified]Alloc: outer becomes Outer or OuterIsSuper??? - Outer.OuterIsNotSuper outerIsNotSuper = outerIsSuper.unqualifiedAlloc(); - int whatIsIt = outerIsNotSuper.getValue(); - print(whatIsIt); - } - - { - // QualifiedSupercall: outer becomes Outer or OuterIsSuper??? - Outer.TestQualifiedSuperCall testQualifiedSuperCall = new Outer.TestQualifiedSuperCall(); - int whatIsIt = testQualifiedSuperCall.getValue(); - print(whatIsIt); - } - - { - // UnqualifiedSupercall: outer becomes Outer or OuterIsSuper??? - Outer.TestUnqualifiedSuperCall testUnqualifiedSuperCall = outerIsSuper.new TestUnqualifiedSuperCall(); - int whatIsIt = testUnqualifiedSuperCall.getValue(); - print(whatIsIt); - } - } +public class InnerOuterSuperTest extends GWTTestCase { public static class Outer { - protected final int value; + public class OuterIsNotSuper { - public Outer(int i) { - value = i; + public int getValue() { + return value; + } + } public class OuterIsSuper extends Outer { @@ -64,14 +27,6 @@ } - public class OuterIsNotSuper { - - public int getValue() { - return value; - } - - } - public static class TestQualifiedSuperCall extends OuterIsNotSuper { public TestQualifiedSuperCall() { new Outer(1).new OuterIsSuper(2).super(); @@ -83,6 +38,49 @@ super(); } } + + protected final int value; + + public Outer(int i) { + value = i; + } + } + + public String getModuleName() { + return "com.google.gwt.dev.jjs.CompilerSuite"; + } + + public void testInnerOuterSuper() { + Outer outer = new Outer(1); + Outer.OuterIsSuper outerIsSuper = outer.new OuterIsSuper(2); + + { + // QualifiedAlloc: outer becomes Outer or OuterIsSuper??? + Outer.OuterIsNotSuper outerIsNotSuper = outerIsSuper.new OuterIsNotSuper(); + int whatIsIt = outerIsNotSuper.getValue(); + assertEquals(2, whatIsIt); + } + + { + // [unqualified]Alloc: outer becomes Outer or OuterIsSuper??? + Outer.OuterIsNotSuper outerIsNotSuper = outerIsSuper.unqualifiedAlloc(); + int whatIsIt = outerIsNotSuper.getValue(); + assertEquals(2, whatIsIt); + } + + { + // QualifiedSupercall: outer becomes Outer or OuterIsSuper??? + Outer.TestQualifiedSuperCall testQualifiedSuperCall = new Outer.TestQualifiedSuperCall(); + int whatIsIt = testQualifiedSuperCall.getValue(); + assertEquals(2, whatIsIt); + } + + { + // UnqualifiedSupercall: outer becomes Outer or OuterIsSuper??? + Outer.TestUnqualifiedSuperCall testUnqualifiedSuperCall = outerIsSuper.new TestUnqualifiedSuperCall(); + int whatIsIt = testUnqualifiedSuperCall.getValue(); + assertEquals(2, whatIsIt); + } } } \ No newline at end of file