dart-sdk/tests/lib_2/js/instanceof_test.dart
Sigmund Cherem 795c0b1b64 [ddc, dart2js] Fix signature of js_util APIs expecting a constructor.
Since JavaScript constructor functions are not valid Dart functions,
they should not be expected to have a Function type.

For context see: https://github.com/dart-lang/sdk/issues/41259

Change-Id: I9092700ad60712f604cec7e5cf0189b23024839a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142321
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2020-04-03 04:54:56 +00:00

30 lines
660 B
Dart

// Copyright (c) 2020, 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 instanceof_test;
import 'package:js/js.dart';
import 'package:expect/expect.dart';
import 'dart:js_util';
@JS()
external void eval(String code);
@JS('Class')
class Class {
external Class();
external Constructor get constructor;
}
@JS()
class Constructor {}
void main() {
eval("self.Class = function Class() {}");
var o = new Class();
var constructor = o.constructor;
Expect.isTrue(instanceof(o, constructor));
}