[dartdevc] add unit test for subtyping op

Change-Id: I704e7b566fe76fa320c68eadd89611517c3641af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/107446
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Vijay Menon <vsm@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
diff --git a/tests/compiler/dartdevc_native/subtype_test.dart b/tests/compiler/dartdevc_native/subtype_test.dart
new file mode 100644
index 0000000..4a14499
--- /dev/null
+++ b/tests/compiler/dartdevc_native/subtype_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2019, 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.
+
+import "package:expect/expect.dart";
+import 'dart:_foreign_helper' show JS;
+import 'dart:_runtime' as dart;
+
+class A {}
+
+class B extends A {}
+
+class C extends B {}
+
+class D<T extends B> {}
+
+// Returns sWrapped<tWrapped> as a wrapped type.
+Object generic1(Type sWrapped, Type tWrapped) {
+  var s = dart.unwrapType(sWrapped);
+  var t = dart.unwrapType(tWrapped);
+  var sGeneric = dart.getGenericClass(s);
+  return dart.wrapType(JS('', '#(#)', sGeneric, t));
+}
+
+void checkSubtype(Type sWrapped, Type tWrapped) {
+  var s = dart.unwrapType(sWrapped);
+  var t = dart.unwrapType(tWrapped);
+  Expect.isTrue(dart.isSubtypeOf(s, t));
+}
+
+void checkProperSubtype(Type sWrapped, Type tWrapped) {
+  var s = dart.unwrapType(sWrapped);
+  var t = dart.unwrapType(tWrapped);
+  Expect.isTrue(dart.isSubtypeOf(s, t));
+  Expect.isFalse(dart.isSubtypeOf(t, s));
+}
+
+void main() {
+  checkProperSubtype(B, A);
+  checkProperSubtype(C, B);
+  checkProperSubtype(C, A);
+
+  checkSubtype(D, generic1(D, B));
+  checkSubtype(generic1(D, B), D);
+  checkProperSubtype(generic1(D, C), generic1(D, B));
+}