A one-line fix to the currently broken support for a runAsync initial
load sequence. Additionally, this patch adds a test case of
said specification.
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5590 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
index ad31b33..f093396 100644
--- a/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/ast/JProgram.java
@@ -1050,7 +1050,7 @@
public void setSplitPointInitialSequence(List<Integer> list) {
assert splitPointInitialSequence.isEmpty();
- splitPointInitialSequence.addAll(list);
+ splitPointInitialSequence = new ArrayList<Integer>(list);
}
/**
diff --git a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
index 146fa61..6396c90 100644
--- a/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
+++ b/user/test/com/google/gwt/dev/jjs/CompilerSuite.java
@@ -27,6 +27,7 @@
import com.google.gwt.dev.jjs.test.EnumsTest;
import com.google.gwt.dev.jjs.test.GenericCastTest;
import com.google.gwt.dev.jjs.test.HostedTest;
+import com.google.gwt.dev.jjs.test.InitialLoadSequenceTest;
import com.google.gwt.dev.jjs.test.InnerClassTest;
import com.google.gwt.dev.jjs.test.InnerOuterSuperTest;
import com.google.gwt.dev.jjs.test.JStaticEvalTest;
@@ -70,6 +71,7 @@
suite.addTestSuite(EnumsTest.class);
suite.addTestSuite(GenericCastTest.class);
suite.addTestSuite(HostedTest.class);
+ suite.addTestSuite(InitialLoadSequenceTest.class);
suite.addTestSuite(InnerClassTest.class);
suite.addTestSuite(InnerOuterSuperTest.class);
suite.addTestSuite(JsniConstructorTest.class);
diff --git a/user/test/com/google/gwt/dev/jjs/InitialLoadSequence.gwt.xml b/user/test/com/google/gwt/dev/jjs/InitialLoadSequence.gwt.xml
new file mode 100644
index 0000000..5c8a752
--- /dev/null
+++ b/user/test/com/google/gwt/dev/jjs/InitialLoadSequence.gwt.xml
@@ -0,0 +1,25 @@
+<!-- -->
+<!-- Copyright 2009 Google Inc. -->
+<!-- Licensed under the Apache License, Version 2.0 (the "License"); you -->
+<!-- may not use this file except in compliance with the License. You may -->
+<!-- may obtain a copy of the License at -->
+<!-- -->
+<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
+<!-- -->
+<!-- Unless required by applicable law or agreed to in writing, software -->
+<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
+<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -->
+<!-- implied. License for the specific language governing permissions and -->
+<!-- limitations under the License. -->
+
+<module>
+ <inherits name="com.google.gwt.core.Core" />
+
+ <source path='test' />
+
+ <!-- Specify an initial load sequence -->
+ <extend-configuration-property name="compiler.splitpoint.initial.sequence"
+ value="@com.google.gwt.dev.jjs.test.InitialLoadSequenceTest::callback1()" />
+ <extend-configuration-property name="compiler.splitpoint.initial.sequence"
+ value="@com.google.gwt.dev.jjs.test.InitialLoadSequenceTest::callback2()" />
+</module>
diff --git a/user/test/com/google/gwt/dev/jjs/test/InitialLoadSequenceTest.java b/user/test/com/google/gwt/dev/jjs/test/InitialLoadSequenceTest.java
new file mode 100644
index 0000000..478727e
--- /dev/null
+++ b/user/test/com/google/gwt/dev/jjs/test/InitialLoadSequenceTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.dev.jjs.test;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.RunAsyncCallback;
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * This test tests that specifying an initial sequence of runAsyncs works. It
+ * has three callbacks which each have a runAsync in them. It then calls the
+ * callbacks in a different order than predicted.
+ */
+public class InitialLoadSequenceTest extends GWTTestCase {
+ private static final int TIMEOUT = 10000;
+ /**
+ * The number of callbacks outstanding. When this gets to zero, the test
+ * finishes.
+ */
+ private int callbacksOutstanding;
+
+ @Override
+ public String getModuleName() {
+ return "com.google.gwt.dev.jjs.InitialLoadSequence";
+ }
+
+ public void testBackwards() {
+ callbacksOutstanding = 3;
+ delayTestFinish(TIMEOUT);
+ callback3();
+ callback2();
+ callback1();
+ }
+
+ private void callback1() {
+ GWT.runAsync(new RunAsyncCallback() {
+ public void onFailure(Throwable reason) {
+ fail(reason.toString());
+ }
+
+ public void onSuccess() {
+ countCallback();
+ }
+ });
+ }
+
+ private void callback2() {
+ GWT.runAsync(new RunAsyncCallback() {
+ public void onFailure(Throwable reason) {
+ fail(reason.toString());
+ }
+
+ public void onSuccess() {
+ countCallback();
+ }
+ });
+ }
+
+ private void callback3() {
+ GWT.runAsync(new RunAsyncCallback() {
+ public void onFailure(Throwable reason) {
+ fail(reason.toString());
+ }
+
+ public void onSuccess() {
+ countCallback();
+ }
+ });
+ }
+
+ private void countCallback() {
+ callbacksOutstanding--;
+ if (callbacksOutstanding == 0) {
+ finishTest();
+ }
+ }
+}