mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
114752421d
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>
46 lines
940 B
Dart
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);
|
|
});
|
|
}
|