From 962a1f2dc39b2ce0f54ae09a31598baf33d46136 Mon Sep 17 00:00:00 2001 From: Sudipto Chandra Date: Wed, 18 Sep 2024 14:18:25 +0400 Subject: [PATCH] Fix tests --- test/random/uuid_test.dart | 73 +++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/test/random/uuid_test.dart b/test/random/uuid_test.dart index 4520330..005d81f 100644 --- a/test/random/uuid_test.dart +++ b/test/random/uuid_test.dart @@ -8,6 +8,27 @@ import 'package:hashlib/codecs.dart'; import 'package:hashlib/src/uuid.dart'; import 'package:test/test.dart'; +@pragma('vm:entry-point') +String runIsolate(version) { + switch (version) { + case 'v1': + return uuid.v1(); + case 'v3': + return uuid.v3(); + case 'v4': + return uuid.v4(); + case 'v5': + return uuid.v5(); + case 'v6': + return uuid.v6(); + case 'v7': + return uuid.v7(); + case 'v8': + return uuid.v8(); + } + throw ArgumentError('Undefined version: $version'); +} + void main() { group('UUID v1', () { test("known value", () { @@ -30,12 +51,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v1', errorsAreFatal: true, - ).then((value) { - return uuid.v1(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -61,12 +80,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v3', errorsAreFatal: true, - ).then((value) { - return uuid.v3(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -92,12 +109,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v4', errorsAreFatal: true, - ).then((value) { - return uuid.v4(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -123,12 +138,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v5', errorsAreFatal: true, - ).then((value) { - return uuid.v5(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -155,12 +168,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v6', errorsAreFatal: true, - ).then((value) { - return uuid.v6(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -187,12 +198,10 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v7', errorsAreFatal: true, - ).then((value) { - return uuid.v7(); - }), + ), )); expect(seeds.toSet().length, 1000); }, tags: ['vm-only']); @@ -237,8 +246,8 @@ void main() { final seeds = await Future.wait(List.generate( 1000, (_) => Isolate.spawn( - (e) => {}, - null, + runIsolate, + 'v8', errorsAreFatal: true, ).then((value) { return uuid.v8();