 Chromium Code Reviews
 Chromium Code Reviews Issue 955053002:
  adding codereview file, formatting, adding gitignore  (Closed) 
  Base URL: https://github.com/dart-lang/isolate.git@master
    
  
    Issue 955053002:
  adding codereview file, formatting, adding gitignore  (Closed) 
  Base URL: https://github.com/dart-lang/isolate.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 library dart.pkg.isolate.isolaterunner_test; | 5 library dart.pkg.isolate.isolaterunner_test; | 
| 6 | 6 | 
| 7 import "package:isolate/isolaterunner.dart"; | 7 import "package:isolate/isolaterunner.dart"; | 
| 8 import "package:unittest/unittest.dart"; | 8 import "package:unittest/unittest.dart"; | 
| 9 import "dart:async" show Future; | 9 import "dart:async" show Future; | 
| 10 import "dart:isolate" show Capability; | 10 import "dart:isolate" show Capability; | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 return IsolateRunner.spawn().then((IsolateRunner runner) { | 28 return IsolateRunner.spawn().then((IsolateRunner runner) { | 
| 29 return runner.run(id, "testCreateRunClose").then((v) { | 29 return runner.run(id, "testCreateRunClose").then((v) { | 
| 30 expect(v, "testCreateRunClose"); | 30 expect(v, "testCreateRunClose"); | 
| 31 return runner.close().then((_) => runner.onExit); | 31 return runner.close().then((_) => runner.onExit); | 
| 32 }); | 32 }); | 
| 33 }); | 33 }); | 
| 34 } | 34 } | 
| 35 | 35 | 
| 36 Future testSeparateIsolates() { | 36 Future testSeparateIsolates() { | 
| 37 // Check that each isolate has its own _global variable. | 37 // Check that each isolate has its own _global variable. | 
| 38 return Future.wait(new Iterable.generate(2, (_) => IsolateRunner.spawn())) | 38 return Future | 
| 39 .then((runners) { | 39 .wait(new Iterable.generate(2, (_) => IsolateRunner.spawn())) | 
| 40 Future runAll(action(IsolateRunner runner, int index)) { | 40 .then((runners) { | 
| 41 var indices = new Iterable.generate(runners.length); | 41 Future runAll(action(IsolateRunner runner, int index)) { | 
| 
Lasse Reichstein Nielsen
2015/02/26 10:59:15
Indent body by four more.
 | |
| 42 return Future.wait(indices.map((i) => action(runners[i], i))); | 42 var indices = new Iterable.generate(runners.length); | 
| 43 } | 43 return Future.wait(indices.map((i) => action(runners[i], i))); | 
| 44 } | |
| 44 | 45 | 
| 45 return runAll((runner, i) => runner.run(setGlobal, i + 1)) | 46 return runAll((runner, i) => runner.run(setGlobal, i + 1)).then((values) { | 
| 
Lasse Reichstein Nielsen
2015/02/26 10:59:15
This one is acceptable, but I still think it's bet
 | |
| 46 .then((values) { | 47 expect(values, [1, 2]); | 
| 47 expect(values, [1, 2]); | 48 expect(_global, null); | 
| 48 expect(_global, null); | 49 return runAll((runner, _) => runner.run(getGlobal, null)); | 
| 49 return runAll((runner, _) => runner.run(getGlobal, null)); | 50 }).then((values) { | 
| 50 }) | 51 expect(values, [1, 2]); | 
| 51 .then((values) { | 52 expect(_global, null); | 
| 52 expect(values, [1, 2]); | 53 return runAll((runner, _) => runner.close()); | 
| 53 expect(_global, null); | |
| 54 return runAll((runner, _) => runner.close()); | |
| 55 }); | |
| 56 }); | 54 }); | 
| 55 }); | |
| 57 } | 56 } | 
| 58 | 57 | 
| 59 void testIsolateFunctions() { | 58 void testIsolateFunctions() { | 
| 60 test("pause", () { | 59 test("pause", () { | 
| 61 bool mayComplete = false; | 60 bool mayComplete = false; | 
| 62 return IsolateRunner.spawn().then((isolate) { | 61 return IsolateRunner.spawn().then((isolate) { | 
| 63 isolate.pause(); | 62 isolate.pause(); | 
| 64 new Future.delayed(MS * 500, () { | 63 new Future.delayed(MS * 500, () { | 
| 65 mayComplete = true; | 64 mayComplete = true; | 
| 66 isolate.resume(); | 65 isolate.resume(); | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 return isolate.kill(); | 104 return isolate.kill(); | 
| 106 }); | 105 }); | 
| 107 }); | 106 }); | 
| 108 } | 107 } | 
| 109 | 108 | 
| 110 id(x) => x; | 109 id(x) => x; | 
| 111 | 110 | 
| 112 var _global; | 111 var _global; | 
| 113 getGlobal(_) => _global; | 112 getGlobal(_) => _global; | 
| 114 void setGlobal(v) => _global = v; | 113 void setGlobal(v) => _global = v; | 
| OLD | NEW |