Index: dev/core/test/com/google/gwt/dev/js/JsInlinerTest.java
--- dev/core/test/com/google/gwt/dev/js/JsInlinerTest.java	(revision 6404)
+++ dev/core/test/com/google/gwt/dev/js/JsInlinerTest.java	(working copy)
@@ -27,7 +27,7 @@ import com.google.gwt.dev.js.ast.JsProgram;
  */
 public class JsInlinerTest extends OptimizerTestBase {
 
-  private static class FixStaticRefsVisitor extends JsModVisitor {
+  static class FixStaticRefsVisitor extends JsModVisitor {
 
     public static void exec(JsProgram program) {
       (new FixStaticRefsVisitor()).accept(program);
@@ -36,7 +36,7 @@ public class JsInlinerTest extends OptimizerTestBase {
     @Override
     public void endVisit(JsFunction x, JsContext<JsExpression> ctx) {
       JsName name = x.getName();
-      if (name != null) { 
+      if (name != null) {
         name.setStaticRef(x);
       }
     }
@@ -45,26 +45,28 @@ public class JsInlinerTest extends OptimizerTestBase {
   public void testInlineArrayLiterals() throws Exception {
     String input = "function a1(arg, x) { arg.x = x; return arg; }"
         + "function b1() { var x=a1([], 10); } b1();";
-    compare(input, input);
+    optimize(input).into(input);
   }
 
   public void testInlineFunctionLiterals() throws Exception {
     String input = "function a1(arg, x) { arg.x = x; return arg; }"
         + "function b1() { var x=a1(function (){}, 10); } b1();";
-    compare(input, input);
+    optimize(input).into(input);
+
     String input2 = "function a1(arg, x) { arg.x = x; return arg; }"
         + "function b1() { var x=a1(function blah(){}, 10); } b1();";
-    compare(input2, input2);
+    optimize(input2).into(input2);
   }
-  
+
   public void testInlineObjectLiterals() throws Exception {
     String input = "function a1(arg, x) { arg.x = x; return arg; }"
         + "function b1() { var x=a1({}, 10); } b1();";
-    compare(input, input);
+    optimize(input).into(input);
   }
+
   /**
    * A test for mutually-recursive functions. Setup:
-   *
+   * 
    * <pre>
    * a -> b, c
    * b -> a, c
@@ -72,29 +74,25 @@ public class JsInlinerTest extends OptimizerTestBase {
    * </pre>
    */
   public void testMutualRecursion() throws Exception {
-    String input = "function a1() { return ex ? b1() : c1() }"
-        + "function b1() { return ex2 ? a1(): c1(); }"
-        + "function c1() { return ex2? a1():c1(); } c1()";
-    String expected = "function a1() { return ex ? (ex2 ? a1() : c1()) : c1() }"
-        + "function c1() { return ex2 ? a1() :c1(); } c1()";
-    compare(expected, input);
+    optimize(
+        "function a1() { return ex ? b1() : c1() }"
+            + "function b1() { return ex2 ? a1(): c1(); }"
+            + "function c1() { return ex2? a1():c1(); } c1()").into(
+        "function a1() { return ex ? (ex2 ? a1() : c1()) : c1() }"
+            + "function c1() { return ex2 ? a1() :c1(); } c1()");
   }
 
   public void testSelfRecursion() throws Exception {
-    String input = "function a1() { return blah && b1() }"
-        + "function b1() { return bar && a1()}" + "function c() { a1() } c()";
-
-    String expected = "function a1() { return blah && bar && a1() }"
-        + "function c() { a1() } c()";
-
-    compare(expected, input);
+    optimize(
+        "function a1() { return blah && b1() }"
+            + "function b1() { return bar && a1()}"
+            + "function c() { a1() } c()").into(
+        "function a1() { return blah && bar && a1() }"
+            + "function c() { a1() } c()");
   }
 
-  private void compare(String expected, String input) throws Exception {
-    input = optimize(input, JsSymbolResolver.class, FixStaticRefsVisitor.class,
+  protected Result optimize(String js) throws Exception {
+    return optimize(js, JsSymbolResolver.class, FixStaticRefsVisitor.class,
         JsInliner.class, JsUnusedFunctionRemover.class);
-    expected = optimize(expected);
-    System.err.println("Input vs ");
-    assertEquals(expected, input);
-  }
+  };
 }
Index: dev/core/test/com/google/gwt/dev/js/JsStaticEvalTest.java
--- dev/core/test/com/google/gwt/dev/js/JsStaticEvalTest.java	(revision 6736)
+++ dev/core/test/com/google/gwt/dev/js/JsStaticEvalTest.java	(working copy)
@@ -21,126 +21,112 @@ package com.google.gwt.dev.js;
 public class JsStaticEvalTest extends OptimizerTestBase {
 
   public void testAddLiterals() throws Exception {
-    assertEquals("alert(42);", optimize("alert(21+21);"));
-    assertEquals("alert('Hello World');", optimize("alert('Hello '+'World');"));
-    assertEquals("alert('Hello 42');", optimize("alert('Hello ' + 42);"));
-    assertEquals("alert('42 Hello');", optimize("alert(42 + ' Hello');"));
-    assertEquals("alert('42 Hello');", optimize("alert(42.0 + ' Hello');"));
-    assertEquals("alert('42.2 Hello');", optimize("alert(42.2 + ' Hello');"));
-    assertEquals("alert('Hello 42.2');", optimize("alert('Hello ' + 42.2);"));
+    optimize("alert(21+21);").into("alert(42);");
+    optimize("alert('Hello '+'World');").into("alert('Hello World');");
+    optimize("alert('Hello ' + 42);").into("alert('Hello 42');");
+    optimize("alert(42 + ' Hello');").into("alert('42 Hello');");
+    optimize("alert(42.0 + ' Hello');").into("alert('42 Hello');");
+    optimize("alert(42.2 + ' Hello');").into("alert('42.2 Hello');");
+    optimize("alert('Hello ' + 42.2);").into("alert('Hello 42.2');");
   }
 
   public void testAssociativity() throws Exception {
     // Simple test
-    assertEquals("alert(a||b||c||d);", optimize("alert((a||b)||(c||d));"));
-    assertEquals("alert(a&&b&&c&&d);", optimize("alert((a&&b)&&(c&&d));"));
+    optimize("alert((a||b)||(c||d));").into("alert(a||b||c||d);");
+    optimize("alert((a&&b)&&(c&&d));").into("alert(a&&b&&c&&d);");
 
     // Preserve precedence
-    assertEquals("alert((a||b)&&(c||d));",
-        optimize("alert((a || b) && (c || d));"));
-    assertEquals("alert(a&&b||c&&d);",
-        optimize("alert((a && b) || ( c && d));"));
-    assertEquals("a(),b&&c();", optimize("a(), b && c()"));
-    assertEquals("a()&&b,c();", optimize("a() && b, c()"));
+    optimize("alert((a || b) && (c || d));").into("alert((a||b)&&(c||d));");
+    optimize("alert((a && b) || ( c && d));").into("alert(a&&b||c&&d);");
+    optimize("a(), b && c()").into("a(),b&&c();");
+    optimize("a() && b, c()").into("a()&&b,c();");
 
     // Don't damage math expressions
-    assertEquals("alert(seconds/(60*60));",
-        optimize("alert(seconds / (60 * 60))"));
-    assertEquals("alert(1-(1-foo));", optimize("alert(1 - (1 - foo))"));
+    optimize("alert(seconds / (60 * 60))").into("alert(seconds/(60*60));");
+    optimize("alert(1 - (1 - foo))").into("alert(1-(1-foo));");
 
     // Don't damage assignments
-    assertEquals("alert((a=0,b=foo));",
-        optimize("alert((a = 0, b = (bar, foo)))"));
-    assertEquals("alert(1+(a='2')+3+4);",
-        optimize("alert(1 + (a = '2') + 3 + 4);"));
-    assertEquals("alert(1+(a='2')+7);",
-        optimize("alert(1 + (a = '2') + (3 + 4));"));
+    optimize("alert((a = 0, b = (bar, foo)))").into("alert((a=0,b=foo));");
+    optimize("alert(1 + (a = '2') + 3 + 4);").into("alert(1+(a='2')+3+4);");
+    optimize("alert(1 + (a = '2') + (3 + 4));").into("alert(1+(a='2')+7);");
 
     // Break comma expressions up
-    assertEquals("alert((a(),b(),c(),d));",
-        optimize("alert(((a(),b()),(c(),d)));"));
+    optimize("alert(((a(),b()),(c(),d)));").into("alert((a(),b(),c(),d));");
     // and remove expressions without side effects
-    assertEquals("alert(d);", optimize("alert(((a,b),(c,d)));"));
+    optimize("alert(((a,b),(c,d)));").into("alert(d);");
 
     // Pattern of coercing a numeric add operation to a string
-    assertEquals("alert(''+(a+b));", optimize("alert('' + (a + b))"));
-    assertEquals("alert('foo'+(a+b));",
-        optimize("alert('foo' + ('' + (a + b)))"));
+    optimize("alert('' + (a + b))").into("alert(''+(a+b));");
+    optimize("alert('foo' + ('' + (a + b)))").into("alert('foo'+(a+b));");
 
     // Tests involving numeric and string literals and identifiers
-    assertEquals("alert(21+(1+$foo));",
-        optimize("alert((20 + 1) + (1 + $foo));"));
-    assertEquals("alert('211'+$foo);",
-        optimize("alert((20 + 1) + ('1' + $foo));"));
-    assertEquals("alert('2011'+$foo);",
-        optimize("alert((20 + '1') + ('1' + $foo));"));
-    assertEquals("alert('2011'+$foo);",
-        optimize("alert(('20' + 1) + ('1' + $foo));"));
-    assertEquals("alert('2011'+$foo);",
-        optimize("alert(('20' + '1') + ('1' + $foo));"));
+    optimize("alert((20 + 1) + (1 + $foo));").into("alert(21+(1+$foo));");
+    optimize("alert((20 + 1) + ('1' + $foo));").into("alert('211'+$foo);");
+    optimize("alert((20 + '1') + ('1' + $foo));").into("alert('2011'+$foo);");
+    optimize("alert(('20' + 1) + ('1' + $foo));").into("alert('2011'+$foo);");
+    optimize("alert(('20' + '1') + ('1' + $foo));").into("alert('2011'+$foo);");
 
     // These are also tricky, because $foo could be non-numeric
-    assertEquals("alert($foo+1+21);", optimize("alert(($foo + 1) + (20 + 1));"));
-    assertEquals("alert($bar+13+7+(2+$foo));",
-        optimize("alert((($bar + (10 + 3)) + (2 + 5)) + (2 + $foo));"));
+    optimize("alert(($foo + 1) + (20 + 1));").into("alert($foo+1+21);");
+    optimize("alert((($bar + (10 + 3)) + (2 + 5)) + (2 + $foo));").into(
+        "alert($bar+13+7+(2+$foo));");
 
     // Without type info, there's nothing that can be done for this expr
-    assertEquals("alert($foo+($bar+($baz+$quux)));",
-        optimize("alert($foo + ($bar + ($baz + $quux)));"));
+    optimize("alert($foo + ($bar + ($baz + $quux)));").into(
+        "alert($foo+($bar+($baz+$quux)));");
   }
 
   public void testIfWithEmptyThen() throws Exception {
-    assertEquals("a();", optimize("if (a()) { }"));
+    optimize("if (a()) { }").into("a();");
   }
 
   public void testIfWithEmptyThenAndElseExpression() throws Exception {
-    assertEquals("a()||b();", optimize("if (a()) { } else { b(); }"));
+    optimize("if (a()) { } else { b(); }").into("a()||b();");
   }
 
   public void testIfWithEmptyThenAndElse() throws Exception {
-    assertEquals("if(!a()){throw 1}",
-        optimize("if (a()) { } else { throw 1; }"));
+    optimize("if (a()) { } else { throw 1; }").into("if(!a()){throw 1}");
   }
 
   public void testIfWithEmptyThenAndEmptyElse() throws Exception {
-    assertEquals("a();", optimize("if (a()) { } else { }"));
+    optimize("if (a()) { } else { }").into("a();");
   }
 
   public void testIfWithThenAndEmptyElse() throws Exception {
-    assertEquals("if(a()){throw 1}", optimize("if (a()) { throw 1; } else { }"));
+    optimize("if (a()) { throw 1; } else { }").into("if(a()){throw 1}");
   }
 
   public void testIfWithThenExpressionAndEmptyElse() throws Exception {
-    assertEquals("a()&&b();", optimize("if (a()) { b() } else { }"));
+    optimize("if (a()) { b() } else { }").into("a()&&b();");
   }
 
   public void testIfWithThenExpressionAndElseExpression() throws Exception {
-    assertEquals("a()?b():c();", optimize("if (a()) { b() } else { c(); }"));
+    optimize("if (a()) { b() } else { c(); }").into("a()?b():c();");
   }
 
   public void testIfWithThenExpressionAndElseStatement() throws Exception {
     // This can't be optimized further
-    assertEquals("if(a()){b()}else{throw 1}",
-        optimize("if (a()) { b() } else { throw 1; }"));
+    optimize("if (a()) { b() } else { throw 1; }").into(
+        "if(a()){b()}else{throw 1}");
   }
 
   public void testLiteralEqNull() throws Exception {
-    assertEquals("alert(false);", optimize("alert('test' == null)"));
+    optimize("alert('test' == null)").into("alert(false);");
   }
 
   public void testLiteralNeNull() throws Exception {
-    assertEquals("alert(true);", optimize("alert('test' != null)"));
+    optimize("alert('test' != null)").into("alert(true);");
   }
 
   public void testNullEqNull() throws Exception {
-    assertEquals("alert(true);", optimize("alert(null == null)"));
+    optimize("alert(null == null)").into("alert(true);");
   }
 
   public void testNullNeNull() throws Exception {
-    assertEquals("alert(false);", optimize("alert(null != null)"));
+    optimize("alert(null != null)").into("alert(false);");
   }
 
-  private String optimize(String js) throws Exception {
+  private Result optimize(String js) throws Exception {
     return optimize(js, JsStaticEval.class);
   }
 }
Index: dev/core/test/com/google/gwt/dev/js/OptimizerTestBase.java
--- dev/core/test/com/google/gwt/dev/js/OptimizerTestBase.java	(revision 5585)
+++ dev/core/test/com/google/gwt/dev/js/OptimizerTestBase.java	(working copy)
@@ -18,12 +18,10 @@ package com.google.gwt.dev.js;
 import com.google.gwt.dev.jjs.SourceOrigin;
 import com.google.gwt.dev.js.ast.JsProgram;
 import com.google.gwt.dev.js.ast.JsStatement;
-import com.google.gwt.dev.js.ast.JsVisitor;
-import com.google.gwt.dev.util.DefaultTextOutput;
-import com.google.gwt.dev.util.TextOutput;
 
 import junit.framework.TestCase;
 
+import java.io.IOException;
 import java.io.StringReader;
 import java.lang.reflect.Method;
 import java.util.List;
@@ -33,6 +31,33 @@ import java.util.List;
  */
 public abstract class OptimizerTestBase extends TestCase {
 
+  public static class Result {
+    private final String jsActual;
+
+    public Result(String jsActual) {
+      this.jsActual = jsActual;
+    }
+
+    void into(String jsExpected) throws JsParserException {
+      JsProgram programExpected = buildProgram(jsExpected);
+      String normalizedJsExpected = programExpected.toSource();
+      assertEquals(normalizedJsExpected, jsActual);
+    }
+  }
+
+  protected static JsProgram buildProgram(String js) throws JsParserException {
+    JsProgram program = new JsProgram();
+    List<JsStatement> expected;
+    try {
+      expected = JsParser.parse(SourceOrigin.UNKNOWN, program.getScope(),
+          new StringReader(js));
+    } catch (IOException e) {
+      throw new RuntimeException("Unexpected from in-memory reader", e);
+    }
+    program.getGlobalBlock().getStatements().addAll(expected);
+    return program;
+  }
+
   /**
    * Optimize a JS program.
    * 
@@ -41,22 +66,15 @@ public abstract class OptimizerTestBase extends TestCase {
    *          <code>static void exec(JsProgram)</code>
    * @return optimized JS
    */
-  protected String optimize(String js, Class<?>... toExec) throws Exception {
-    JsProgram program = new JsProgram();
-    List<JsStatement> expected = JsParser.parse(SourceOrigin.UNKNOWN,
-        program.getScope(), new StringReader(js));
-
-    program.getGlobalBlock().getStatements().addAll(expected);
+  protected Result optimize(String js, Class<?>... toExec) throws Exception {
+    JsProgram program = buildProgram(js);
 
     for (Class<?> clazz : toExec) {
       Method m = clazz.getMethod("exec", JsProgram.class);
       m.invoke(null, program);
     }
 
-    TextOutput text = new DefaultTextOutput(true);
-    JsVisitor generator = new JsSourceGenerationVisitor(text);
-
-    generator.accept(program);
-    return text.toString();
+    return new Result(program.toSource());
   }
+
 }
\ No newline at end of file

