Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Unified Diff: tests/html/js_typed_interop_type3_test.dart

Issue 2307883002: Fix type masks for js-interop types. (Closed)
Patch Set: Update status Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/js_typed_interop_type2_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/js_typed_interop_type3_test.dart
diff --git a/tests/html/js_typed_interop_type3_test.dart b/tests/html/js_typed_interop_type3_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f20bc2077695787b79d12b5ee25fd0457d66b627
--- /dev/null
+++ b/tests/html/js_typed_interop_type3_test.dart
@@ -0,0 +1,87 @@
+import 'dart:html';
+import 'package:js/js.dart';
+import 'package:expect/expect.dart';
+
+@JS()
+class A {
+ external get foo;
+
+ external A(var foo);
+}
+
+@JS()
+@anonymous
+class C {
+ final foo;
+
+ external factory C({foo});
+}
+
+@JS()
+@anonymous
+class D {
+ final foo;
+
+ external factory D({foo});
+}
+
+class F {
+ final foo;
+
+ F(this.foo);
+}
+
+@NoInline()
+testA(A o) {
+ return o.foo;
+}
+
+@NoInline()
+testC(C o) {
+ return o.foo;
+}
+
+
+@NoInline()
+testD(D o) {
+ return o.foo;
+}
+
+@NoInline()
+testF(F o) {
+ return o.foo;
+}
+
+
+_injectJs() {
+ document.body.append(new ScriptElement()
+ ..type = 'text/javascript'
+ ..innerHtml = r"""
+function A(foo) {
+ this.foo = foo;
+}
+""");
+}
+
+void expectValueOrTypeError(f(), value) {
+ try {
+ String i = 0; // Test for checked mode.
+ Expect.equals(f(), value);
+ } on TypeError catch (error) {
+ Expect.throws(f, (ex) => ex is TypeError);
+ }
+}
+
+main() {
+ _injectJs();
+
+ var a = new A(1);
+ var d = new D(foo: 4);
+
+ Expect.equals(testA(a), 1); /// 01: ok
+ Expect.equals(testA(a), 1); /// 02: ok
+ Expect.equals(testA(d), 4);
+ Expect.equals(testD(d), 4); /// 02: continued
+}
+
+
« no previous file with comments | « tests/html/js_typed_interop_type2_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698