Index: test/mjsunit/harmony/module-recompile.js |
diff --git a/test/mjsunit/regress/regress-2054.js b/test/mjsunit/harmony/module-recompile.js |
similarity index 63% |
copy from test/mjsunit/regress/regress-2054.js |
copy to test/mjsunit/harmony/module-recompile.js |
index 97b989c944303a69fa01cc15fcf78c0d83376c45..23f5bfc4d4549c678804efe365bea90350d643fd 100644 |
--- a/test/mjsunit/regress/regress-2054.js |
+++ b/test/mjsunit/harmony/module-recompile.js |
@@ -25,10 +25,63 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Test that we can correctly optimize top level code that contains a |
-// throw (or return) as it's last statement. |
+// Flags: --harmony-modules |
+ |
+// Test that potential recompilation of the global scope does not screw up. |
+ |
+"use strict"; |
+ |
+var N = 1e5; // Number of loop iterations that trigger optimization. |
+ |
+module A { |
+ export var x = 1 |
+ export function f() { return x } |
+} |
+var f = A.f |
+ |
+assertEquals(1, A.x) |
+assertEquals(1, A.f()) |
+assertEquals(1, f()) |
+ |
+A.x = 2 |
+ |
+assertEquals(2, A.x) |
+assertEquals(2, A.f()) |
+assertEquals(2, f()) |
-var N = 1e5; // Number of iterations that trigger optimization. |
for (var i = 0; i < N; i++) { |
- if (i > N) throw new Error; |
+ if (i > N) print("impossible"); |
+} |
+ |
+assertEquals(2, A.x) |
+assertEquals(2, A.f()) |
+assertEquals(2, f()) |
+ |
+ |
+// Same test with loop inside a module. |
+ |
+module B { |
+ module A { |
+ export var x = 1 |
+ export function f() { return x } |
+ } |
+ var f = A.f |
+ |
+ assertEquals(1, A.x) |
+ assertEquals(1, A.f()) |
+ assertEquals(1, f()) |
+ |
+ A.x = 2 |
+ |
+ assertEquals(2, A.x) |
+ assertEquals(2, A.f()) |
+ assertEquals(2, f()) |
+ |
+ for (var i = 0; i < N; i++) { |
+ if (i > N) print("impossible"); |
+ } |
+ |
+ assertEquals(2, A.x) |
+ assertEquals(2, A.f()) |
+ assertEquals(2, f()) |
} |