Skip to content

Commit d43dd08

Browse files
joshualittCommit Queue
authored and
Commit Queue
committed
[dart2wasm] Add regression test for js interop method rename.
Change-Id: I90867d6a3d14e0fb8c2fdbe94ae1390af0544ffd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267880 Commit-Queue: Joshua Litt <[email protected]> Reviewed-by: Srujan Gaddam <[email protected]>
1 parent 24ffc88 commit d43dd08

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/web/wasm/static_interop_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,22 @@ extension StaticJSClassMethods on StaticJSClass {
2828
external String doSumUpTo2([String? a, String? b]);
2929
external String doSum1Or2NonNull(String a, [String b = 'bar']);
3030
external String doSumUpTo2NonNull([String a = 'foo', String b = 'bar']);
31+
32+
@JS('nameInJSMethod')
33+
external String nameInDartMethod(String a, String b);
34+
@JS('nameInJSGetter')
35+
external String get nameInDartGetter;
36+
@JS('nameInJSSetter')
37+
external set nameInDartSetter(String v);
38+
external String get nameInJSSetter;
3139
}
3240

3341
void createClassTest() {
3442
eval(r'''
3543
globalThis.JSClass = function(foo) {
3644
this.foo = foo;
3745
this.nonNullableInt = 6;
46+
this.nameInJSGetter = 'foo';
3847
this.nonNullableIntReturnMethod = function() {
3948
return 7;
4049
}
@@ -65,6 +74,9 @@ void createClassTest() {
6574
this.doSumUpTo2NonNull = function(a, b) {
6675
return a + b;
6776
}
77+
this.nameInJSMethod = function(a, b) {
78+
return a + b;
79+
}
6880
}
6981
''');
7082
final foo = StaticJSClass.factory('foo');
@@ -96,6 +108,11 @@ void createClassTest() {
96108
Expect.equals('foobar', foo.doSumUpTo2NonNull());
97109
Expect.equals('foobar', foo.doSumUpTo2NonNull('foo'));
98110
Expect.equals('foobar', foo.doSumUpTo2NonNull('foo', 'bar'));
111+
112+
Expect.equals('foobar', foo.nameInDartMethod('foo', 'bar'));
113+
Expect.equals('foo', foo.nameInDartGetter);
114+
foo.nameInDartSetter = 'boo';
115+
Expect.equals('boo', foo.nameInJSSetter);
99116
}
100117

101118
@JS('JSClass.NestedJSClass')

0 commit comments

Comments
 (0)