diff --git a/.github/workflows/protoc_plugin.yaml b/.github/workflows/protoc_plugin.yaml index 4d561c90..0d7c799c 100644 --- a/.github/workflows/protoc_plugin.yaml +++ b/.github/workflows/protoc_plugin.yaml @@ -43,3 +43,7 @@ jobs: - run: dart format --output=none --set-exit-if-changed lib - run: dart test + + - run: dart test -p chrome -c dart2js + + - run: dart test -p chrome -c dart2wasm diff --git a/protoc_plugin/test/client_generator_test.dart b/protoc_plugin/test/client_generator_test.dart index f1fb0b87..43956643 100644 --- a/protoc_plugin/test/client_generator_test.dart +++ b/protoc_plugin/test/client_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; import 'package:protoc_plugin/src/linker.dart'; diff --git a/protoc_plugin/test/deprecations_test.dart b/protoc_plugin/test/deprecations_test.dart index 42a0b2ce..1c07e487 100644 --- a/protoc_plugin/test/deprecations_test.dart +++ b/protoc_plugin/test/deprecations_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:io'; import 'package:test/test.dart'; diff --git a/protoc_plugin/test/doc_comments_test.dart b/protoc_plugin/test/doc_comments_test.dart index ccd2edf7..db65f174 100644 --- a/protoc_plugin/test/doc_comments_test.dart +++ b/protoc_plugin/test/doc_comments_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:io'; import 'package:test/test.dart'; diff --git a/protoc_plugin/test/enum_generator_test.dart b/protoc_plugin/test/enum_generator_test.dart index a60ad71f..f41bd0a2 100644 --- a/protoc_plugin/test/enum_generator_test.dart +++ b/protoc_plugin/test/enum_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; import 'package:protoc_plugin/src/gen/google/protobuf/descriptor.pb.dart'; diff --git a/protoc_plugin/test/extension_generator_test.dart b/protoc_plugin/test/extension_generator_test.dart index e09e9f7d..bd3775aa 100644 --- a/protoc_plugin/test/extension_generator_test.dart +++ b/protoc_plugin/test/extension_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; import 'package:protoc_plugin/src/gen/google/protobuf/compiler/plugin.pb.dart' diff --git a/protoc_plugin/test/file_generator_test.dart b/protoc_plugin/test/file_generator_test.dart index d561053d..13b931d7 100644 --- a/protoc_plugin/test/file_generator_test.dart +++ b/protoc_plugin/test/file_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; import 'package:protoc_plugin/src/gen/google/api/client.pb.dart'; diff --git a/protoc_plugin/test/generated_message_test.dart b/protoc_plugin/test/generated_message_test.dart index 6d35ac86..5f7cf9af 100644 --- a/protoc_plugin/test/generated_message_test.dart +++ b/protoc_plugin/test/generated_message_test.dart @@ -115,10 +115,10 @@ void main() { expect(message.utf8String, '\u1234'); expect(message.infDouble, same(double.infinity)); expect(message.negInfDouble, same(double.negativeInfinity)); - expect(message.nanDouble, same(double.nan)); + expect(message.nanDouble.isNaN, isTrue); expect(message.infFloat, same(double.infinity)); expect(message.negInfFloat, same(double.negativeInfinity)); - expect(message.nanFloat, same(double.nan)); + expect(message.nanFloat.isNaN, isTrue); expect(message.cppTrigraph, '? ? ?? ?? ??? ??/ ??-'); expect( message.smallInt64.toRadixString(16).toUpperCase(), diff --git a/protoc_plugin/test/message_generator_test.dart b/protoc_plugin/test/message_generator_test.dart index 6d6e0700..5585e5c3 100644 --- a/protoc_plugin/test/message_generator_test.dart +++ b/protoc_plugin/test/message_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:collection'; import 'package:collection/collection.dart'; diff --git a/protoc_plugin/test/oneof_test.dart b/protoc_plugin/test/oneof_test.dart index 9b17832f..a99cc31f 100644 --- a/protoc_plugin/test/oneof_test.dart +++ b/protoc_plugin/test/oneof_test.dart @@ -113,29 +113,43 @@ void main() { }); test('serialize and parse concat oneof', () { - var foo = Foo()..first = 'oneof'; - expectFirstSet(foo); + final foo1 = Foo()..first = 'oneof'; + expectFirstSet(foo1); final foo2 = Foo()..second = 1; expectSecondSet(foo2); - final concat = [...foo.writeToBuffer(), ...foo2.writeToBuffer()]; - foo = Foo.fromBuffer(concat); - expectSecondSet(foo); + final concat = [...foo1.writeToBuffer(), ...foo2.writeToBuffer()]; + expectSecondSet(Foo.fromBuffer(concat)); }); test('JSON serialize and parse concat oneof', () { - var foo = Foo()..first = 'oneof'; - expectFirstSet(foo); + final foo1 = Foo()..first = 'oneof'; + expectFirstSet(foo1); final foo2 = Foo()..second = 1; expectSecondSet(foo2); final jsonConcat = '${foo2.writeToJson().substring(0, foo2.writeToJson().length - 1)}, ' - '${foo.writeToJson().substring(1)}'; - foo = Foo.fromJson(jsonConcat); - expectFirstSet(foo); + '${foo1.writeToJson().substring(1)}'; + + final decoded = Foo.fromJson(jsonConcat); + + // It's unclear how to handle the input `{5:..., 1:...}` in this format. In + // the browsers we want to use the browser's JSON decoder, for performance. + // However numeric properties in JS objects are always iterated in ascending + // order, so that makes `5` override the previous oneof value, regardless of + // the orders of keys in the JSON string. In the backends that have their + // own map types (VM and Wasm) the key that comes later override the + // previous one. + if (identical(1.0, 1)) { + // In JS: '5' comes last during object key iteration. + expectSecondSet(decoded); + } else { + // In VM and Wasm: '1' comes last during object iteration. + expectFirstSet(decoded); + } }); test('set and clear second oneof field', () { diff --git a/protoc_plugin/test/reserved_names_test.dart b/protoc_plugin/test/reserved_names_test.dart index 56376c3f..26f002c9 100644 --- a/protoc_plugin/test/reserved_names_test.dart +++ b/protoc_plugin/test/reserved_names_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:collection' show MapMixin; import 'dart:mirrors'; diff --git a/protoc_plugin/test/send_protos_via_sendports_test.dart b/protoc_plugin/test/send_protos_via_sendports_test.dart index 39b8b8a2..8e60b33f 100644 --- a/protoc_plugin/test/send_protos_via_sendports_test.dart +++ b/protoc_plugin/test/send_protos_via_sendports_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'dart:isolate'; import 'package:test/test.dart'; diff --git a/protoc_plugin/test/service_generator_test.dart b/protoc_plugin/test/service_generator_test.dart index 98dfcb45..52c2401c 100644 --- a/protoc_plugin/test/service_generator_test.dart +++ b/protoc_plugin/test/service_generator_test.dart @@ -2,6 +2,9 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +@TestOn('vm') +library; + import 'package:protoc_plugin/indenting_writer.dart'; import 'package:protoc_plugin/protoc.dart'; import 'package:protoc_plugin/src/linker.dart';