Make tests/lib/js/static_interop not use minitest.
Change-Id: Id7a8a6ac0098df55b04fa089587c62b07e9cf3c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403860
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
diff --git a/sdk/lib/_internal/js_shared/lib/js_util_patch.dart b/sdk/lib/_internal/js_shared/lib/js_util_patch.dart
index 9ee8daa..7e09dfc 100644
--- a/sdk/lib/_internal/js_shared/lib/js_util_patch.dart
+++ b/sdk/lib/_internal/js_shared/lib/js_util_patch.dart
@@ -525,7 +525,7 @@
@patch
@pragma('dart2js:tryInline')
T not<T>(Object? o) {
- return JS<dynamic>('Object', '!#', o);
+ return JS<T>('bool', '!#', o);
}
@patch
@@ -537,13 +537,13 @@
@patch
@pragma('dart2js:tryInline')
T or<T>(Object? first, Object? second) {
- return JS<dynamic>('Object|bool', '# || #', first, second);
+ return JS<dynamic>('Object|Null|bool', '# || #', first, second);
}
@patch
@pragma('dart2js:tryInline')
T and<T>(Object? first, Object? second) {
- return JS<dynamic>('Object|bool', '# && #', first, second);
+ return JS<dynamic>('Object|Null|bool', '# && #', first, second);
}
@patch
diff --git a/tests/lib/js/static_interop_test/allowed_external_member_native_type_test.dart b/tests/lib/js/static_interop_test/allowed_external_member_native_type_test.dart
index 2fd0355..cbb5903 100644
--- a/tests/lib/js/static_interop_test/allowed_external_member_native_type_test.dart
+++ b/tests/lib/js/static_interop_test/allowed_external_member_native_type_test.dart
@@ -6,9 +6,6 @@
// valid ones are those that <: `JavaScriptObject` and users can reference,
// which end up only being the types in the SDK web libraries.
-@JS()
-library allowed_external_member_native_type_test;
-
import 'dart:html';
import 'dart:js_interop';
import 'dart:svg';
diff --git a/tests/lib/js/static_interop_test/allowed_external_member_type_test.dart b/tests/lib/js/static_interop_test/allowed_external_member_type_test.dart
index f7d57be..d8861dd 100644
--- a/tests/lib/js/static_interop_test/allowed_external_member_type_test.dart
+++ b/tests/lib/js/static_interop_test/allowed_external_member_type_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library allowed_external_member_type_test;
-
import 'dart:js_interop';
import 'package:js/js.dart' as pkgJs;
@@ -192,8 +189,13 @@
@JS()
external void primitivesMethod(num a, int b, double c, bool d, String e);
-void functionToJSTest<T extends JSAny, U extends ExtensionType,
- V extends StaticInterop, W, Y>() {
+void functionToJSTest<
+ T extends JSAny,
+ U extends ExtensionType,
+ V extends StaticInterop,
+ W,
+ Y
+>() {
// Test `toJS` conversions of functions.
((double _) => 4.0.toJS).toJS;
diff --git a/tests/lib/js/static_interop_test/call_utils.dart b/tests/lib/js/static_interop_test/call_utils.dart
index fdd268d..95d192d 100644
--- a/tests/lib/js/static_interop_test/call_utils.dart
+++ b/tests/lib/js/static_interop_test/call_utils.dart
@@ -15,8 +15,7 @@
external JSAny? eval(String script);
void injectJS() {
- eval(
- '''
+ eval('''
self.jsFunction = function(s) {
if (this == null) {
throw "`this` is null or undefined";
@@ -47,8 +46,7 @@
}
}
self.jsClass = new NamedClass();
- ''',
- );
+ ''');
}
bool jsThisIsNullCheck(e) =>
diff --git a/tests/lib/js/static_interop_test/constants_test.dart b/tests/lib/js/static_interop_test/constants_test.dart
index 4ed689f..34bf104 100644
--- a/tests/lib/js/static_interop_test/constants_test.dart
+++ b/tests/lib/js/static_interop_test/constants_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library constants_test;
-
import 'dart:html';
import 'package:js/js.dart';
diff --git a/tests/lib/js/static_interop_test/disallowed_generative_constructor_static_test.dart b/tests/lib/js/static_interop_test/disallowed_generative_constructor_static_test.dart
index 2d83bf6..a541e2f 100644
--- a/tests/lib/js/static_interop_test/disallowed_generative_constructor_static_test.dart
+++ b/tests/lib/js/static_interop_test/disallowed_generative_constructor_static_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library disallowed_generative_constructor_static_test;
-
import 'package:js/js.dart';
@JS()
@@ -24,16 +21,16 @@
void main() {
SyntheticConstructor();
-//^
-// [web] Synthetic constructors on `@staticInterop` classes can not be used.
+ // [error column 3]
+ // [web] Synthetic constructors on `@staticInterop` classes can not be used.
SyntheticConstructor.new;
-//^
-// [web] Synthetic constructors on `@staticInterop` classes can not be used.
+ // [error column 3]
+ // [web] Synthetic constructors on `@staticInterop` classes can not be used.
// Make sure that we report an error for every usage of the constant and that
// we check nested constants.
const [SyntheticConstructor.new];
-//^
-// [web] Synthetic constructors on `@staticInterop` classes can not be used.
+ // [error column 3]
+ // [web] Synthetic constructors on `@staticInterop` classes can not be used.
}
diff --git a/tests/lib/js/static_interop_test/extension_type/external_extension_member_test.dart b/tests/lib/js/static_interop_test/extension_type/external_extension_member_test.dart
index 75ed1b2..4f6b1eb 100644
--- a/tests/lib/js/static_interop_test/extension_type/external_extension_member_test.dart
+++ b/tests/lib/js/static_interop_test/extension_type/external_extension_member_test.dart
@@ -2,12 +2,8 @@
// 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.
-@JS()
-library external_extension_member_test;
-
import 'dart:js_interop';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
@JS()
external void eval(String code);
@@ -52,24 +48,24 @@
var extension = ExtensionType();
// Fields.
- expect(extension.field, 'field');
+ Expect.equals('field', extension.field);
extension.field = 'modified';
- expect(extension.field, 'modified');
- expect(extension.renamedField, 'modified');
+ Expect.equals('modified', extension.field);
+ Expect.equals('modified', extension.renamedField);
extension.renamedField = 'renamedField';
- expect(extension.renamedField, 'renamedField');
- expect(extension.finalField, 'finalField');
+ Expect.equals('renamedField', extension.renamedField);
+ Expect.equals('finalField', extension.finalField);
// Getters and setters.
- expect(extension.getSet, 'getSet');
+ Expect.equals('getSet', extension.getSet);
extension.getSet = 'modified';
- expect(extension.getSet, 'modified');
- expect(extension.renamedGetSet, 'modified');
+ Expect.equals('modified', extension.getSet);
+ Expect.equals('modified', extension.renamedGetSet);
extension.renamedGetSet = 'renamedGetSet';
- expect(extension.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', extension.renamedGetSet);
// Methods.
- expect(extension.method(), 'method');
- expect(extension.differentArgsMethod('method'), 'methodundefined');
- expect(extension.renamedMethod(), 'method');
+ Expect.equals('method', extension.method());
+ Expect.equals('methodundefined', extension.differentArgsMethod('method'));
+ Expect.equals('method', extension.renamedMethod());
}
diff --git a/tests/lib/js/static_interop_test/extension_type/external_member_test.dart b/tests/lib/js/static_interop_test/extension_type/external_member_test.dart
index c53a2bb..29af583 100644
--- a/tests/lib/js/static_interop_test/extension_type/external_member_test.dart
+++ b/tests/lib/js/static_interop_test/extension_type/external_member_test.dart
@@ -2,13 +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.
-@JS()
-library external_member_test;
-
import 'dart:js_interop';
import 'package:expect/expect.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
import 'package:expect/variations.dart';
const soundNullSafety = !unsoundNullSafety;
@@ -41,8 +37,11 @@
@JS('addMethod')
external T addMethodT(T a, T b);
@JS('addMethod')
- external R addMethodGeneric<R extends JSAny?, P extends JSAny?>(P a, P b,
- [bool dontAddNull]);
+ external R addMethodGeneric<R extends JSAny?, P extends JSAny?>(
+ P a,
+ P b, [
+ bool dontAddNull,
+ ]);
external Nested nested;
external Nested combineNested(Nested a, Nested b);
@@ -87,61 +86,65 @@
final external = External<JSString, Nested>();
// Fields.
- expect(external.field, 'field');
+ Expect.equals('field', external.field);
external.field = 'modified';
- expect(external.field, 'modified');
- expect(external.renamedField, 'modified');
+ Expect.equals('modified', external.field);
+ Expect.equals('modified', external.renamedField);
external.renamedField = 'renamedField';
- expect(external.renamedField, 'renamedField');
- expect(external.finalField, 'finalField');
+ Expect.equals('renamedField', external.renamedField);
+ Expect.equals('finalField', external.finalField);
// Getters and setters.
- expect(external.getSet, 'getSet');
+ Expect.equals('getSet', external.getSet);
external.getSet = 'modified';
- expect(external.getSet, 'modified');
- expect(external.renamedGetSet, 'modified');
+ Expect.equals('modified', external.getSet);
+ Expect.equals('modified', external.renamedGetSet);
external.renamedGetSet = 'renamedGetSet';
- expect(external.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', external.renamedGetSet);
// Methods.
- expect(external.method(), 'method');
- expect(external.addMethod('method'), 'methodundefined');
- expect(external.addMethod('method', 'method'), 'methodmethod');
- expect(external.renamedMethod(), 'method');
+ Expect.equals('method', external.method());
+ Expect.equals('methodundefined', external.addMethod('method'));
+ Expect.equals('methodmethod', external.addMethod('method', 'method'));
+ Expect.equals('method', external.renamedMethod());
// Check that type parameters operate as expected on external interfaces.
final value = 'value';
final jsValue = value.toJS;
external.fieldT = jsValue;
- expect(external.fieldT.toDart, value);
- expect(external.addMethodT(jsValue, jsValue).toDart, '$value$value');
- expect(
- external.addMethodGeneric<JSNumber, JSNumber>(0.toJS, 0.toJS).toDartInt,
- 0);
+ Expect.equals(value, external.fieldT.toDart);
+ Expect.equals('$value$value', external.addMethodT(jsValue, jsValue).toDart);
+ Expect.equals(
+ 0,
+ external.addMethodGeneric<JSNumber, JSNumber>(0.toJS, 0.toJS).toDartInt,
+ );
external.nested = Nested(jsValue);
- expect((external.nested as Nested<JSString>).value.toDart, value);
- expect(
- (external.combineNested(Nested(value.toJS), Nested(jsValue))
- as Nested<JSString>)
- .value
- .toDart,
- '$value$value');
+ Expect.equals(value, (external.nested as Nested<JSString>).value.toDart);
+ Expect.equals(
+ '$value$value',
+ (external.combineNested(Nested(value.toJS), Nested(jsValue))
+ as Nested<JSString>)
+ .value
+ .toDart,
+ );
external.nestedU = Nested(jsValue);
- expect((external.nestedU as Nested<JSString>).value.toDart, value);
- expect(
- (external.combineNestedU(Nested(jsValue), Nested(jsValue))
- as Nested<JSString>)
- .value
- .toDart,
- '$value$value');
- expect(
- external
- .combineNestedGeneric(Nested(jsValue), Nested(jsValue))
- .value
- .toDart,
- '$value$value');
+ Expect.equals(value, (external.nestedU as Nested<JSString>).value.toDart);
+ Expect.equals(
+ '$value$value',
+ (external.combineNestedU(Nested(jsValue), Nested(jsValue))
+ as Nested<JSString>)
+ .value
+ .toDart,
+ );
+ Expect.equals(
+ '$value$value',
+ external
+ .combineNestedGeneric(Nested(jsValue), Nested(jsValue))
+ .value
+ .toDart,
+ );
// Try invalid generics.
(external as External<JSNumber, Nested>).fieldT = 0.toJS;
@@ -151,15 +154,25 @@
Expect.throws(() => external.fieldT.toDart.toLowerCase());
(external as External<JSNumber?, Nested>).fieldT = null;
Expect.throwsWhen(
- soundNullSafety && checkedImplicitDowncasts, () => external.fieldT);
- Expect.throws(() => external
- .addMethodGeneric<JSNumber, JSString>(value.toJS, value.toJS)
- .toDartInt);
- Expect.throws(() => external
- .addMethodGeneric<JSString, JSNumber>(0.toJS, 0.toJS)
- .toDart
- .toLowerCase());
- Expect.throwsWhen(soundNullSafety && checkedImplicitDowncasts,
- () => external.addMethodGeneric<JSString, JSString?>(null, null, true));
+ soundNullSafety && checkedImplicitDowncasts,
+ () => external.fieldT,
+ );
+ Expect.throws(
+ () =>
+ external
+ .addMethodGeneric<JSNumber, JSString>(value.toJS, value.toJS)
+ .toDartInt,
+ );
+ Expect.throws(
+ () =>
+ external
+ .addMethodGeneric<JSString, JSNumber>(0.toJS, 0.toJS)
+ .toDart
+ .toLowerCase(),
+ );
+ Expect.throwsWhen(
+ soundNullSafety && checkedImplicitDowncasts,
+ () => external.addMethodGeneric<JSString, JSString?>(null, null, true),
+ );
external.addMethodGeneric<JSString?, JSString?>(''.toJS, null, true);
}
diff --git a/tests/lib/js/static_interop_test/extension_type/external_static_member_test.dart b/tests/lib/js/static_interop_test/extension_type/external_static_member_test.dart
index b683a93..9b3d02b 100644
--- a/tests/lib/js/static_interop_test/extension_type/external_static_member_test.dart
+++ b/tests/lib/js/static_interop_test/extension_type/external_static_member_test.dart
@@ -6,13 +6,9 @@
// should combine this with
// tests/lib/js/static_interop_test/external_static_member_lowerings_test.dart.
-@JS()
-library external_static_member_test;
-
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
import 'external_static_member_with_namespaces.dart' as namespace;
@@ -46,8 +42,8 @@
void testStaticMembers() {
// Constructors.
void testExternalConstructorCall(ExternalStatic externalStatic) {
- expect((externalStatic['a'] as JSNumber).toDartInt, 0);
- expect((externalStatic['b'] as JSString).toDart, '');
+ Expect.equals(0, (externalStatic['a'] as JSNumber).toDartInt);
+ Expect.equals('', (externalStatic['b'] as JSString).toDart);
}
testExternalConstructorCall(ExternalStatic());
@@ -56,32 +52,32 @@
testExternalConstructorCall(ExternalStatic.nonExternal());
// Fields.
- expect(ExternalStatic.field, 'field');
+ Expect.equals('field', ExternalStatic.field);
ExternalStatic.field = 'modified';
- expect(ExternalStatic.field, 'modified');
- expect(ExternalStatic.renamedField, 'modified');
+ Expect.equals('modified', ExternalStatic.field);
+ Expect.equals('modified', ExternalStatic.renamedField);
ExternalStatic.renamedField = 'renamedField';
- expect(ExternalStatic.renamedField, 'renamedField');
- expect(ExternalStatic.finalField, 'finalField');
+ Expect.equals('renamedField', ExternalStatic.renamedField);
+ Expect.equals('finalField', ExternalStatic.finalField);
// Getters and setters.
- expect(ExternalStatic.getSet, 'getSet');
+ Expect.equals('getSet', ExternalStatic.getSet);
ExternalStatic.getSet = 'modified';
- expect(ExternalStatic.getSet, 'modified');
- expect(ExternalStatic.renamedGetSet, 'modified');
+ Expect.equals('modified', ExternalStatic.getSet);
+ Expect.equals('modified', ExternalStatic.renamedGetSet);
ExternalStatic.renamedGetSet = 'renamedGetSet';
- expect(ExternalStatic.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', ExternalStatic.renamedGetSet);
// Methods.
- expect(ExternalStatic.method(), 'method');
- expect(ExternalStatic.renamedMethod(), 'method');
+ Expect.equals('method', ExternalStatic.method());
+ Expect.equals('method', ExternalStatic.renamedMethod());
}
void testNamespacedStaticMembers() {
// Constructors.
void testExternalConstructorCall(namespace.ExternalStatic externalStatic) {
- expect((externalStatic['a'] as JSNumber).toDartInt, 0);
- expect((externalStatic['b'] as JSString).toDart, '');
+ Expect.equals(0, (externalStatic['a'] as JSNumber).toDartInt);
+ Expect.equals('', (externalStatic['b'] as JSString).toDart);
}
testExternalConstructorCall(namespace.ExternalStatic());
@@ -90,25 +86,25 @@
testExternalConstructorCall(namespace.ExternalStatic.nonExternal());
// Fields.
- expect(namespace.ExternalStatic.field, 'field');
+ Expect.equals('field', namespace.ExternalStatic.field);
namespace.ExternalStatic.field = 'modified';
- expect(namespace.ExternalStatic.field, 'modified');
- expect(namespace.ExternalStatic.renamedField, 'modified');
+ Expect.equals('modified', namespace.ExternalStatic.field);
+ Expect.equals('modified', namespace.ExternalStatic.renamedField);
namespace.ExternalStatic.renamedField = 'renamedField';
- expect(namespace.ExternalStatic.renamedField, 'renamedField');
- expect(namespace.ExternalStatic.finalField, 'finalField');
+ Expect.equals('renamedField', namespace.ExternalStatic.renamedField);
+ Expect.equals('finalField', namespace.ExternalStatic.finalField);
// Getters and setters.
- expect(namespace.ExternalStatic.getSet, 'getSet');
+ Expect.equals('getSet', namespace.ExternalStatic.getSet);
namespace.ExternalStatic.getSet = 'modified';
- expect(namespace.ExternalStatic.getSet, 'modified');
- expect(namespace.ExternalStatic.renamedGetSet, 'modified');
+ Expect.equals('modified', namespace.ExternalStatic.getSet);
+ Expect.equals('modified', namespace.ExternalStatic.renamedGetSet);
namespace.ExternalStatic.renamedGetSet = 'renamedGetSet';
- expect(namespace.ExternalStatic.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', namespace.ExternalStatic.renamedGetSet);
// Methods.
- expect(namespace.ExternalStatic.method(), 'method');
- expect(namespace.ExternalStatic.renamedMethod(), 'method');
+ Expect.equals('method', namespace.ExternalStatic.method());
+ Expect.equals('method', namespace.ExternalStatic.renamedMethod());
}
void main() {
diff --git a/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_test.dart b/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_test.dart
index e09958a..5e1a2e6 100644
--- a/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_test.dart
+++ b/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_test.dart
@@ -6,8 +6,7 @@
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
extension type Literal._(JSObject _) implements JSObject {
external Literal({double? a, String b, bool? c});
@@ -20,22 +19,22 @@
// This is not guaranteed to be the same across different backends.
void testProperties(JSObject literal, {double? a, String? b, bool? c}) {
if (a != null) {
- expect(literal.has('a'), true);
- expect((literal['a'] as JSNumber).toDartDouble, a);
+ Expect.isTrue(literal.has('a'));
+ Expect.equals(a, (literal['a'] as JSNumber).toDartDouble);
} else {
- expect(literal.has('a'), false);
+ Expect.isFalse(literal.has('a'));
}
if (b != null) {
- expect(literal.has('b'), true);
- expect((literal['b'] as JSString).toDart, b);
+ Expect.isTrue(literal.has('b'));
+ Expect.equals(b, (literal['b'] as JSString).toDart);
} else {
- expect(literal.has('b'), false);
+ Expect.isFalse(literal.has('b'));
}
if (c != null) {
- expect(literal.has('c'), true);
- expect((literal['c'] as JSBoolean).toDart, c);
+ Expect.isTrue(literal.has('c'));
+ Expect.equals(c, (literal['c'] as JSBoolean).toDart);
} else {
- expect(literal.has('c'), false);
+ Expect.isFalse(literal.has('c'));
}
}
diff --git a/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_with_library_annotation_test.dart b/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_with_library_annotation_test.dart
index dcf6ee1..b32178a 100644
--- a/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_with_library_annotation_test.dart
+++ b/tests/lib/js/static_interop_test/extension_type/object_literal_constructor_with_library_annotation_test.dart
@@ -6,7 +6,7 @@
// lowerings.
@JS()
-library object_literal_constructor_with_library_annotation_test;
+library;
import 'dart:js_interop';
diff --git a/tests/lib/js/static_interop_test/external_extension_members_test.dart b/tests/lib/js/static_interop_test/external_extension_members_test.dart
index ef4b201..3a93c00 100644
--- a/tests/lib/js/static_interop_test/external_extension_members_test.dart
+++ b/tests/lib/js/static_interop_test/external_extension_members_test.dart
@@ -5,13 +5,9 @@
// Tests behavior of external extension members, which are routed to js_util
// calls by a CFE transformation.
-@JS()
-library external_extension_members_test;
-
import 'dart:js_interop';
import 'package:expect/expect.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
// To test non-JS types for @staticInterop.
import 'package:js/js.dart' as pkgJs;
import 'package:js/js_util.dart' as js_util;
@@ -129,91 +125,108 @@
}
""");
- test('fields', () {
+ {
+ // fields.
+
var foo = Foo(42);
// field getters
- expect(foo.field, equals(42));
- expect(foo.finalField, equals(42));
- expect(foo.annotatedField, equals(42));
+ Expect.equals(42, foo.field);
+ Expect.equals(42, foo.finalField);
+ Expect.equals(42, foo.annotatedField);
// field setters
foo.field = 'squid';
- expect(foo.field, equals('squid'));
+ Expect.equals('squid', foo.field);
foo.annotatedField = 'octopus';
- expect(foo.annotatedField, equals('octopus'));
+ Expect.equals('octopus', foo.annotatedField);
js_util.setProperty(foo, 'fieldAnnotation', 'clownfish');
- expect(foo.annotatedField, equals('clownfish'));
- });
+ Expect.equals('clownfish', foo.annotatedField);
+ }
- test('getters', () {
+ {
+ // getters.
+
var foo = Foo(42);
- expect(foo.getter, equals(42));
- expect(foo.annotatedGetter, equals(42));
+ Expect.equals(42, foo.getter);
+ Expect.equals(42, foo.annotatedGetter);
js_util.setProperty(foo, 'getterAnnotation', 'eel');
- expect(foo.annotatedGetter, equals('eel'));
- });
+ Expect.equals('eel', foo.annotatedGetter);
+ }
- test('setters', () {
+ {
+ // setters.
+
var foo = Foo(42);
foo.setter = 'starfish';
- expect(js_util.getProperty(foo, 'setter'), equals('starfish'));
+ Expect.equals('starfish', js_util.getProperty(foo, 'setter'));
foo.annotatedSetter = 'whale';
- expect(js_util.getProperty(foo, 'setterAnnotation'), equals('whale'));
- });
+ Expect.equals('whale', js_util.getProperty(foo, 'setterAnnotation'));
+ }
- test('methods', () {
+ {
+ // methods.
+
var foo = Foo(42);
- expect(foo.getField(), equals(42));
- expect(foo.extToString(), equals('Foo: 42'));
- expect(foo.getFirstEl([1, 2, 3]), equals(1));
- expect(foo.sumFn(2, 3), equals(5));
- expect(foo.otherSumFn(10, 5), equals(15));
- });
+ Expect.equals(42, foo.getField());
+ Expect.equals('Foo: 42', foo.extToString());
+ Expect.equals(1, foo.getFirstEl([1, 2, 3]));
+ Expect.equals(5, foo.sumFn(2, 3));
+ Expect.equals(15, foo.otherSumFn(10, 5));
+ }
- test('module class', () {
+ {
+ // module class.
+
var bar = Bar(5);
- expect(js_util.getProperty(bar, 'fieldAnnotation'), equals(5));
- expect(bar.barField, equals(5));
- expect(js_util.getProperty(bar, 'field'), equals(5));
+ Expect.equals(5, js_util.getProperty(bar, 'fieldAnnotation'));
+ Expect.equals(5, bar.barField);
+ Expect.equals(5, js_util.getProperty(bar, 'field'));
bar.barField = 10;
- expect(js_util.getProperty(bar, 'fieldAnnotation'), equals(5));
- expect(js_util.getProperty(bar, 'field'), equals(10));
- });
+ Expect.equals(5, js_util.getProperty(bar, 'fieldAnnotation'));
+ Expect.equals(10, js_util.getProperty(bar, 'field'));
+ }
- test('type parameters', () {
+ {
+ // type parameters.
+
final foo = Foo<JSString, Nested>(0);
final value = 'value';
final jsValue = value.toJS;
foo.fieldT = jsValue;
- expect(foo.fieldT.toDart, value);
- expect(foo.sumFnT(jsValue, jsValue).toDart, '$value$value');
- expect(foo.sumFnGeneric<JSNumber, JSNumber>(0.toJS, 0.toJS).toDartInt, 0);
+ Expect.equals(value, foo.fieldT.toDart);
+ Expect.equals('$value$value', foo.sumFnT(jsValue, jsValue).toDart);
+ Expect.equals(
+ 0,
+ foo.sumFnGeneric<JSNumber, JSNumber>(0.toJS, 0.toJS).toDartInt,
+ );
foo.nested = Nested(jsValue);
- expect((foo.nested as Nested<JSString>).value.toDart, value);
- expect(
- (foo.combineNested(Nested(value.toJS), Nested(jsValue))
- as Nested<JSString>)
- .value
- .toDart,
- '$value$value');
+ Expect.equals(value, (foo.nested as Nested<JSString>).value.toDart);
+ Expect.equals(
+ '$value$value',
+ (foo.combineNested(Nested(value.toJS), Nested(jsValue))
+ as Nested<JSString>)
+ .value
+ .toDart,
+ );
foo.nestedU = Nested(jsValue);
- expect((foo.nestedU as Nested<JSString>).value.toDart, value);
- expect(
- (foo.combineNestedU(Nested(jsValue), Nested(jsValue))
- as Nested<JSString>)
- .value
- .toDart,
- '$value$value');
- expect(
- foo.combineNestedGeneric(Nested(jsValue), Nested(jsValue)).value.toDart,
- '$value$value');
+ Expect.equals(value, (foo.nestedU as Nested<JSString>).value.toDart);
+ Expect.equals(
+ '$value$value',
+ (foo.combineNestedU(Nested(jsValue), Nested(jsValue)) as Nested<JSString>)
+ .value
+ .toDart,
+ );
+ Expect.equals(
+ '$value$value',
+ foo.combineNestedGeneric(Nested(jsValue), Nested(jsValue)).value.toDart,
+ );
// Try invalid generics.
(foo as Foo<JSNumber, Nested>).fieldT = 0.toJS;
@@ -221,13 +234,19 @@
// extern ref, so we would only see that it's not a String when we call
// methods on it.
Expect.throws(() => foo.fieldT.toDart.toLowerCase());
- Expect.throws(() => foo
- .sumFnGeneric<JSNumber, JSString>(value.toJS, value.toJS)
- .toDartInt
- .isEven);
- Expect.throws(() => foo
- .sumFnGeneric<JSString, JSNumber>(0.toJS, 0.toJS)
- .toDart
- .toLowerCase());
- });
+ Expect.throws(
+ () =>
+ foo
+ .sumFnGeneric<JSNumber, JSString>(value.toJS, value.toJS)
+ .toDartInt
+ .isEven,
+ );
+ Expect.throws(
+ () =>
+ foo
+ .sumFnGeneric<JSString, JSNumber>(0.toJS, 0.toJS)
+ .toDart
+ .toLowerCase(),
+ );
+ }
}
diff --git a/tests/lib/js/static_interop_test/external_static_member_lowerings_test.dart b/tests/lib/js/static_interop_test/external_static_member_lowerings_test.dart
index c4e7070..40197b3 100644
--- a/tests/lib/js/static_interop_test/external_static_member_lowerings_test.dart
+++ b/tests/lib/js/static_interop_test/external_static_member_lowerings_test.dart
@@ -2,12 +2,8 @@
// 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.
-@JS()
-library external_static_member_lowerings_test;
-
import 'dart:js_interop';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
import 'external_static_member_lowerings_with_namespaces.dart' as namespace;
@@ -18,8 +14,9 @@
@staticInterop
class ExternalStatic {
external factory ExternalStatic(String initialValue);
- external factory ExternalStatic.named(
- [String initialValue = 'uninitialized']);
+ external factory ExternalStatic.named([
+ String initialValue = 'uninitialized',
+ ]);
// External redirecting factories are not allowed.
external static String field;
@@ -69,48 +66,48 @@
void testClassStaticMembers() {
// Fields.
- expect(ExternalStatic.field, 'field');
+ Expect.equals('field', ExternalStatic.field);
ExternalStatic.field = 'modified';
- expect(ExternalStatic.field, 'modified');
- expect(ExternalStatic.renamedField, 'modified');
+ Expect.equals('modified', ExternalStatic.field);
+ Expect.equals('modified', ExternalStatic.renamedField);
ExternalStatic.renamedField = 'renamedField';
- expect(ExternalStatic.renamedField, 'renamedField');
- expect(ExternalStatic.finalField, 'finalField');
+ Expect.equals('renamedField', ExternalStatic.renamedField);
+ Expect.equals('finalField', ExternalStatic.finalField);
// Getters and setters.
- expect(ExternalStatic.getSet, 'getSet');
+ Expect.equals('getSet', ExternalStatic.getSet);
ExternalStatic.getSet = 'modified';
- expect(ExternalStatic.getSet, 'modified');
- expect(ExternalStatic.renamedGetSet, 'modified');
+ Expect.equals('modified', ExternalStatic.getSet);
+ Expect.equals('modified', ExternalStatic.renamedGetSet);
ExternalStatic.renamedGetSet = 'renamedGetSet';
- expect(ExternalStatic.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', ExternalStatic.renamedGetSet);
// Methods.
- expect(ExternalStatic.method(), 'method');
- expect(ExternalStatic.renamedMethod(), 'method');
+ Expect.equals('method', ExternalStatic.method());
+ Expect.equals('method', ExternalStatic.renamedMethod());
}
void testTopLevelMembers() {
// Fields.
- expect(field, 'field');
+ Expect.equals('field', field);
field = 'modified';
- expect(field, 'modified');
- expect(renamedField, 'modified');
+ Expect.equals('modified', field);
+ Expect.equals('modified', renamedField);
renamedField = 'renamedField';
- expect(renamedField, 'renamedField');
- expect(finalField, 'finalField');
+ Expect.equals('renamedField', renamedField);
+ Expect.equals('finalField', finalField);
// Getters and setters.
- expect(getSet, 'getSet');
+ Expect.equals('getSet', getSet);
getSet = 'modified';
- expect(getSet, 'modified');
- expect(renamedGetSet, 'modified');
+ Expect.equals('modified', getSet);
+ Expect.equals('modified', renamedGetSet);
renamedGetSet = 'renamedGetSet';
- expect(renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', renamedGetSet);
// Methods.
- expect(method(), 'method');
- expect(renamedMethod(), 'method');
+ Expect.equals('method', method());
+ Expect.equals('method', renamedMethod());
}
void testFactories() {
@@ -118,55 +115,55 @@
var initialized = 'initialized';
var externalStatic = ExternalStatic(initialized);
- expect(externalStatic.initialValue, initialized);
+ Expect.equals(initialized, externalStatic.initialValue);
externalStatic = ExternalStatic.named();
- expect(externalStatic.initialValue, null);
+ Expect.isNull(externalStatic.initialValue);
}
void testNamespacedClassStaticMembers() {
// Fields.
- expect(namespace.ExternalStatic.field, 'field');
+ Expect.equals('field', namespace.ExternalStatic.field);
namespace.ExternalStatic.field = 'modified';
- expect(namespace.ExternalStatic.field, 'modified');
- expect(namespace.ExternalStatic.renamedField, 'modified');
+ Expect.equals('modified', namespace.ExternalStatic.field);
+ Expect.equals('modified', namespace.ExternalStatic.renamedField);
namespace.ExternalStatic.renamedField = 'renamedField';
- expect(namespace.ExternalStatic.renamedField, 'renamedField');
- expect(namespace.ExternalStatic.finalField, 'finalField');
+ Expect.equals('renamedField', namespace.ExternalStatic.renamedField);
+ Expect.equals('finalField', namespace.ExternalStatic.finalField);
// Getters and setters.
- expect(namespace.ExternalStatic.getSet, 'getSet');
+ Expect.equals('getSet', namespace.ExternalStatic.getSet);
namespace.ExternalStatic.getSet = 'modified';
- expect(namespace.ExternalStatic.getSet, 'modified');
- expect(namespace.ExternalStatic.renamedGetSet, 'modified');
+ Expect.equals('modified', namespace.ExternalStatic.getSet);
+ Expect.equals('modified', namespace.ExternalStatic.renamedGetSet);
namespace.ExternalStatic.renamedGetSet = 'renamedGetSet';
- expect(namespace.ExternalStatic.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', namespace.ExternalStatic.renamedGetSet);
// Methods.
- expect(namespace.ExternalStatic.method(), 'method');
- expect(namespace.ExternalStatic.renamedMethod(), 'method');
+ Expect.equals('method', namespace.ExternalStatic.method());
+ Expect.equals('method', namespace.ExternalStatic.renamedMethod());
}
void testNamespacedTopLevelMembers() {
// Fields.
- expect(namespace.field, 'field');
+ Expect.equals('field', namespace.field);
namespace.field = 'modified';
- expect(namespace.field, 'modified');
- expect(namespace.renamedField, 'modified');
+ Expect.equals('modified', namespace.field);
+ Expect.equals('modified', namespace.renamedField);
namespace.renamedField = 'renamedField';
- expect(namespace.renamedField, 'renamedField');
- expect(namespace.finalField, 'finalField');
+ Expect.equals('renamedField', namespace.renamedField);
+ Expect.equals('finalField', namespace.finalField);
// Getters and setters.
- expect(namespace.getSet, 'getSet');
+ Expect.equals('getSet', namespace.getSet);
namespace.getSet = 'modified';
- expect(namespace.getSet, 'modified');
- expect(namespace.renamedGetSet, 'modified');
+ Expect.equals('modified', namespace.getSet);
+ Expect.equals('modified', namespace.renamedGetSet);
namespace.renamedGetSet = 'renamedGetSet';
- expect(namespace.renamedGetSet, 'renamedGetSet');
+ Expect.equals('renamedGetSet', namespace.renamedGetSet);
// Methods.
- expect(namespace.method(), 'method');
- expect(namespace.renamedMethod(), 'method');
+ Expect.equals('method', namespace.method());
+ Expect.equals('method', namespace.renamedMethod());
}
void testNamespacedFactories() {
@@ -174,9 +171,9 @@
var initialized = 'initialized';
var externalStatic = namespace.ExternalStatic(initialized);
- expect(externalStatic.initialValue, initialized);
+ Expect.equals(initialized, externalStatic.initialValue);
externalStatic = namespace.ExternalStatic.named();
- expect(externalStatic.initialValue, null);
+ Expect.isNull(externalStatic.initialValue);
}
void main() {
diff --git a/tests/lib/js/static_interop_test/external_static_member_lowerings_trusttypes_test.dart b/tests/lib/js/static_interop_test/external_static_member_lowerings_trusttypes_test.dart
index f85247e..4d665bf 100644
--- a/tests/lib/js/static_interop_test/external_static_member_lowerings_trusttypes_test.dart
+++ b/tests/lib/js/static_interop_test/external_static_member_lowerings_trusttypes_test.dart
@@ -2,12 +2,8 @@
// 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.
-@JS()
-library external_static_member_lowerings_trusttypes_test;
-
import 'dart:js_interop';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
import 'package:js/js.dart' show trustTypes;
@JS()
@@ -42,9 +38,9 @@
''');
// Use wrong return type in conjunction with `@trustTypes`.
- expect(confuse(ExternalStaticTrustType.field), 'field');
+ Expect.equals('field', confuse(ExternalStaticTrustType.field));
- expect(confuse(ExternalStaticTrustType.getSet), 'getSet');
+ Expect.equals('getSet', confuse(ExternalStaticTrustType.getSet));
- expect(confuse(ExternalStaticTrustType.method()), 'method');
+ Expect.equals('method', confuse(ExternalStaticTrustType.method()));
}
diff --git a/tests/lib/js/static_interop_test/futurevaluetype_test.dart b/tests/lib/js/static_interop_test/futurevaluetype_test.dart
index 84f7b75..7741e65 100644
--- a/tests/lib/js/static_interop_test/futurevaluetype_test.dart
+++ b/tests/lib/js/static_interop_test/futurevaluetype_test.dart
@@ -5,9 +5,6 @@
// Test that `FunctionNode`'s `futureValueType`s are correctly transformed.
// See https://github.com/dart-lang/sdk/issues/48835 for more details.
-@JS()
-library futurevaluetype_test;
-
import 'dart:html';
import 'package:expect/async_helper.dart';
diff --git a/tests/lib/js/static_interop_test/generic_factory_test.dart b/tests/lib/js/static_interop_test/generic_factory_test.dart
index 2564e91..0d35f93 100644
--- a/tests/lib/js/static_interop_test/generic_factory_test.dart
+++ b/tests/lib/js/static_interop_test/generic_factory_test.dart
@@ -5,7 +5,7 @@
// Test type parameters on @staticInterop factories.
import 'package:js/js.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
@JS()
@staticInterop
@@ -33,15 +33,15 @@
void main() {
final arr1 = Array(true, '');
- expect(arr1[0], true);
- expect(arr1[1], '');
+ Expect.isTrue(arr1[0]);
+ Expect.equals('', arr1[1]);
final arr2 = Array<bool, String>(false, '');
- expect(arr2[0], false);
- expect(arr2[1], '');
+ Expect.isFalse(arr2[0]);
+ Expect.equals('', arr2[1]);
final anon1 = Anonymous(t: true, u: '');
- expect(anon1.t, true);
- expect(anon1.u, '');
+ Expect.isTrue(anon1.t);
+ Expect.equals('', anon1.u);
final anon2 = Anonymous<bool, String>(t: false, u: '');
- expect(anon2.t, false);
- expect(anon2.u, '');
+ Expect.isFalse(anon2.t);
+ Expect.equals('', anon2.u);
}
diff --git a/tests/lib/js/static_interop_test/js_and_staticinterop_annotation_static_test.dart b/tests/lib/js/static_interop_test/js_and_staticinterop_annotation_static_test.dart
index 0d8ef99..1874cf6 100644
--- a/tests/lib/js/static_interop_test/js_and_staticinterop_annotation_static_test.dart
+++ b/tests/lib/js/static_interop_test/js_and_staticinterop_annotation_static_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library js_and_staticinterop_annotation_static_test;
-
import 'package:js/js.dart';
@staticInterop
diff --git a/tests/lib/js/static_interop_test/js_array_proxy_or_ref_test.dart b/tests/lib/js/static_interop_test/js_array_proxy_or_ref_test.dart
index 2cf6d33..ef4632e 100644
--- a/tests/lib/js/static_interop_test/js_array_proxy_or_ref_test.dart
+++ b/tests/lib/js/static_interop_test/js_array_proxy_or_ref_test.dart
@@ -5,7 +5,7 @@
// Test the JS array proxy or reference that's created for lists for interop.
import 'dart:js_interop';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
@JS()
external void eval(String code);
@@ -23,8 +23,12 @@
extension JSArrayExtension<T extends JSAny?> on JSArray<T> {
external int at(int i);
- external JSArray<T> concat(
- [JSArray<T> arg1, JSArray<T> arg2, JSArray<T> arg3, JSArray<T> arg4]);
+ external JSArray<T> concat([
+ JSArray<T> arg1,
+ JSArray<T> arg2,
+ JSArray<T> arg3,
+ JSArray<T> arg4,
+ ]);
external void forEach(JSFunction callback, [JSObject thisObj]);
external int indexOf(JSAny? element, [int? fromIndex]);
external bool includes(JSAny? element, [int? fromIndex]);
@@ -32,56 +36,62 @@
external int pop();
external int push([T arg1, T arg2, T arg3]);
external JSArray<T> slice([int? start, int? end]);
- external JSArray<T> splice(
- [int? start, int? deleteCount, T arg1, T arg2, T arg3, T arg4]);
+ external JSArray<T> splice([
+ int? start,
+ int? deleteCount,
+ T arg1,
+ T arg2,
+ T arg3,
+ T arg4,
+ ]);
}
void main() {
final numList = <int?>[4, 3, 2, 1, 0].map((e) => e?.toJS).toList();
final numProxy = numList.toJSProxyOrRef;
final roundTripProxy = numProxy.toDart.toJSProxyOrRef;
- expect(numProxy, roundTripProxy);
+ Expect.equals(roundTripProxy, numProxy);
// `length`/`[]`/`at`/`[]=`
numProxy.length = 6;
- expect(numList.length, 6);
- expect(numProxy.length, numList.length);
+ Expect.equals(6, numList.length);
+ Expect.equals(numList.length, numProxy.length);
numList.length = 5;
- expect(numProxy.length, numList.length);
+ Expect.equals(numList.length, numProxy.length);
for (var i = 0; i < numProxy.length; i++) {
- expect(numProxy[i]!.toDartInt, numProxy.length - i - 1);
- expect(numProxy.at(i), numProxy.length - i - 1);
+ Expect.equals(numProxy[i]!.toDartInt, numProxy.length - i - 1);
+ Expect.equals(numProxy.at(i), numProxy.length - i - 1);
numProxy[i] = i.toJS;
- expect(numProxy[i]!.toDartInt, i);
- expect(numProxy.at(i), i);
+ Expect.equals(i, numProxy[i]!.toDartInt);
+ Expect.equals(i, numProxy.at(i));
// Test negative indexing.
- expect(numProxy.at(i - numProxy.length), i);
- expect(numList[i]!.toDartInt, i);
+ Expect.equals(i, numProxy.at(i - numProxy.length));
+ Expect.equals(i, numList[i]!.toDartInt);
}
// `includes`/`indexOf`
- expect(numProxy.includes(0.toJS), true);
- expect(numProxy.includes(0.toJS, 1), false);
- expect(numProxy.includes(5.toJS), false);
- expect(numProxy.indexOf(0.toJS), 0);
- expect(numProxy.indexOf(0.toJS, 1), -1);
- expect(numProxy.indexOf(5.toJS), -1);
+ Expect.isTrue(numProxy.includes(0.toJS));
+ Expect.isFalse(numProxy.includes(0.toJS, 1));
+ Expect.isFalse(numProxy.includes(5.toJS));
+ Expect.equals(0, numProxy.indexOf(0.toJS));
+ Expect.equals(-1, numProxy.indexOf(0.toJS, 1));
+ Expect.equals(-1, numProxy.indexOf(5.toJS));
// `pop`/`push`
- expect(numProxy.push(5.toJS), numList.length);
- expect(numProxy.length, numList.length);
- expect(numList.length, 6);
- expect(numList[5]!.toDartInt, 5);
+ Expect.equals(numList.length + 1, numProxy.push(5.toJS));
+ Expect.equals(numList.length, numProxy.length);
+ Expect.equals(6, numList.length);
+ Expect.equals(5, numList[5]!.toDartInt);
- expect(numProxy.pop(), 5);
- expect(numProxy.length, numList.length);
- expect(numList.length, 5);
+ Expect.equals(5, numProxy.pop());
+ Expect.equals(numList.length, numProxy.length);
+ Expect.equals(5, numList.length);
- expect(numProxy.push(5.toJS, 6.toJS, 7.toJS), 8);
- expect(numProxy.push(8.toJS, null, null), 11);
- expect(numList.length, 11);
+ Expect.equals(8, numProxy.push(5.toJS, 6.toJS, 7.toJS));
+ Expect.equals(11, numProxy.push(8.toJS, null, null));
+ Expect.equals(11, numList.length);
numList.length = 9; // Remove the `null`s we just added.
// iteration/for loop
@@ -95,17 +105,19 @@
return counter;
};
''');
- expect(iterateAndValidateArray(numProxy), numList.length);
+ Expect.equals(numList.length, iterateAndValidateArray(numProxy));
// `forEach`
var numElements = 0;
- numProxy.forEach((int element, int index, JSArray array) {
- expect(numElements, element);
- expect(numElements, index);
- expect(numProxy, array);
- numElements++;
- }.toJS);
- expect(numElements, numList.length);
+ numProxy.forEach(
+ (int element, int index, JSArray array) {
+ Expect.equals(element, numElements);
+ Expect.equals(index, numElements);
+ Expect.equals(array, numProxy);
+ numElements++;
+ }.toJS,
+ );
+ Expect.equals(numList.length, numElements);
// `forEach` with a bound this.
eval('''
@@ -118,22 +130,22 @@
globalThis.counter = counter;
''');
numProxy.forEach(counter.forEachBound, counter);
- expect(counter.numElements, numList.length);
+ Expect.equals(numList.length, counter.numElements);
// `slice`, `splice`, and `concat`
void testEquals(JSArray<JSNumber?> arr, List<int> list) {
final len = list.length;
for (var i = 0; i < len; i++) {
- expect(arr[i]!.toDartInt, list[i]);
+ Expect.equals(arr[i]!.toDartInt, list[i]);
}
}
final sliced = numProxy.slice(4, 9);
testEquals(sliced, [4, 5, 6, 7, 8]);
- expect(numList.length, 9);
+ Expect.equals(9, numList.length);
final deleted = numProxy.splice(4, 5);
testEquals(deleted, [4, 5, 6, 7, 8]);
- expect(numList.length, 4);
+ Expect.equals(4, numList.length);
final deleted2 = numProxy.splice(0, 4, 3.toJS, 2.toJS, 1.toJS, 0.toJS);
testEquals(deleted2, [0, 1, 2, 3]);
@@ -141,8 +153,8 @@
testEquals(numProxy.concat(deleted2), [3, 2, 1, 0, 0, 1, 2, 3]);
// `join`
- expect(numProxy.join('-'), '3-2-1-0');
- expect(numProxy.join(), '3,2,1,0');
+ Expect.equals('3-2-1-0', numProxy.join('-'));
+ Expect.equals('3,2,1,0', numProxy.join());
// TODO(srujzs): Test the remaining JS Array methods. While we cover the
// common ones and the ones needed for JSArrayImpl, we might be missing some
diff --git a/tests/lib/js/static_interop_test/js_array_test.dart b/tests/lib/js/static_interop_test/js_array_test.dart
index f0eb8d9..88b45f1 100644
--- a/tests/lib/js/static_interop_test/js_array_test.dart
+++ b/tests/lib/js/static_interop_test/js_array_test.dart
@@ -4,9 +4,6 @@
// Test that JS' Array type is interoperable using static interop.
-@JS()
-library js_array_test;
-
import 'dart:js_interop';
@JS()
diff --git a/tests/lib/js/static_interop_test/js_default_test.dart b/tests/lib/js/static_interop_test/js_default_test.dart
index b56138f..0880e66 100644
--- a/tests/lib/js/static_interop_test/js_default_test.dart
+++ b/tests/lib/js/static_interop_test/js_default_test.dart
@@ -9,8 +9,7 @@
library js_default_test;
import 'dart:js_interop';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
import 'js_default_with_namespaces.dart' as namespace;
@@ -56,110 +55,160 @@
void testCurrentLibrary() {
// Test top level methods.
- expect(0, twoOptional().toDartInt);
- expect(1, twoOptional(4.0.toJS).toDartInt);
- expect(2, twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(0, twoOptional().toDartInt);
+ Expect.equals(1, twoOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
- expect(1, oneOptional(4.0.toJS).toDartInt);
- expect(2, oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
// Test factories.
- expect(0, SimpleObject.twoOptional().initialArguments.toDartInt);
- expect(1, SimpleObject.twoOptional(4.0.toJS).initialArguments.toDartInt);
- expect(2,
- SimpleObject.twoOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt);
+ Expect.equals(0, SimpleObject.twoOptional().initialArguments.toDartInt);
+ Expect.equals(
+ 1,
+ SimpleObject.twoOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ SimpleObject.twoOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt,
+ );
- expect(1, SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt);
- expect(2,
- SimpleObject.oneOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt);
+ Expect.equals(
+ 1,
+ SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ SimpleObject.oneOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt,
+ );
// Test static methods.
- expect(0, SimpleObject.twoOptionalStatic().toDartInt);
- expect(1, SimpleObject.twoOptionalStatic(4.0.toJS).toDartInt);
- expect(2, SimpleObject.twoOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(0, SimpleObject.twoOptionalStatic().toDartInt);
+ Expect.equals(1, SimpleObject.twoOptionalStatic(4.0.toJS).toDartInt);
+ Expect.equals(
+ 2,
+ SimpleObject.twoOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
- expect(1, SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt);
- expect(2, SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt);
+ Expect.equals(
+ 2,
+ SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
// Test extension methods.
final s = SimpleObject();
- expect(0, s.twoOptional().toDartInt);
- expect(1, s.twoOptional(4.0.toJS).toDartInt);
- expect(2, s.twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(0, s.twoOptional().toDartInt);
+ Expect.equals(1, s.twoOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s.twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
- expect(1, s.oneOptional(4.0.toJS).toDartInt);
- expect(2, s.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, s.oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
// Test extension type factories.
- expect(0, SimpleObject2.twoOptional().initialArguments.toDartInt);
- expect(1, SimpleObject2.twoOptional(4.0.toJS).initialArguments.toDartInt);
- expect(2,
- SimpleObject2.twoOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt);
+ Expect.equals(0, SimpleObject2.twoOptional().initialArguments.toDartInt);
+ Expect.equals(
+ 1,
+ SimpleObject2.twoOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ SimpleObject2.twoOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt,
+ );
- expect(1, SimpleObject2.oneOptional(4.0.toJS).initialArguments.toDartInt);
- expect(2,
- SimpleObject2.oneOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt);
+ Expect.equals(
+ 1,
+ SimpleObject2.oneOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ SimpleObject2.oneOptional(4.0.toJS, 5.0.toJS).initialArguments.toDartInt,
+ );
// Test extension type static methods.
- expect(0, SimpleObject2.twoOptionalStatic().toDartInt);
- expect(1, SimpleObject2.twoOptionalStatic(4.0.toJS).toDartInt);
- expect(2, SimpleObject2.twoOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(0, SimpleObject2.twoOptionalStatic().toDartInt);
+ Expect.equals(1, SimpleObject2.twoOptionalStatic(4.0.toJS).toDartInt);
+ Expect.equals(
+ 2,
+ SimpleObject2.twoOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
- expect(1, SimpleObject2.oneOptionalStatic(4.0.toJS).toDartInt);
- expect(2, SimpleObject2.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, SimpleObject2.oneOptionalStatic(4.0.toJS).toDartInt);
+ Expect.equals(
+ 2,
+ SimpleObject2.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
// Test extension type methods.
final s2 = SimpleObject2();
- expect(0, s2.twoOptional().toDartInt);
- expect(1, s2.twoOptional(4.0.toJS).toDartInt);
- expect(2, s2.twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(0, s2.twoOptional().toDartInt);
+ Expect.equals(1, s2.twoOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s2.twoOptional(4.0.toJS, 5.0.toJS).toDartInt);
- expect(1, s2.oneOptional(4.0.toJS).toDartInt);
- expect(2, s2.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, s2.oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s2.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
}
void testOtherLibrary() {
// Test top level methods.
- expect(1, namespace.oneOptional(4.0.toJS).toDartInt);
- expect(2, namespace.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, namespace.oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, namespace.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
// Test factories.
- expect(1,
- namespace.SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt);
- expect(
- 2,
- namespace.SimpleObject.oneOptional(4.0.toJS, 5.0.toJS)
- .initialArguments
- .toDartInt);
+ Expect.equals(
+ 1,
+ namespace.SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ namespace.SimpleObject.oneOptional(
+ 4.0.toJS,
+ 5.0.toJS,
+ ).initialArguments.toDartInt,
+ );
// Test static methods.
- expect(1, namespace.SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt);
- expect(2,
- namespace.SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(
+ 1,
+ namespace.SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt,
+ );
+ Expect.equals(
+ 2,
+ namespace.SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
// Test extension methods.
final s = namespace.SimpleObject();
- expect(1, s.oneOptional(4.0.toJS).toDartInt);
- expect(2, s.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, s.oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
// Test extension type factories.
- expect(1,
- namespace.SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt);
- expect(
- 2,
- namespace.SimpleObject.oneOptional(4.0.toJS, 5.0.toJS)
- .initialArguments
- .toDartInt);
+ Expect.equals(
+ 1,
+ namespace.SimpleObject.oneOptional(4.0.toJS).initialArguments.toDartInt,
+ );
+ Expect.equals(
+ 2,
+ namespace.SimpleObject.oneOptional(
+ 4.0.toJS,
+ 5.0.toJS,
+ ).initialArguments.toDartInt,
+ );
// Test extension type static methods.
- expect(1, namespace.SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt);
- expect(2,
- namespace.SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(
+ 1,
+ namespace.SimpleObject.oneOptionalStatic(4.0.toJS).toDartInt,
+ );
+ Expect.equals(
+ 2,
+ namespace.SimpleObject.oneOptionalStatic(4.0.toJS, 5.0.toJS).toDartInt,
+ );
// Test extension type methods.
final s2 = namespace.SimpleObject();
- expect(1, s2.oneOptional(4.0.toJS).toDartInt);
- expect(2, s2.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
+ Expect.equals(1, s2.oneOptional(4.0.toJS).toDartInt);
+ Expect.equals(2, s2.oneOptional(4.0.toJS, 5.0.toJS).toDartInt);
}
void main() {
diff --git a/tests/lib/js/static_interop_test/js_function_conversions_test.dart b/tests/lib/js/static_interop_test/js_function_conversions_test.dart
index 566e210..4e58eba 100644
--- a/tests/lib/js/static_interop_test/js_function_conversions_test.dart
+++ b/tests/lib/js/static_interop_test/js_function_conversions_test.dart
@@ -9,7 +9,6 @@
import 'dart:js_interop';
import 'package:expect/expect.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
import 'package:expect/variations.dart';
const isJSBackend = 0 is JSNumber;
@@ -39,7 +38,8 @@
@JS('jsFunction')
external ExternalDartReference? externalDartReferenceF(
- ExternalDartReference? e);
+ ExternalDartReference? e,
+);
@JS()
external JSAny? callFunctionWithUndefined();
@@ -54,29 +54,29 @@
void main() {
// Test primitive conversions.
jsFunction = ((String arg) => arg).toJS;
- expect(stringF('stringF'.toJS).toDart, 'stringF');
+ Expect.equals('stringF', stringF('stringF'.toJS).toDart);
Expect.throws(() => anyF(0.toJS));
jsFunction = ((int arg) => arg).toJS;
- expect(numF(0.toJS).toDartInt, 0);
- expect(numF(0.0.toJS).toDartInt, 0);
+ Expect.equals(0, numF(0.toJS).toDartInt);
+ Expect.equals(0, numF(0.0.toJS).toDartInt);
Expect.throws(() => numF(0.1.toJS));
Expect.throws(() => anyF(true.toJS));
jsFunction = ((double arg) => arg).toJS;
- expect(numF(0.toJS).toDartDouble, 0.0);
- expect(numF(0.0.toJS).toDartDouble, 0.0);
- expect(numF(0.1.toJS).toDartDouble, 0.1);
+ Expect.equals(0.0, numF(0.toJS).toDartDouble);
+ Expect.equals(0.0, numF(0.0.toJS).toDartDouble);
+ Expect.equals(0.1, numF(0.1.toJS).toDartDouble);
Expect.throws(() => anyF(true.toJS));
jsFunction = ((num arg) => arg).toJS;
- expect(numF(0.toJS).toDartInt, 0);
- expect(numF(0.0.toJS).toDartInt, 0);
- expect(numF(0.1.toJS).toDartDouble, 0.1);
+ Expect.equals(0, numF(0.toJS).toDartInt);
+ Expect.equals(0, numF(0.0.toJS).toDartInt);
+ Expect.equals(0.1, numF(0.1.toJS).toDartDouble);
Expect.throws(() => anyF(true.toJS));
jsFunction = ((bool arg) => arg).toJS;
- expect(boolF(true.toJS).toDart, true);
+ Expect.isTrue(boolF(true.toJS).toDart);
Expect.throws(() => anyF(''.toJS));
jsFunction = ((String arg) {}).toJS;
@@ -86,31 +86,39 @@
// Extension type on primitives.
jsFunction = ((IntE i) => i).toJS;
- expect(numF(0.toJS).toDartInt, 0);
+ Expect.equals(0, numF(0.toJS).toDartInt);
Expect.throwsWhen(soundNullSafety, () => anyF(null));
jsFunction = ((IntE? i) => i).toJS;
- expect(numF(0.toJS).toDartInt, 0);
- expect(anyF(null), null);
+ Expect.equals(0, numF(0.toJS).toDartInt);
+ Expect.isNull(anyF(null));
jsFunction = ((NullableIntE i) => i).toJS;
- expect(numF(0.toJS).toDartInt, 0);
- expect(anyF(null), null);
+ Expect.equals(0, numF(0.toJS).toDartInt);
+ Expect.isNull(anyF(null));
// Test ExternalDartReference.
Set set = {};
jsFunction = ((ExternalDartReference<Set> arg) => arg).toJS;
- expect(externalDartReferenceF(set.toExternalReference)!.toDartObject, set);
+ Expect.equals(
+ set,
+ externalDartReferenceF(set.toExternalReference)!.toDartObject,
+ );
// However, if we try to internalize it to the wrong value, that should fail.
// In the JS backends, it fails in the cast. In dart2wasm, it fails in the
// internalization.
Expect.throwsWhen(
- isJSBackend && soundNullSafety, () => externalDartReferenceF(null));
+ isJSBackend && soundNullSafety,
+ () => externalDartReferenceF(null),
+ );
Expect.throwsWhen(
- isJSBackend, () => externalDartReferenceF([].toExternalReference));
+ isJSBackend,
+ () => externalDartReferenceF([].toExternalReference),
+ );
Expect.throwsWhen(isJSBackend, () => anyF(''.toJS));
- jsFunction = ((ExternalDartReference<Set> arg) {
- arg.toDartObject;
- }).toJS;
+ jsFunction =
+ ((ExternalDartReference<Set> arg) {
+ arg.toDartObject;
+ }).toJS;
Expect.throwsWhen(soundNullSafety, () => externalDartReferenceF(null));
Expect.throws(() => externalDartReferenceF([].toExternalReference));
// TODO(srujzs): On dart2wasm, this is a `RuntimeError: illegal cast` because
@@ -131,9 +139,9 @@
void expectNullPass(JSFunction f) {
jsFunction = f;
- expect(anyF(null), null);
- expect(callFunctionWithUndefined(), null);
- expect(callFunctionWithJSNull(), null);
+ Expect.isNull(anyF(null));
+ Expect.isNull(callFunctionWithUndefined());
+ Expect.isNull(callFunctionWithJSNull());
}
void expectNullFail(JSFunction f) {
@@ -145,15 +153,19 @@
}
}
- expectNullPass(((String? arg) {
- expect(arg, null);
- return arg;
- }).toJS);
+ expectNullPass(
+ ((String? arg) {
+ Expect.isNull(arg);
+ return arg;
+ }).toJS,
+ );
- expectNullPass(((JSString? arg) {
- expect(arg, null);
- return arg;
- }).toJS);
+ expectNullPass(
+ ((JSString? arg) {
+ Expect.isNull(arg);
+ return arg;
+ }).toJS,
+ );
expectNullFail(((String arg) => arg).toJS);
@@ -168,11 +180,11 @@
final empty = ''.toJS;
setBoundAnyFunction();
- expect(anyF(null), null);
- expect(anyF(zero), zero);
+ Expect.isNull(anyF(null));
+ Expect.equals(zero, anyF(zero));
setBoundAnyFunction<JSAny>();
Expect.throwsWhen(soundNullSafety, () => anyF(null));
- expect(anyF(zero), zero);
+ Expect.equals(zero, anyF(zero));
setBoundAnyFunction<JSNumber>();
Expect.throwsWhen(soundNullSafety, () => anyF(null));
Expect.throws(() {
@@ -181,7 +193,7 @@
// convert, but currently that does not throw on dart2wasm.
if (!any.isA<JSNumber>()) throw TypeError();
});
- expect(anyF(zero), zero);
+ Expect.equals(zero, anyF(zero));
void setBoundNonNullAnyFunction<T extends JSAny>() {
jsFunction = ((T t) => t).toJS;
@@ -189,7 +201,7 @@
setBoundNonNullAnyFunction();
Expect.throwsWhen(soundNullSafety, () => anyF(null));
- expect(anyF(zero), zero);
+ Expect.equals(zero, anyF(zero));
setBoundNonNullAnyFunction<JSNumber>();
Expect.throwsWhen(soundNullSafety, () => anyF(null));
Expect.throws(() {
@@ -198,7 +210,7 @@
// convert, but currently that does not throw on dart2wasm.
if (!any.isA<JSNumber>()) throw TypeError();
});
- expect(anyF(zero), zero);
+ Expect.equals(zero, anyF(zero));
void setBoundJSNumberFunction<T extends JSNumber>() {
jsFunction = ((T t) => t).toJS;
@@ -212,10 +224,13 @@
// convert, but currently that does not throw on dart2wasm.
if (!any.isA<JSNumber>()) throw TypeError();
});
- expect(anyF(zero), zero);
+ Expect.equals(zero, anyF(zero));
- void setBoundNonNullAnyMultipleParametersFunction<T extends JSAny,
- U extends JSAny, V extends JSAny>({bool captureThis = false}) {
+ void setBoundNonNullAnyMultipleParametersFunction<
+ T extends JSAny,
+ U extends JSAny,
+ V extends JSAny
+ >({bool captureThis = false}) {
if (captureThis) {
jsFunction = ((T this_, U u, [V? v]) => this_).toJSCaptureThis;
} else {
@@ -245,20 +260,22 @@
}
setBoundExternalDartReference<ExternalDartReference<Object?>, Object?>();
- expect(externalDartReferenceF(null), null);
- expect(externalDartReferenceF(0.toExternalReference)!.toDartObject, 0);
+ Expect.isNull(externalDartReferenceF(null));
+ Expect.equals(0, externalDartReferenceF(0.toExternalReference)!.toDartObject);
setBoundExternalDartReference<ExternalDartReference<Object>?, Object>();
- expect(externalDartReferenceF(null), null);
- expect(externalDartReferenceF(0.toExternalReference)!.toDartObject, 0);
+ Expect.isNull(externalDartReferenceF(null));
+ Expect.equals(0, externalDartReferenceF(0.toExternalReference)!.toDartObject);
- void setBoundNonNullExternalDartReference<T extends ExternalDartReference<U>,
- U>() {
+ void setBoundNonNullExternalDartReference<
+ T extends ExternalDartReference<U>,
+ U
+ >() {
jsFunction = ((T t) => t.toDartObject.toExternalReference).toJS;
}
setBoundNonNullExternalDartReference<ExternalDartReference<Object>, Object>();
Expect.throwsWhen(soundNullSafety, () => externalDartReferenceF(null));
- expect(externalDartReferenceF(0.toExternalReference)!.toDartObject, 0);
+ Expect.equals(0, externalDartReferenceF(0.toExternalReference)!.toDartObject);
// Test that type parameters local to the expression can still be casted to.
T Function(T) getF<T extends JSAny?>() {
@@ -274,12 +291,12 @@
// Make sure function expression is only evaluated once in lowerings.
var evalCount = 0;
- jsFunction = (() {
- evalCount++;
- return () {};
- }())
- .toJS;
+ jsFunction =
+ (() {
+ evalCount++;
+ return () {};
+ }()).toJS;
anyF();
anyF();
- expect(evalCount, 1);
+ Expect.equals(1, evalCount);
}
diff --git a/tests/lib/js/static_interop_test/js_string_test.dart b/tests/lib/js/static_interop_test/js_string_test.dart
index 38424f3..44acc5d0 100644
--- a/tests/lib/js/static_interop_test/js_string_test.dart
+++ b/tests/lib/js/static_interop_test/js_string_test.dart
@@ -21,10 +21,7 @@
jsStringImplReceiverAndArguments,
}
-enum Position {
- jsStringImplReceiver,
- jsStringImplArgument,
-}
+enum Position { jsStringImplReceiver, jsStringImplArgument }
bool useJSStringImpl(Position pos, TestMode mode) =>
(pos == Position.jsStringImplReceiver &&
@@ -155,7 +152,7 @@
Expect.throws(() => rstr.startsWith(aEmptyStr, -1));
Expect.throws(() => rstr.startsWith(aEmptyStr, 4));
- final regexp = new RegExp('s(?:tr?)?');
+ final regexp = RegExp('s(?:tr?)?');
Expect.isTrue(rstr.startsWith(regexp));
Expect.isFalse(rstrstr.startsWith(regexp, 1));
Expect.isFalse(rstrstr.startsWith(regexp, 2));
@@ -307,7 +304,9 @@
Expect.equals('AtoBtoCDtoE', r('AfromBfromCDfromE').replaceAll(aFrom, aTo));
Expect.equals('toABtoCDtoE', r('fromABfromCDfromE').replaceAll(aFrom, aTo));
Expect.equals(
- 'toABtoCDtoEto', r('fromABfromCDfromEfrom').replaceAll(aFrom, aTo));
+ 'toABtoCDtoEto',
+ r('fromABfromCDfromEfrom').replaceAll(aFrom, aTo),
+ );
Expect.equals('ABC', r('ABC').replaceAll(aFrom, aTo));
Expect.equals('', r('').replaceAll(aFrom, aTo));
Expect.equals('fro', r('fro').replaceAll(aFrom, aTo));
@@ -319,7 +318,9 @@
Expect.equals('toAtoBtoCto', r('ABC').replaceAll(aEmptyStr, aTo));
Expect.equals('aXXcaXXdae', r('abcabdae').replaceAll(RegExp('b'), a('XX')));
Expect.equals(
- 'aXXcaXXdae', r('abcabdae').replaceAll(RegExpWrap('b'), a('XX')));
+ 'aXXcaXXdae',
+ r('abcabdae').replaceAll(RegExpWrap('b'), a('XX')),
+ );
}
void testReplaceAllMapped(TestMode mode) {
@@ -332,10 +333,14 @@
Expect.equals('bcbde', r('abcabdae').replaceAllMapped(a('a'), (m) => a('')));
Expect.equals('[]', r('').replaceAllMapped(a(''), mark));
Expect.equals('[]A[]B[]C[]', r('ABC').replaceAllMapped(a(''), mark));
- Expect.equals('aXXcaXXdae',
- r('abcabdae').replaceAllMapped(RegExp('b'), (_) => a('XX')));
- Expect.equals('aXXcaXXdae',
- r('abcabdae').replaceAllMapped(RegExpWrap('b'), (_) => a('XX')));
+ Expect.equals(
+ 'aXXcaXXdae',
+ r('abcabdae').replaceAllMapped(RegExp('b'), (_) => a('XX')),
+ );
+ Expect.equals(
+ 'aXXcaXXdae',
+ r('abcabdae').replaceAllMapped(RegExpWrap('b'), (_) => a('XX')),
+ );
}
void testCompareTo(TestMode mode) {
@@ -365,24 +370,20 @@
}
void testRepeat() {
- List<String> testStrings = [
- '',
- '\x00',
- 'a',
- 'ab',
- '\x80',
- '\xff',
- '\u2028',
- 'abcdef\u2028',
- '\u{10002}',
- 'abcdef\u{10002}'
- ].map(jsStringImpl).toList();
- List<int> counts = [
- 0,
- 1,
- 2,
- 10,
- ];
+ List<String> testStrings =
+ [
+ '',
+ '\x00',
+ 'a',
+ 'ab',
+ '\x80',
+ '\xff',
+ '\u2028',
+ 'abcdef\u2028',
+ '\u{10002}',
+ 'abcdef\u{10002}',
+ ].map(jsStringImpl).toList();
+ List<int> counts = [0, 1, 2, 10];
void testRepeat(String str, int repeat) {
String expect;
if (repeat <= 0) {
@@ -390,7 +391,7 @@
} else if (repeat == 1) {
expect = str;
} else {
- StringBuffer buf = new StringBuffer();
+ StringBuffer buf = StringBuffer();
for (int i = 0; i < repeat; i++) {
buf.write(str);
}
@@ -420,7 +421,9 @@
Expect.equals('xyzxyzxyzxyzxyz', r('').padLeft(5, a('xyz')));
Expect.equals('xyzxyzxyzxyza', r('a').padLeft(5, a('xyz')));
Expect.equals(
- '\u{10002}\u{10002}\u{10002}aa', r('aa').padLeft(5, a('\u{10002}')));
+ '\u{10002}\u{10002}\u{10002}aa',
+ r('aa').padLeft(5, a('\u{10002}')),
+ );
}
void testPadRight(TestMode mode) {
@@ -436,7 +439,9 @@
Expect.equals('xyzxyzxyzxyzxyz', r('').padRight(5, a('xyz')));
Expect.equals('axyzxyzxyzxyz', r('a').padRight(5, a('xyz')));
Expect.equals(
- 'aa\u{10002}\u{10002}\u{10002}', r('aa').padRight(5, a('\u{10002}')));
+ 'aa\u{10002}\u{10002}\u{10002}',
+ r('aa').padRight(5, a('\u{10002}')),
+ );
Expect.equals('a', r('a').padRight(10, a('')));
}
@@ -544,7 +549,9 @@
for (final match in matches) {
Expect.equals(astr.indexOf(expected, start), match.start);
Expect.equals(
- astr.indexOf(expected, start) + helloPattern.length, match.end);
+ astr.indexOf(expected, start) + helloPattern.length,
+ match.end,
+ );
Expect.equals(helloPattern, match.pattern);
Expect.equals(astr, match.input);
Expect.equals(helloPattern, match[0]);
@@ -692,39 +699,57 @@
// Test replaceFirst
Expect.equals(
- 'AtoBtoCDtoE', r('AfromBtoCDtoE').replaceFirst(a('from'), a('to')));
+ 'AtoBtoCDtoE',
+ r('AfromBtoCDtoE').replaceFirst(a('from'), a('to')),
+ );
Expect.equals(
- 'toABtoCDtoE', r('fromABtoCDtoE').replaceFirst(a('from'), a('to')));
+ 'toABtoCDtoE',
+ r('fromABtoCDtoE').replaceFirst(a('from'), a('to')),
+ );
Expect.equals(
- 'toABtoCDtoEto', r('fromABtoCDtoEto').replaceFirst(a('from'), a('to')));
+ 'toABtoCDtoEto',
+ r('fromABtoCDtoEto').replaceFirst(a('from'), a('to')),
+ );
Expect.equals('ABC', r('ABC').replaceFirst(a('from'), a('to')));
Expect.equals('', r('').replaceFirst(a('from'), a('to')));
- Expect.equals('foo-AAA-foo-bar',
- r('foo-bar-foo-bar').replaceFirst(a('bar'), a('AAA'), 4));
- Expect.equals('foo-bar-foo-bar',
- r('foo-bar-foo-bar').replaceFirst(RegExp(r'^foo'), a(''), 8));
+ Expect.equals(
+ 'foo-AAA-foo-bar',
+ r('foo-bar-foo-bar').replaceFirst(a('bar'), a('AAA'), 4),
+ );
+ Expect.equals(
+ 'foo-bar-foo-bar',
+ r('foo-bar-foo-bar').replaceFirst(RegExp(r'^foo'), a(''), 8),
+ );
Expect.throwsRangeError(() => r('hello').replaceFirst(a('h'), a('X'), -1));
Expect.throwsRangeError(() => r('hello').replaceFirst(a('h'), a('X'), 6));
// Test replaceFirstMapped.
- Expect.equals('AtoBtoCDtoE',
- r('AfromBtoCDtoE').replaceFirstMapped(a('from'), (_) => a('to')));
+ Expect.equals(
+ 'AtoBtoCDtoE',
+ r('AfromBtoCDtoE').replaceFirstMapped(a('from'), (_) => a('to')),
+ );
Expect.equals('ABC', r('ABC').replaceFirstMapped(a('from'), (_) => a('to')));
Expect.equals('', r('').replaceFirstMapped(a('from'), (_) => a('to')));
- Expect.equals('foo-AAA-foo-bar',
- r('foo-bar-foo-bar').replaceFirstMapped(a('bar'), (_) => a('AAA'), 4));
Expect.equals(
+ 'foo-AAA-foo-bar',
+ r('foo-bar-foo-bar').replaceFirstMapped(a('bar'), (_) => a('AAA'), 4),
+ );
+ Expect.equals(
+ 'foo-bar-foo-bar',
+ r('foo-bar-foo-bar').replaceFirstMapped(RegExp(r'^foo'), (_) => a(''), 8),
+ );
+ Expect.throwsRangeError(
+ () => r('hello').replaceFirstMapped(a('h'), (_) => a('X'), -1),
+ );
+ Expect.throwsRangeError(
+ () => r('hello').replaceFirstMapped(a('h'), (_) => a('X'), 6),
+ );
+ Expect.equals(
+ 'foo-BAR-foo-bar',
+ r(
'foo-bar-foo-bar',
- r('foo-bar-foo-bar')
- .replaceFirstMapped(RegExp(r'^foo'), (_) => a(''), 8));
- Expect.throwsRangeError(
- () => r('hello').replaceFirstMapped(a('h'), (_) => a('X'), -1));
- Expect.throwsRangeError(
- () => r('hello').replaceFirstMapped(a('h'), (_) => a('X'), 6));
- Expect.equals(
- 'foo-BAR-foo-bar',
- r('foo-bar-foo-bar')
- .replaceFirstMapped(a('bar'), (v) => a(v[0]!.toUpperCase())));
+ ).replaceFirstMapped(a('bar'), (v) => a(v[0]!.toUpperCase())),
+ );
for (final string in [r(''), r('x'), r('foo'), r('x\u2000z')]) {
for (final replacement in [a(''), a('foo'), a(string)]) {
@@ -733,12 +758,18 @@
for (int end = start; end <= string.length; end++) {
expect =
string.substring(0, start) + replacement + string.substring(end);
- Expect.equals(expect, string.replaceRange(start, end, replacement),
- "'$string'[$start:$end]='$replacement'");
+ Expect.equals(
+ expect,
+ string.replaceRange(start, end, replacement),
+ "'$string'[$start:$end]='$replacement'",
+ );
}
// Reuse expect from 'end == string.length' case when omitting end.
- Expect.equals(expect, string.replaceRange(start, null, replacement),
- "'$string'[$start:]='$replacement'");
+ Expect.equals(
+ expect,
+ string.replaceRange(start, null, replacement),
+ "'$string'[$start:]='$replacement'",
+ );
}
}
Expect.throws(() => string.replaceRange(-1, 0, 'x'));
@@ -752,27 +783,41 @@
String mark(Match m) => a('[${m[0]}]');
String rest(String s) => a('<${s}>');
- Expect.equals('<a>[b]<ca>[b]<dae>',
- r('abcabdae').splitMapJoin(a('b'), onMatch: mark, onNonMatch: rest));
- Expect.equals('<abcabdae>',
- r('abcabdae').splitMapJoin(a('f'), onMatch: mark, onNonMatch: rest));
Expect.equals(
- '<>', r('').splitMapJoin(a('from'), onMatch: mark, onNonMatch: rest));
+ '<a>[b]<ca>[b]<dae>',
+ r('abcabdae').splitMapJoin(a('b'), onMatch: mark, onNonMatch: rest),
+ );
Expect.equals(
- '<>[]<>', r('').splitMapJoin(a(''), onMatch: mark, onNonMatch: rest));
- Expect.equals('<>[]<A>[]<B>[]<C>[]<>',
- r('ABC').splitMapJoin(a(''), onMatch: mark, onNonMatch: rest));
+ '<abcabdae>',
+ r('abcabdae').splitMapJoin(a('f'), onMatch: mark, onNonMatch: rest),
+ );
Expect.equals(
- '[a]bc[a]bd[a]e', r('abcabdae').splitMapJoin(a('a'), onMatch: mark));
+ '<>',
+ r('').splitMapJoin(a('from'), onMatch: mark, onNonMatch: rest),
+ );
Expect.equals(
- '<>a<bc>a<bd>a<e>', r('abcabdae').splitMapJoin(a('a'), onNonMatch: rest));
+ '<>[]<>',
+ r('').splitMapJoin(a(''), onMatch: mark, onNonMatch: rest),
+ );
+ Expect.equals(
+ '<>[]<A>[]<B>[]<C>[]<>',
+ r('ABC').splitMapJoin(a(''), onMatch: mark, onNonMatch: rest),
+ );
+ Expect.equals(
+ '[a]bc[a]bd[a]e',
+ r('abcabdae').splitMapJoin(a('a'), onMatch: mark),
+ );
+ Expect.equals(
+ '<>a<bc>a<bd>a<e>',
+ r('abcabdae').splitMapJoin(a('a'), onNonMatch: rest),
+ );
}
void main() {
for (final mode in [
TestMode.jsStringImplReceiver,
TestMode.jsStringImplArgument,
- TestMode.jsStringImplReceiverAndArguments
+ TestMode.jsStringImplReceiverAndArguments,
]) {
testLength(mode);
testConcat(mode);
diff --git a/tests/lib/js/static_interop_test/js_types_test.dart b/tests/lib/js/static_interop_test/js_types_test.dart
index 385b170..f522c77 100644
--- a/tests/lib/js/static_interop_test/js_types_test.dart
+++ b/tests/lib/js/static_interop_test/js_types_test.dart
@@ -10,8 +10,6 @@
import 'package:expect/async_helper.dart';
import 'package:expect/expect.dart';
-// TODO(srujzs): Delete this import and replace all uses with expect.dart.
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
const isJSBackend = const bool.fromEnvironment('dart.library.html');
@@ -165,25 +163,28 @@
''');
// [JSObject]
- expect(obj is JSObject, true);
- expect(confuse(obj) is JSObject, true);
- expect((obj as SimpleObject).foo.toDart, 'bar');
+ Expect.isTrue(obj is JSObject);
+ Expect.isTrue(confuse(obj) is JSObject);
+ Expect.equals('bar', (obj as SimpleObject).foo.toDart);
// [JSFunction]
- expect(fun is JSFunction, true);
- expect(confuse(fun) is JSFunction, true);
+ Expect.isTrue(fun is JSFunction);
+ Expect.isTrue(confuse(fun) is JSFunction);
// [JSExportedDartFunction] <-> [Function]
final dartFunction = (JSString a, JSString b) {
return (a.toDart + b.toDart).toJS;
};
edf = dartFunction.toJS;
- expect(doFun('foo'.toJS, 'bar'.toJS).toDart, 'foobar');
- expect(
- (edf.toDart as JSString Function(JSString, JSString))(
- 'foo'.toJS, 'bar'.toJS)
- .toDart,
- 'foobar');
+ Expect.equals('foobar', doFun('foo'.toJS, 'bar'.toJS).toDart);
+ Expect.equals(
+ 'foobar',
+ (edf.toDart as JSString Function(JSString, JSString))(
+ 'foo'.toJS,
+ 'bar'.toJS,
+ )
+ .toDart,
+ );
Expect.identical(edf.toDart, dartFunction);
// Two wrappers should not be the same.
Expect.notEquals(edf, dartFunction.toJS);
@@ -197,55 +198,58 @@
};
edf = dartFunctionThis.toJSCaptureThis;
Expect.equals(
- (edf.callAsFunction(this_, 'foo'.toJS, 'bar'.toJS) as JSString).toDart,
- 'foobar');
+ (edf.callAsFunction(this_, 'foo'.toJS, 'bar'.toJS) as JSString).toDart,
+ 'foobar',
+ );
Expect.identical(edf.toDart, dartFunctionThis);
Expect.notEquals(edf, dartFunctionThis.toJSCaptureThis);
// [JSBoxedDartObject] <-> [Object]
edo = DartObject().toJSBox;
- expect(edo is JSBoxedDartObject, true);
- expect(confuse(edo) is JSBoxedDartObject, true);
- expect(((edo as JSBoxedDartObject).toDart as DartObject).foo, 'bar');
- expect(edo.instanceOfString('Object'), true);
+ Expect.isTrue(edo is JSBoxedDartObject);
+ Expect.isTrue(confuse(edo) is JSBoxedDartObject);
+ Expect.equals('bar', ((edo as JSBoxedDartObject).toDart as DartObject).foo);
+ Expect.isTrue(edo.instanceOfString('Object'));
// Functions should be boxed without assertInterop.
final concat = (String a, String b) => a + b;
edo = concat.toJSBox;
- expect(
- (edo.toDart as String Function(String, String))('foo', 'bar'), 'foobar');
+ Expect.equals(
+ 'foobar',
+ (edo.toDart as String Function(String, String))('foo', 'bar'),
+ );
// Should not box a non Dart-object.
Expect.throws(() => edo.toJSBox);
// [JSArray] constructors and members.
arrN = JSArray<JSNumber>();
- expect(arrN.length, 0);
+ Expect.equals(0, arrN.length);
arrN = JSArray<JSNumber>.withLength(4);
- expect(arrN.length, 4);
+ Expect.equals(4, arrN.length);
arrN.length = 1;
- expect(arrN.length, 1);
+ Expect.equals(1, arrN.length);
arrN[0] = 1.toJS;
- expect(arrN[0].toDartInt, 1);
+ Expect.equals(1, arrN[0].toDartInt);
arrN = JSArray.from<JSNumber>(arrN);
- expect(arrN.length, 1);
- expect(arrN[0].toDartInt, 1);
+ Expect.equals(1, arrN.length);
+ Expect.equals(1, arrN[0].toDartInt);
final typedArray = JSArray.from<JSNumber>(JSUint8Array.withLength(4));
- expect(typedArray.length, 4);
- expect(typedArray[0].toDartInt, 0);
+ Expect.equals(4, typedArray.length);
+ Expect.equals(0, typedArray[0].toDartInt);
// [JSArray] <-> [List<JSAny?>]
final list = <JSAny?>[1.0.toJS, 'foo'.toJS];
arr = list.toJS;
- expect(arr is JSArray, true);
- expect(confuse(arr) is JSArray, true);
+ Expect.isTrue(arr is JSArray);
+ Expect.isTrue(confuse(arr) is JSArray);
List<JSAny?> dartArr = arr.toDart;
- expect((dartArr[0] as JSNumber).toDartDouble, 1.0);
- expect((dartArr[1] as JSString).toDart, 'foo');
+ Expect.equals(1.0, (dartArr[0] as JSNumber).toDartDouble);
+ Expect.equals('foo', (dartArr[1] as JSString).toDart);
List<JSNumber> dartArrN = arrN.toDart;
if (isJSBackend) {
// Since lists on the JS backends are passed by ref, we only create a
// cast-list if there's a downcast needed.
- expect(dartArr, list);
+ Expect.equals(list, dartArr);
Expect.notEquals(dartArrN, list);
Expect.throwsTypeError(() => dartArrN[1]);
} else {
@@ -258,16 +262,16 @@
// [JSArray<T>] <-> [List<T>]
final listN = <JSNumber>[1.0.toJS, 2.0.toJS];
arrN = listN.toJS;
- expect(arrN is JSArray<JSNumber>, true);
- expect(confuse(arrN) is JSArray<JSNumber>, true);
+ Expect.isTrue(arrN is JSArray<JSNumber>);
+ Expect.isTrue(confuse(arrN) is JSArray<JSNumber>);
dartArr = arr.toDart;
dartArrN = arrN.toDart;
if (isJSBackend) {
// A cast-list should not be introduced if the array is already the
// right list type.
- expect(dartArr, listN);
- expect(dartArrN, listN);
+ Expect.equals(listN, dartArr);
+ Expect.equals(listN, dartArrN);
} else {
Expect.notEquals(dartArr, list);
Expect.notEquals(dartArrN, list);
@@ -275,236 +279,251 @@
// [ArrayBuffer] <-> [ByteBuffer]
buf = Uint8List.fromList([0, 255, 0, 255]).buffer.toJS;
- expect(buf is JSArrayBuffer, true);
- expect(confuse(buf) is JSArrayBuffer, true);
+ Expect.isTrue(buf is JSArrayBuffer);
+ Expect.isTrue(confuse(buf) is JSArrayBuffer);
ByteBuffer dartBuf = buf.toDart;
- expect(dartBuf.asUint8List(), equals([0, 255, 0, 255]));
+ Expect.listEquals([0, 255, 0, 255], dartBuf.asUint8List());
buf = JSArrayBuffer(5);
- expect(buf.byteLength, 5);
+ Expect.equals(5, buf.byteLength);
buf = JSArrayBuffer(5, {'maxByteLength': 12}.jsify() as JSObject);
// [DataView] <-> [ByteData]
final datBuf = Uint8List.fromList([0, 255, 0, 255]).buffer.toJS;
dat = datBuf.toDart.asByteData().toJS;
- expect(dat is JSDataView, true);
- expect(confuse(dat) is JSDataView, true);
+ Expect.isTrue(dat is JSDataView);
+ Expect.isTrue(confuse(dat) is JSDataView);
ByteData dartDat = dat.toDart;
- expect(dartDat.getUint8(0), 0);
- expect(dartDat.getUint8(1), 255);
+ Expect.equals(0, dartDat.getUint8(0));
+ Expect.equals(255, dartDat.getUint8(1));
dat = JSDataView(datBuf);
- expect(dat.buffer, datBuf);
+ Expect.equals(datBuf, dat.buffer);
final dat2 = JSDataView(datBuf, 1, 3);
- expect(dat2.byteOffset, 1);
- expect(dat2.byteLength, 3);
+ Expect.equals(1, dat2.byteOffset);
+ Expect.equals(3, dat2.byteLength);
// [TypedArray]s <-> [TypedData]s
// Test common TypedArray constructors for different subtypes.
void testTypedArrayConstructors(
- JSTypedArray Function(JSArrayBuffer) createFromBuffer,
- JSTypedArray Function(JSArrayBuffer, int, int)
- createFromBufferOffsetAndLength,
- JSTypedArray Function(int) createFromLength,
- int byteSize) {
+ JSTypedArray Function(JSArrayBuffer) createFromBuffer,
+ JSTypedArray Function(JSArrayBuffer, int, int)
+ createFromBufferOffsetAndLength,
+ JSTypedArray Function(int) createFromLength,
+ int byteSize,
+ ) {
var byteLength = 16;
final buf = JSArrayBuffer(byteLength);
var typedArray = createFromBuffer(buf);
- expect(typedArray.buffer, buf);
- expect(typedArray.byteLength, byteLength);
- expect(typedArray.byteOffset, 0);
- expect(typedArray.length, byteLength ~/ byteSize);
+ Expect.equals(buf, typedArray.buffer);
+ Expect.equals(byteLength, typedArray.byteLength);
+ Expect.equals(0, typedArray.byteOffset);
+ Expect.equals(typedArray.length, byteLength ~/ byteSize);
byteLength = 8;
- typedArray =
- createFromBufferOffsetAndLength(buf, 8, byteLength ~/ byteSize);
- expect(typedArray.buffer, buf);
- expect(typedArray.byteLength, byteLength);
- expect(typedArray.byteOffset, 8);
- expect(typedArray.length, byteLength ~/ byteSize);
+ typedArray = createFromBufferOffsetAndLength(
+ buf,
+ 8,
+ byteLength ~/ byteSize,
+ );
+ Expect.equals(buf, typedArray.buffer);
+ Expect.equals(byteLength, typedArray.byteLength);
+ Expect.equals(8, typedArray.byteOffset);
+ Expect.equals(typedArray.length, byteLength ~/ byteSize);
typedArray = createFromLength(byteLength ~/ byteSize);
- expect(typedArray.byteLength, byteLength);
- expect(typedArray.byteOffset, 0);
- expect(typedArray.length, byteLength ~/ byteSize);
+ Expect.equals(byteLength, typedArray.byteLength);
+ Expect.equals(0, typedArray.byteOffset);
+ Expect.equals(typedArray.length, byteLength ~/ byteSize);
}
// Int8
ai8 = Int8List.fromList([-128, 0, 127]).toJS;
- expect(ai8 is JSInt8Array, true);
- expect(confuse(ai8) is JSInt8Array, true);
+ Expect.isTrue(ai8 is JSInt8Array);
+ Expect.isTrue(confuse(ai8) is JSInt8Array);
Int8List dartAi8 = ai8.toDart;
- expect(dartAi8, equals([-128, 0, 127]));
+ Expect.listEquals([-128, 0, 127], dartAi8);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSInt8Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSInt8Array(obj, byteOffset, length),
- (int length) => JSInt8Array.withLength(length),
- 1);
+ (JSArrayBuffer obj) => JSInt8Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSInt8Array(obj, byteOffset, length),
+ (int length) => JSInt8Array.withLength(length),
+ 1,
+ );
// Uint8
au8 = Uint8List.fromList([-1, 0, 255, 256]).toJS;
- expect(au8 is JSUint8Array, true);
- expect(confuse(au8) is JSUint8Array, true);
+ Expect.isTrue(au8 is JSUint8Array);
+ Expect.isTrue(confuse(au8) is JSUint8Array);
Uint8List dartAu8 = au8.toDart;
- expect(dartAu8, equals([255, 0, 255, 0]));
+ Expect.listEquals([255, 0, 255, 0], dartAu8);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSUint8Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSUint8Array(obj, byteOffset, length),
- (int length) => JSUint8Array.withLength(length),
- 1);
+ (JSArrayBuffer obj) => JSUint8Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSUint8Array(obj, byteOffset, length),
+ (int length) => JSUint8Array.withLength(length),
+ 1,
+ );
// Uint8Clamped
ac8 = Uint8ClampedList.fromList([-1, 0, 255, 256]).toJS;
- expect(ac8 is JSUint8ClampedArray, true);
- expect(confuse(ac8) is JSUint8ClampedArray, true);
+ Expect.isTrue(ac8 is JSUint8ClampedArray);
+ Expect.isTrue(confuse(ac8) is JSUint8ClampedArray);
Uint8ClampedList dartAc8 = ac8.toDart;
- expect(dartAc8, equals([0, 0, 255, 255]));
+ Expect.listEquals([0, 0, 255, 255], dartAc8);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSUint8ClampedArray(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSUint8ClampedArray(obj, byteOffset, length),
- (int length) => JSUint8ClampedArray.withLength(length),
- 1);
+ (JSArrayBuffer obj) => JSUint8ClampedArray(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSUint8ClampedArray(obj, byteOffset, length),
+ (int length) => JSUint8ClampedArray.withLength(length),
+ 1,
+ );
// Int16
ai16 = Int16List.fromList([-32769, -32768, 0, 32767, 32768]).toJS;
- expect(ai16 is JSInt16Array, true);
- expect(confuse(ai16) is JSInt16Array, true);
+ Expect.isTrue(ai16 is JSInt16Array);
+ Expect.isTrue(confuse(ai16) is JSInt16Array);
Int16List dartAi16 = ai16.toDart;
- expect(dartAi16, equals([32767, -32768, 0, 32767, -32768]));
+ Expect.listEquals([32767, -32768, 0, 32767, -32768], dartAi16);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSInt16Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSInt16Array(obj, byteOffset, length),
- (int length) => JSInt16Array.withLength(length),
- 2);
+ (JSArrayBuffer obj) => JSInt16Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSInt16Array(obj, byteOffset, length),
+ (int length) => JSInt16Array.withLength(length),
+ 2,
+ );
// Uint16
au16 = Uint16List.fromList([-1, 0, 65535, 65536]).toJS;
- expect(au16 is JSUint16Array, true);
- expect(confuse(au16) is JSUint16Array, true);
+ Expect.isTrue(au16 is JSUint16Array);
+ Expect.isTrue(confuse(au16) is JSUint16Array);
Uint16List dartAu16 = au16.toDart;
- expect(dartAu16, equals([65535, 0, 65535, 0]));
+ Expect.listEquals([65535, 0, 65535, 0], dartAu16);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSUint16Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSUint16Array(obj, byteOffset, length),
- (int length) => JSUint16Array.withLength(length),
- 2);
+ (JSArrayBuffer obj) => JSUint16Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSUint16Array(obj, byteOffset, length),
+ (int length) => JSUint16Array.withLength(length),
+ 2,
+ );
// Int32
ai32 = Int32List.fromList([-2147483648, 0, 2147483647]).toJS;
- expect(ai32 is JSInt32Array, true);
- expect(confuse(ai32) is JSInt32Array, true);
+ Expect.isTrue(ai32 is JSInt32Array);
+ Expect.isTrue(confuse(ai32) is JSInt32Array);
Int32List dartAi32 = ai32.toDart;
- expect(dartAi32, equals([-2147483648, 0, 2147483647]));
+ Expect.listEquals([-2147483648, 0, 2147483647], dartAi32);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSInt32Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSInt32Array(obj, byteOffset, length),
- (int length) => JSInt32Array.withLength(length),
- 4);
+ (JSArrayBuffer obj) => JSInt32Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSInt32Array(obj, byteOffset, length),
+ (int length) => JSInt32Array.withLength(length),
+ 4,
+ );
// Uint32
au32 = Uint32List.fromList([-1, 0, 4294967295, 4294967296]).toJS;
- expect(au32 is JSUint32Array, true);
- expect(confuse(au32) is JSUint32Array, true);
+ Expect.isTrue(au32 is JSUint32Array);
+ Expect.isTrue(confuse(au32) is JSUint32Array);
Uint32List dartAu32 = au32.toDart;
- expect(dartAu32, equals([4294967295, 0, 4294967295, 0]));
+ Expect.listEquals([4294967295, 0, 4294967295, 0], dartAu32);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSUint32Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSUint32Array(obj, byteOffset, length),
- (int length) => JSUint32Array.withLength(length),
- 4);
+ (JSArrayBuffer obj) => JSUint32Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSUint32Array(obj, byteOffset, length),
+ (int length) => JSUint32Array.withLength(length),
+ 4,
+ );
// Float32
af32 = Float32List.fromList([-1000.488, -0.00001, 0.0001, 10004.888]).toJS;
- expect(af32 is JSFloat32Array, true);
- expect(confuse(af32) is JSFloat32Array, true);
+ Expect.isTrue(af32 is JSFloat32Array);
+ Expect.isTrue(confuse(af32) is JSFloat32Array);
Float32List dartAf32 = af32.toDart;
- expect(dartAf32,
- equals(Float32List.fromList([-1000.488, -0.00001, 0.0001, 10004.888])));
+ Expect.listEquals(
+ Float32List.fromList([-1000.488, -0.00001, 0.0001, 10004.888]),
+ dartAf32,
+ );
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSFloat32Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSFloat32Array(obj, byteOffset, length),
- (int length) => JSFloat32Array.withLength(length),
- 4);
+ (JSArrayBuffer obj) => JSFloat32Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSFloat32Array(obj, byteOffset, length),
+ (int length) => JSFloat32Array.withLength(length),
+ 4,
+ );
// Float64
af64 = Float64List.fromList([-1000.488, -0.00001, 0.0001, 10004.888]).toJS;
- expect(af64 is JSFloat64Array, true);
- expect(confuse(af64) is JSFloat64Array, true);
+ Expect.isTrue(af64 is JSFloat64Array);
+ Expect.isTrue(confuse(af64) is JSFloat64Array);
Float64List dartAf64 = af64.toDart;
- expect(dartAf64, equals([-1000.488, -0.00001, 0.0001, 10004.888]));
+ Expect.listEquals([-1000.488, -0.00001, 0.0001, 10004.888], dartAf64);
testTypedArrayConstructors(
- (JSArrayBuffer obj) => JSFloat64Array(obj),
- (JSArrayBuffer obj, int byteOffset, int length) =>
- JSFloat64Array(obj, byteOffset, length),
- (int length) => JSFloat64Array.withLength(length),
- 8);
+ (JSArrayBuffer obj) => JSFloat64Array(obj),
+ (JSArrayBuffer obj, int byteOffset, int length) =>
+ JSFloat64Array(obj, byteOffset, length),
+ (int length) => JSFloat64Array.withLength(length),
+ 8,
+ );
// [JSNumber] <-> [double]
nbr = 4.5.toJS;
- expect(nbr is JSNumber, true);
- expect(confuse(nbr) is JSNumber, true);
+ Expect.isTrue(nbr is JSNumber);
+ Expect.isTrue(confuse(nbr) is JSNumber);
double dartNbr = nbr.toDartDouble;
- expect(dartNbr, 4.5);
+ Expect.equals(4.5, dartNbr);
// [JSBoolean] <-> [bool]
boo = true.toJS;
- expect(boo is JSBoolean, true);
- expect(confuse(boo) is JSBoolean, true);
+ Expect.isTrue(boo is JSBoolean);
+ Expect.isTrue(confuse(boo) is JSBoolean);
bool dartBoo = boo.toDart;
- expect(dartBoo, true);
+ Expect.isTrue(dartBoo);
// [JSString] <-> [String]
str = 'foo'.toJS;
- expect(str is JSString, true);
- expect(confuse(str) is JSString, true);
+ Expect.isTrue(str is JSString);
+ Expect.isTrue(confuse(str) is JSString);
String dartStr = str.toDart;
- expect(dartStr, 'foo');
+ Expect.equals('foo', dartStr);
// [JSSymbol]
symbol = createSymbol('foo');
- expect(symbol is JSSymbol, true);
- expect(confuse(symbol) is JSSymbol, true);
- expect(symbol.toStringExternal(), 'Symbol(foo)');
+ Expect.isTrue(symbol is JSSymbol);
+ Expect.isTrue(confuse(symbol) is JSSymbol);
+ Expect.equals('Symbol(foo)', symbol.toStringExternal());
// [JSBigInt]
bigInt = createBigInt('9876543210000000000000123456789');
- expect(bigInt is JSBigInt, true);
- expect(confuse(bigInt) is JSBigInt, true);
- expect(bigInt.toStringExternal(), '9876543210000000000000123456789');
+ Expect.isTrue(bigInt is JSBigInt);
+ Expect.isTrue(confuse(bigInt) is JSBigInt);
+ Expect.equals('9876543210000000000000123456789', bigInt.toStringExternal());
// null and undefined can flow into `JSAny?`.
// TODO(srujzs): Remove the `isJSBackend` checks when `JSNull` and
// `JSUndefined` can be distinguished on dart2wasm.
if (isJSBackend) {
- expect(nullAny.isNull, true);
- expect(nullAny.isUndefined, false);
+ Expect.isTrue(nullAny.isNull);
+ Expect.isFalse(nullAny.isUndefined);
}
- expect(nullAny, null);
- expect(nullAny.isUndefinedOrNull, true);
- expect(nullAny.isDefinedAndNotNull, false);
- expect(nullAny.typeofEquals('object'), true);
+ Expect.isNull(nullAny);
+ Expect.isTrue(nullAny.isUndefinedOrNull);
+ Expect.isFalse(nullAny.isDefinedAndNotNull);
+ Expect.isTrue(nullAny.typeofEquals('object'));
if (isJSBackend) {
- expect(undefinedAny.isNull, false);
- expect(undefinedAny.isUndefined, true);
+ Expect.isFalse(undefinedAny.isNull);
+ Expect.isTrue(undefinedAny.isUndefined);
}
- expect(undefinedAny.isUndefinedOrNull, true);
- expect(undefinedAny.isDefinedAndNotNull, false);
+ Expect.isTrue(undefinedAny.isUndefinedOrNull);
+ Expect.isFalse(undefinedAny.isDefinedAndNotNull);
if (isJSBackend) {
- expect(undefinedAny.typeofEquals('undefined'), true);
- expect(definedNonNullAny.isNull, false);
- expect(definedNonNullAny.isUndefined, false);
+ Expect.isTrue(undefinedAny.typeofEquals('undefined'));
+ Expect.isFalse(definedNonNullAny.isNull);
+ Expect.isFalse(definedNonNullAny.isUndefined);
} else {
- expect(undefinedAny.typeofEquals('object'), true);
+ Expect.isTrue(undefinedAny.typeofEquals('object'));
}
- expect(definedNonNullAny.isUndefinedOrNull, false);
- expect(definedNonNullAny.isDefinedAndNotNull, true);
- expect(definedNonNullAny.typeofEquals('object'), true);
+ Expect.isFalse(definedNonNullAny.isUndefinedOrNull);
+ Expect.isTrue(definedNonNullAny.isDefinedAndNotNull);
+ Expect.isTrue(definedNonNullAny.typeofEquals('object'));
}
@JS()
@@ -515,11 +534,13 @@
@JS()
external JSPromise<T> resolvePromiseWithNullOrUndefined<T extends JSAny?>(
- bool resolveWithNull);
+ bool resolveWithNull,
+);
@JS()
external JSPromise<T> rejectPromiseWithNullOrUndefined<T extends JSAny?>(
- bool resolveWithNull);
+ bool resolveWithNull,
+);
Future<void> asyncTests() async {
eval(r'''
@@ -541,13 +562,13 @@
// Test resolution.
{
final f = getResolvedPromise().toDart;
- expect(((await f) as JSString).toDart, 'resolved');
+ Expect.equals('resolved', ((await f) as JSString).toDart);
}
// Test resolution with generics.
{
final f = getResolvedPromise<JSString>().toDart;
- expect((await f).toDart, 'resolved');
+ Expect.equals('resolved', (await f).toDart);
}
// Test resolution with incorrect type.
@@ -570,10 +591,10 @@
{
try {
await getRejectedPromise().toDart;
- fail('Expected rejected promise to throw.');
+ Expect.fail('Expected rejected promise to throw.');
} catch (e) {
final jsError = e as JSObject;
- expect(jsError.toString(), 'Error: rejected');
+ Expect.equals('Error: rejected', jsError.toString());
}
}
@@ -581,10 +602,10 @@
{
try {
await getRejectedPromise<JSString>().toDart;
- fail('Expected rejected promise to throw.');
+ Expect.fail('Expected rejected promise to throw.');
} catch (e) {
final jsError = e as JSObject;
- expect(jsError.toString(), 'Error: rejected');
+ Expect.equals('Error: rejected', jsError.toString());
}
}
@@ -592,31 +613,35 @@
{
bool didThen = false;
final f = getResolvedPromise().toDart.then((resolved) {
- expect((resolved as JSString).toDart, 'resolved');
+ Expect.equals('resolved', (resolved as JSString).toDart);
didThen = true;
return null;
});
await f;
- expect(didThen, true);
+ Expect.isTrue(didThen);
}
// Test rejection Promise chaining.
{
- final f = getRejectedPromise().toDart.then((_) {
- fail('Expected rejected promise to throw.');
- return null;
- }, onError: (e) {
- final jsError = e as JSObject;
- expect(jsError.toString(), 'Error: rejected');
- });
+ final f = getRejectedPromise().toDart.then(
+ (_) {
+ Expect.fail('Expected rejected promise to throw.');
+ return null;
+ },
+ onError: (e) {
+ final jsError = e as JSObject;
+ Expect.equals('Error: rejected', jsError.toString());
+ },
+ );
await f;
}
// Test resolving generic promise with null and undefined.
Future<void> testResolveWithNullOrUndefined<T extends JSAny?>(
- bool resolveWithNull) async {
+ bool resolveWithNull,
+ ) async {
final f = resolvePromiseWithNullOrUndefined<T>(resolveWithNull).toDart;
- expect(await f, null);
+ Expect.isNull(await f);
}
await testResolveWithNullOrUndefined(true);
@@ -627,12 +652,13 @@
// Test rejecting generic promise with null and undefined should trigger an
// exception.
Future<void> testRejectionWithNullOrUndefined<T extends JSAny?>(
- bool rejectWithNull) async {
+ bool rejectWithNull,
+ ) async {
try {
await rejectPromiseWithNullOrUndefined<T>(rejectWithNull).toDart;
- fail('Expected rejected promise to throw.');
+ Expect.fail('Expected rejected promise to throw.');
} catch (e) {
- expect(e is NullRejectionException, true);
+ Expect.isTrue(e is NullRejectionException);
}
}
@@ -645,13 +671,13 @@
// Test resolution.
{
final f = Future<JSAny?>(() => 'resolved'.toJS).toJS.toDart;
- expect(((await f) as JSString).toDart, 'resolved');
+ Expect.equals('resolved', ((await f) as JSString).toDart);
}
// Test resolution with generics.
{
final f = Future<JSString>(() => 'resolved'.toJS).toJS.toDart;
- expect((await f).toDart, 'resolved');
+ Expect.equals('resolved', (await f).toDart);
}
// Test resolution with incorrect types. Depending on the backend and the type
@@ -689,12 +715,14 @@
{
try {
await Future<JSAny?>(() => throw Exception()).toJS.toDart;
- fail('Expected future to throw.');
+ Expect.fail('Expected future to throw.');
} catch (e) {
- expect(e is JSObject, true);
+ Expect.isTrue(e is JSObject);
final jsError = e as JSObject;
- expect(jsError.instanceof(globalContext['Error'] as JSFunction), true);
- expect((jsError['error'] as JSBoxedDartObject).toDart is Exception, true);
+ Expect.isTrue(jsError.instanceof(globalContext['Error'] as JSFunction));
+ Expect.isTrue(
+ (jsError['error'] as JSBoxedDartObject).toDart is Exception,
+ );
StackTrace.fromString((jsError['stack'] as JSString).toDart);
}
}
@@ -703,11 +731,12 @@
// Test resolution.
{
var compute = false;
- final f = Future<void>(() {
- compute = true;
- }).toJS.toDart;
+ final f =
+ Future<void>(() {
+ compute = true;
+ }).toJS.toDart;
await f;
- expect(compute, true);
+ Expect.isTrue(compute);
}
// Test rejection.
@@ -716,12 +745,14 @@
final f =
Future<void>(() => throw Exception()).toJS.toDart as Future<void>;
await f;
- fail('Expected future to throw.');
+ Expect.fail('Expected future to throw.');
} catch (e) {
- expect(e is JSObject, true);
+ Expect.isTrue(e is JSObject);
final jsError = e as JSObject;
- expect(jsError.instanceof(globalContext['Error'] as JSFunction), true);
- expect((jsError['error'] as JSBoxedDartObject).toDart is Exception, true);
+ Expect.isTrue(jsError.instanceof(globalContext['Error'] as JSFunction));
+ Expect.isTrue(
+ (jsError['error'] as JSBoxedDartObject).toDart is Exception,
+ );
StackTrace.fromString((jsError['stack'] as JSString).toDart);
}
}
diff --git a/tests/lib/js/static_interop_test/jsobject_type_test.dart b/tests/lib/js/static_interop_test/jsobject_type_test.dart
index 868ec83..e63e8a9 100644
--- a/tests/lib/js/static_interop_test/jsobject_type_test.dart
+++ b/tests/lib/js/static_interop_test/jsobject_type_test.dart
@@ -4,12 +4,8 @@
// Check that `JSObject` can be used to type JS objects.
-@JS()
-library jsobject_type_test;
-
import 'dart:js_interop';
-
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
+import 'package:expect/expect.dart';
@JS()
external void eval(String code);
@@ -21,6 +17,6 @@
eval('''
globalThis.obj = {};
''');
- expect(obj is JSObject, true);
+ Expect.isTrue(obj is JSObject);
obj as JSObject;
}
diff --git a/tests/lib/js/static_interop_test/member_test.dart b/tests/lib/js/static_interop_test/member_test.dart
index 0c2dc08..d1dd141 100644
--- a/tests/lib/js/static_interop_test/member_test.dart
+++ b/tests/lib/js/static_interop_test/member_test.dart
@@ -4,9 +4,6 @@
// Test that instance members are disallowed from static interop classes.
-@JS()
-library member_test;
-
import 'package:js/js.dart';
@JS()
diff --git a/tests/lib/js/static_interop_test/native_error_test.dart b/tests/lib/js/static_interop_test/native_error_test.dart
index 746424f..a8fc305 100644
--- a/tests/lib/js/static_interop_test/native_error_test.dart
+++ b/tests/lib/js/static_interop_test/native_error_test.dart
@@ -4,9 +4,6 @@
// Test that JS error types are interoperable.
-@JS()
-library native_error_test;
-
import 'dart:js_interop';
@JS()
diff --git a/tests/lib/js/static_interop_test/number_test.dart b/tests/lib/js/static_interop_test/number_test.dart
index d476b3e..b3eccda 100644
--- a/tests/lib/js/static_interop_test/number_test.dart
+++ b/tests/lib/js/static_interop_test/number_test.dart
@@ -6,13 +6,9 @@
// Test that external members returning numbers have correct semantics.
-@JS()
-library number_test;
-
import 'dart:js_interop';
import 'package:expect/expect.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
extension type IntE(int _) {}
@@ -130,32 +126,32 @@
globalThis.nullVal = null;
''');
- expect(integerAsInt, 0);
- expect(integerAsIntE, 0);
- expect(integerAsDouble, 0.0);
- expect(integerAsNum, 0);
- expect(integerAsJSNumber.toDartDouble, 0.0);
- expect(integerAsJSNumber.toDartInt, 0);
+ Expect.equals(0, integerAsInt);
+ Expect.equals(0, integerAsIntE);
+ Expect.equals(0.0, integerAsDouble);
+ Expect.equals(0, integerAsNum);
+ Expect.equals(0.0, integerAsJSNumber.toDartDouble);
+ Expect.equals(0, integerAsJSNumber.toDartInt);
- expect(integerAsNullInt, 0);
- expect(integerAsNullableIntE, 0);
- expect(integerAsNullDouble, 0.0);
- expect(integerAsNullNum, 0);
- expect(integerAsNullJSNumber!.toDartDouble, 0.0);
- expect(integerAsNullJSNumber!.toDartInt, 0);
+ Expect.equals(0, integerAsNullInt);
+ Expect.equals(0, integerAsNullableIntE);
+ Expect.equals(0.0, integerAsNullDouble);
+ Expect.equals(0, integerAsNullNum);
+ Expect.equals(0.0, integerAsNullJSNumber!.toDartDouble);
+ Expect.equals(0, integerAsNullJSNumber!.toDartInt);
Expect.throws(() => floatAsInt);
Expect.throws(() => floatAsIntE);
- expect(floatAsDouble, 0.5);
- expect(floatAsNum, 0.5);
- expect(floatAsJSNumber.toDartDouble, 0.5);
+ Expect.equals(0.5, floatAsDouble);
+ Expect.equals(0.5, floatAsNum);
+ Expect.equals(0.5, floatAsJSNumber.toDartDouble);
Expect.throws(() => floatAsJSNumber.toDartInt);
Expect.throws(() => floatAsNullInt);
Expect.throws(() => floatAsNullableIntE);
- expect(floatAsNullDouble, 0.5);
- expect(floatAsNullNum, 0.5);
- expect(floatAsNullJSNumber!.toDartDouble, 0.5);
+ Expect.equals(0.5, floatAsNullDouble);
+ Expect.equals(0.5, floatAsNullNum);
+ Expect.equals(0.5, floatAsNullJSNumber!.toDartDouble);
Expect.throws(() => floatAsNullJSNumber!.toDartInt);
Expect.throws(() => nullAsInt);
@@ -164,9 +160,9 @@
Expect.throws(() => nullAsNum);
Expect.throws(() => nullAsJSNumber);
- expect(nullAsNullInt, null);
- expect(nullAsNullableIntE, null);
- expect(nullAsNullDouble, null);
- expect(nullAsNullNum, null);
- expect(nullAsNullJSNumber, null);
+ Expect.isNull(nullAsNullInt);
+ Expect.isNull(nullAsNullableIntE);
+ Expect.isNull(nullAsNullDouble);
+ Expect.isNull(nullAsNullNum);
+ Expect.isNull(nullAsNullJSNumber);
}
diff --git a/tests/lib/js/static_interop_test/object_apis_static_interop_values_test.dart b/tests/lib/js/static_interop_test/object_apis_static_interop_values_test.dart
index 7223799..8034258 100644
--- a/tests/lib/js/static_interop_test/object_apis_static_interop_values_test.dart
+++ b/tests/lib/js/static_interop_test/object_apis_static_interop_values_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library object_apis_test;
-
import 'package:expect/expect.dart';
import 'package:js/js.dart';
diff --git a/tests/lib/js/static_interop_test/operator_static_test.dart b/tests/lib/js/static_interop_test/operator_static_test.dart
index 8f6b71d..f25010a 100644
--- a/tests/lib/js/static_interop_test/operator_static_test.dart
+++ b/tests/lib/js/static_interop_test/operator_static_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library operator_static_test;
-
import 'dart:js_interop';
@JS()
diff --git a/tests/lib/js/static_interop_test/operator_test.dart b/tests/lib/js/static_interop_test/operator_test.dart
index 7652cb5..f895884 100644
--- a/tests/lib/js/static_interop_test/operator_test.dart
+++ b/tests/lib/js/static_interop_test/operator_test.dart
@@ -4,13 +4,9 @@
// Test operators through overloading and the ones defined in dart:js_interop.
-@JS()
-library operator_test;
-
import 'dart:js_interop';
import 'package:expect/expect.dart';
-import 'package:expect/legacy/minitest.dart'; // ignore: deprecated_member_use_from_same_package
@JS()
extension type OperableExtType(JSObject _) {
@@ -21,11 +17,11 @@
void extensionTypeTest() {
final obj = OperableExtType(JSObject());
obj[4] = 5;
- expect(obj[4], 5);
+ Expect.equals(5, obj[4]);
final arr = OperableExtType(JSArray());
arr[6] = 7;
- expect(arr[6], 7);
+ Expect.equals(7, arr[6]);
}
@JS()
@@ -40,11 +36,11 @@
void staticInteropTest() {
final obj = JSObject() as Operable;
obj[4] = 5;
- expect(obj[4], 5);
+ Expect.equals(5, obj[4]);
final arr = JSArray() as Operable;
arr[5] = 6;
- expect(arr[5], 6);
+ Expect.equals(6, arr[5]);
}
@JS()
@@ -62,15 +58,15 @@
void dartJsInteropOperatorsTest() {
// Arithmetic.
final i10 = 10.toJS;
- expect(toInt(i10.add(1.toJS)), 11);
- expect(toInt(i10.subtract(1.toJS)), 9);
- expect(toInt(i10.multiply(2.toJS)), 20);
- expect(toInt(i10.divide(10.toJS)), 1);
- expect(toInt(i10.modulo(5.toJS)), 0);
- expect(toInt(i10.exponentiate(2.toJS)), 100);
+ Expect.equals(11, toInt(i10.add(1.toJS)));
+ Expect.equals(9, toInt(i10.subtract(1.toJS)));
+ Expect.equals(20, toInt(i10.multiply(2.toJS)));
+ Expect.equals(1, toInt(i10.divide(10.toJS)));
+ Expect.equals(0, toInt(i10.modulo(5.toJS)));
+ Expect.equals(100, toInt(i10.exponentiate(2.toJS)));
// Bitwise.
- expect(toInt(i10.unsignedRightShift(1.toJS)), 5);
+ Expect.equals(5, toInt(i10.unsignedRightShift(1.toJS)));
// Comparison/relational.
final t = true.toJS;
@@ -90,19 +86,19 @@
Expect.isTrue(i10.greaterThanOrEqualTo(i10).toDart);
// Nulls.
- expect(toInt(null.add(null)), 0);
- expect(toInt(null.subtract(null)), 0);
- expect(toInt(null.multiply(null)), 0);
+ Expect.equals(0, toInt(null.add(null)));
+ Expect.equals(0, toInt(null.subtract(null)));
+ Expect.equals(0, toInt(null.multiply(null)));
Expect.isTrue(isNaN(null.divide(null)));
Expect.isTrue(isNaN(null.modulo(null)));
- expect(toInt(null.exponentiate(null)), 1);
- expect(toInt(null.unsignedRightShift(null)), 0);
+ Expect.equals(1, toInt(null.exponentiate(null)));
+ Expect.equals(0, toInt(null.unsignedRightShift(null)));
Expect.isTrue(null.equals(null).toDart);
Expect.isFalse(null.notEquals(null).toDart);
Expect.isTrue(null.strictEquals(null).toDart);
Expect.isFalse(null.strictNotEquals(null).toDart);
- expect(null.and(null), null);
- expect(null.or(null), null);
+ Expect.isNull(null.and(null));
+ Expect.isNull(null.or(null));
Expect.isTrue(null.not.toDart);
Expect.isFalse(null.isTruthy.toDart);
Expect.isFalse(null.lessThan(null).toDart);
@@ -112,22 +108,22 @@
// Different types.
final b10 = 10.toBigInt;
- expect(b10.add(1.toBigInt), 11.toBigInt);
- expect(b10.subtract(1.toBigInt), 9.toBigInt);
- expect(b10.multiply(2.toBigInt), 20.toBigInt);
- expect(b10.divide(10.toBigInt), 1.toBigInt);
- expect(b10.modulo(5.toBigInt), 0.toBigInt);
- expect(b10.exponentiate(2.toBigInt), 100.toBigInt);
+ Expect.equals(11.toBigInt, b10.add(1.toBigInt));
+ Expect.equals(9.toBigInt, b10.subtract(1.toBigInt));
+ Expect.equals(20.toBigInt, b10.multiply(2.toBigInt));
+ Expect.equals(1.toBigInt, b10.divide(10.toBigInt));
+ Expect.equals(0.toBigInt, b10.modulo(5.toBigInt));
+ Expect.equals(100.toBigInt, b10.exponentiate(2.toBigInt));
// Note that `unsignedRightShift` can not be used with BigInts and always
// returns a number.
- expect(toInt(t.unsignedRightShift(f)), 1);
+ Expect.equals(1, toInt(t.unsignedRightShift(f)));
final b1 = 1.toBigInt;
Expect.isTrue(b1.equals(t).toDart);
Expect.isFalse(b1.notEquals(t).toDart);
Expect.isFalse(b1.strictEquals(t).toDart);
Expect.isTrue(b1.strictNotEquals(t).toDart);
- expect(b10.and(b1), b1);
- expect(b10.or(b1), b10);
+ Expect.equals(b1, b10.and(b1));
+ Expect.equals(b10, b10.or(b1));
Expect.isFalse(b10.not.toDart);
Expect.isTrue(b10.isTruthy.toDart);
Expect.isFalse(b10.lessThan(b10).toDart);
diff --git a/tests/lib/js/static_interop_test/supertype_test.dart b/tests/lib/js/static_interop_test/supertype_test.dart
index f620f41..7b00c0d 100644
--- a/tests/lib/js/static_interop_test/supertype_test.dart
+++ b/tests/lib/js/static_interop_test/supertype_test.dart
@@ -5,9 +5,6 @@
// Test that interop classes that inherit/implement other classes have the
// appropriate static interop static errors.
-@JS()
-library supertype_test;
-
import 'package:js/js.dart';
// Base static interop class.
diff --git a/tests/lib/js/static_interop_test/supertype_transform_test.dart b/tests/lib/js/static_interop_test/supertype_transform_test.dart
index b466ca6..2c27ff3 100644
--- a/tests/lib/js/static_interop_test/supertype_transform_test.dart
+++ b/tests/lib/js/static_interop_test/supertype_transform_test.dart
@@ -2,9 +2,6 @@
// 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.
-@JS()
-library supertype_transform_test;
-
import 'dart:html';
import 'package:js/js.dart';
diff --git a/tests/lib/js/static_interop_test/top_level_member_annotation_static_test.dart b/tests/lib/js/static_interop_test/top_level_member_annotation_static_test.dart
index f6a8e20..f0813fb 100644
--- a/tests/lib/js/static_interop_test/top_level_member_annotation_static_test.dart
+++ b/tests/lib/js/static_interop_test/top_level_member_annotation_static_test.dart
@@ -5,9 +5,6 @@
// Test that top-level external members need an @JS annotation even if the
// library has one when using dart:js_interop.
-@JS()
-library top_level_member_annotation_static_test;
-
import 'dart:js_interop';
external int field;
diff --git a/tests/lib/js/static_interop_test/typed_data_test.dart b/tests/lib/js/static_interop_test/typed_data_test.dart
index 4d66062..2ef246e 100644
--- a/tests/lib/js/static_interop_test/typed_data_test.dart
+++ b/tests/lib/js/static_interop_test/typed_data_test.dart
@@ -5,9 +5,6 @@
// Test that the JS types that are intercepted by `@Native` typed_data classes
// are interoperable using static interop.
-@JS()
-library typed_data_test;
-
import 'dart:js_interop';
@JS()