Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1147524

Browse files
srujzscommit-bot@chromium.org
authored andcommitted
[dart:html] Remove multitest usage in some js tests
Multitest usage that didn't involve separating out failures is removed. Static errors are changed to static error tests. Change-Id: I81d7409ead0005b9788ac80d229ac534279f1658 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142543 Commit-Queue: Srujan Gaddam <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]> Reviewed-by: Bob Nystrom <[email protected]>
1 parent ff9731d commit 1147524

8 files changed

+100
-34
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@JS()
6+
library js_typed_interop_test;
7+
8+
import 'dart:html';
9+
10+
import 'package:js/js.dart';
11+
import 'package:expect/minitest.dart';
12+
13+
_injectJs() {
14+
document.body!.append(new ScriptElement()
15+
..type = 'text/javascript'
16+
..innerHtml = r"""
17+
var Foo = {
18+
get42: function(b) { return arguments.length >= 1 ? b : 42; }
19+
};
20+
""");
21+
}
22+
23+
@JS()
24+
class Foo {
25+
external static num get42([num? b = 3
26+
// TODO(41375): This should be a static error. It's invalid to have a
27+
// default value.
28+
]);
29+
}
30+
31+
main() {
32+
_injectJs();
33+
34+
test('call tearoff from dart with default', () {
35+
var f = Foo.get42;
36+
// Note: today both SSA and CPS remove the extra argument on static calls,
37+
// but they fail to do so on tearoffs.
38+
expect(f(), 3);
39+
// TODO(41375): Remove this once the above is resolved. This is temporary
40+
// to track this test failure.
41+
throw ("This test should not execute. It should fail to compile above.");
42+
});
43+
}

tests/lib/html/js_typed_interop_default_arg_test.dart

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ _injectJs() {
1515
..type = 'text/javascript'
1616
..innerHtml = r"""
1717
var Foo = {
18-
get42: function(b) { return arguments.length >= 1 ? b : 42; },
19-
get43: function(b) { return arguments.length >= 1 ? b : 43; }
18+
get42: function(b) { return arguments.length >= 1 ? b : 42; }
2019
};
2120
""");
2221
}
2322

2423
@JS()
2524
class Foo {
26-
// Note: it's invalid to provide a default value.
27-
external static num get42([num? b
28-
= 3 // //# default_value: compile-time error
29-
]);
30-
external static num get43([num? b]);
25+
external static num get42([num? b]);
3126
}
3227

3328
main() {
@@ -40,16 +35,11 @@ main() {
4035

4136
test('call tearoff from dart with arg', () {
4237
var f = Foo.get42;
43-
expect(f(2), 2); //# explicit_argument: ok
38+
expect(f(2), 2);
4439
});
4540

46-
test('call tearoff from dart with default', () {
41+
test('call tearoff from dart with no arg', () {
4742
var f = Foo.get42;
48-
// Note: today both SSA and CPS remove the extra argument on static calls,
49-
// but they fail to do so on tearoffs.
50-
expect(f(), 3); //# default_value: continued
51-
52-
f = Foo.get43;
53-
expect(f(), 43);
43+
expect(f(), 42);
5444
});
5545
}

tests/lib/html/js_typed_interop_type1_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ main() {
4949
var f = new F(6);
5050

5151
Expect.equals(testA(a), 1);
52-
Expect.equals(testF(f), 6); //# 01: ok
52+
Expect.equals(testF(f), 6);
5353
}

tests/lib/html/js_typed_interop_type2_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ main() {
4545
dynamic d = new D(foo: 4);
4646
var f = new F(6);
4747
Expect.equals(testC(d), 4);
48-
Expect.equals(testF(f), 6); //# 01: ok
48+
Expect.equals(testF(f), 6);
4949
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
@JS()
6+
library js_typed_interop_test;
7+
8+
import 'dart:html';
9+
10+
import 'package:js/js.dart';
11+
import 'package:expect/minitest.dart';
12+
13+
_injectJs() {
14+
document.body.append(new ScriptElement()
15+
..type = 'text/javascript'
16+
..innerHtml = r"""
17+
var Foo = {
18+
get42: function(b) { return arguments.length >= 1 ? b : 42; }
19+
};
20+
""");
21+
}
22+
23+
@JS()
24+
class Foo {
25+
external static num get42([num b = 3
26+
// TODO(41375): This should be a static error. It's invalid to have a
27+
// default value.
28+
]);
29+
}
30+
31+
main() {
32+
_injectJs();
33+
34+
test('call tearoff from dart with default', () {
35+
var f = Foo.get42;
36+
// Note: today both SSA and CPS remove the extra argument on static calls,
37+
// but they fail to do so on tearoffs.
38+
expect(f(), 3);
39+
// TODO(41375): Remove this once the above is resolved. This is temporary
40+
// to track this test failure.
41+
throw ("This test should not execute. It should fail to compile above.");
42+
});
43+
}

tests/lib_2/html/js_typed_interop_default_arg_test.dart

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,14 @@ _injectJs() {
1515
..type = 'text/javascript'
1616
..innerHtml = r"""
1717
var Foo = {
18-
get42: function(b) { return arguments.length >= 1 ? b : 42; },
19-
get43: function(b) { return arguments.length >= 1 ? b : 43; }
18+
get42: function(b) { return arguments.length >= 1 ? b : 42; }
2019
};
2120
""");
2221
}
2322

2423
@JS()
2524
class Foo {
26-
// Note: it's invalid to provide a default value.
27-
external static num get42([num b
28-
= 3 // //# default_value: compile-time error
29-
]);
30-
external static num get43([num b]);
25+
external static num get42([num b]);
3126
}
3227

3328
main() {
@@ -40,16 +35,11 @@ main() {
4035

4136
test('call tearoff from dart with arg', () {
4237
var f = Foo.get42;
43-
expect(f(2), 2); //# explicit_argument: ok
38+
expect(f(2), 2);
4439
});
4540

46-
test('call tearoff from dart with default', () {
41+
test('call tearoff from dart with no arg', () {
4742
var f = Foo.get42;
48-
// Note: today both SSA and CPS remove the extra argument on static calls,
49-
// but they fail to do so on tearoffs.
50-
expect(f(), 3); //# default_value: continued
51-
52-
f = Foo.get43;
53-
expect(f(), 43);
43+
expect(f(), 42);
5444
});
5545
}

tests/lib_2/html/js_typed_interop_type1_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ main() {
4545
var f = new F(6);
4646

4747
Expect.equals(testA(a), 1);
48-
Expect.equals(testF(f), 6); //# 01: ok
48+
Expect.equals(testF(f), 6);
4949
}

tests/lib_2/html/js_typed_interop_type2_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ main() {
4141
dynamic d = new D(foo: 4);
4242
var f = new F(6);
4343
Expect.equals(testC(d), 4);
44-
Expect.equals(testF(f), 6); //# 01: ok
44+
Expect.equals(testF(f), 6);
4545
}

0 commit comments

Comments
 (0)