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

Unified Diff: test/mjsunit/harmony/module-recompile.js

Issue 10690043: Implement proper module linking. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed Michael's comments. Created 8 years, 5 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: 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())
}

Powered by Google App Engine
This is Rietveld 408576698