dart-sdk/tests/lib/html/js_typed_interop_default_arg_test.dart
Srujan Gaddam 114752421d [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 <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-04-08 20:05:36 +00:00

46 lines
940 B
Dart

// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// 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_typed_interop_test;
import 'dart:html';
import 'package:js/js.dart';
import 'package:expect/minitest.dart';
_injectJs() {
document.body!.append(new ScriptElement()
..type = 'text/javascript'
..innerHtml = r"""
var Foo = {
get42: function(b) { return arguments.length >= 1 ? b : 42; }
};
""");
}
@JS()
class Foo {
external static num get42([num? b]);
}
main() {
_injectJs();
test('call directly from dart', () {
expect(Foo.get42(2), 2);
expect(Foo.get42(), 42);
});
test('call tearoff from dart with arg', () {
var f = Foo.get42;
expect(f(2), 2);
});
test('call tearoff from dart with no arg', () {
var f = Foo.get42;
expect(f(), 42);
});
}