Index: test/mjsunit/d8-worker.js |
diff --git a/test/mjsunit/compiler/smi-stores-opt.js b/test/mjsunit/d8-worker.js |
similarity index 73% |
copy from test/mjsunit/compiler/smi-stores-opt.js |
copy to test/mjsunit/d8-worker.js |
index ca0923abc99501096d182bcdcd05f6f4020de9c9..055cbba26667d87ed7bce839a3d36a48b24675c8 100644 |
--- a/test/mjsunit/compiler/smi-stores-opt.js |
+++ b/test/mjsunit/d8-worker.js |
@@ -1,4 +1,4 @@ |
-// Copyright 2014 the V8 project authors. All rights reserved. |
+// Copyright 2015 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -25,25 +25,22 @@ |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
-// Flags: --allow-natives-syntax |
+// Test the Worker.new function of d8. This test only makes sense with d8. |
+// Worker.new spawns a new OS thread and isolate, and runs it concurrently with |
+// the current running thread. |
-var o = {a:1.5}; |
-o.a = 0; |
-var a = o.a; |
- |
-function g() { |
- return 1; |
+function f() { |
+ // Set a global variable; should not be visible outside of the worker's |
+ // context. |
+ foo = 100; |
+ return "OK"; |
} |
-var o2 = {a:{}}; |
+Worker.new(f); |
-function f() { |
- var result = {a: a}; |
- var literal = {x:g()}; |
- return [result, literal]; |
-} |
+// Currently can only create one worker at a time. |
+assertThrows(function() { Worker.new(f); }); |
-f(); |
-f(); |
-%OptimizeFunctionOnNextCall(f); |
-assertEquals(1, f()[1].x); |
+var result = Worker.join(); |
binji
2015/06/15 19:11:48
This API is a bit strange, but was the easiest to
|
+assertEquals("undefined", typeof foo); |
+assertEquals("OK", result); |