-
Notifications
You must be signed in to change notification settings - Fork 256
/
isolate_test.dart
31 lines (24 loc) · 879 Bytes
/
isolate_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import 'dart:isolate';
import 'package:frb_example_pure_dart/src/rust/api/pseudo_manual/simple_twin_sync.dart';
import 'package:frb_example_pure_dart/src/rust/api/simple.dart';
import 'package:frb_example_pure_dart/src/rust/frb_generated.dart';
import 'package:test/test.dart';
Future<void> main() async {
await RustLib.init();
test('can execute in another isolate', () async {
// Can call in current isolate
expect(await simpleAdderTwinNormal(a: 42, b: 100), 142);
expect(simpleAdderTwinSync(a: 42, b: 100), 142);
final isolateResults = await Isolate.run(() async {
await RustLib.init();
// Can call in new isolate
final ans = (
await simpleAdderTwinNormal(a: 42, b: 100),
simpleAdderTwinSync(a: 42, b: 100),
);
RustLib.dispose();
return ans;
});
expect(isolateResults, (142, 142));
});
}