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

Unified Diff: tests/language/type_promotion_parameter_test.dart

Issue 26232003: Support type promotion in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated to latest spec change Created 7 years, 2 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/language/type_promotion_multiple_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/type_promotion_parameter_test.dart
diff --git a/tests/language/type_promotion_parameter_test.dart b/tests/language/type_promotion_parameter_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b390ede076b05cdaa03314fcf94981998c532139
--- /dev/null
+++ b/tests/language/type_promotion_parameter_test.dart
@@ -0,0 +1,197 @@
+// Copyright (c) 2013, 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.
+
+// Test type promotion of parameters.
+
+class A {
+ var a = "a";
+}
+class B extends A {
+ var b = "b";
+}
+class C extends B {
+ var c = "c";
+}
+class D extends A {
+ var d = "d";
+}
+class E implements C, D {
+ var a = "";
+ var b = "";
+ var c = "";
+ var d = "";
+}
+
+void main() {
+ test(new E());
+}
+void test(A a) {
+ print(a.a);
+ print(a.b); /// 01: static type warning
+ print(a.c); /// 02: static type warning
+ print(a.d); /// 03: static type warning
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c); /// 04: static type warning
+ print(a.d); /// 05: static type warning
+
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 06: static type warning
+ }
+
+ print(a.a);
+ print(a.b);
+ print(a.c); /// 07: static type warning
+ print(a.d); /// 08: static type warning
+ }
+ if (a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 09: static type warning
+
+ if (a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 10: static type warning
+ }
+ if (a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 11: static type warning
+ }
+
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 12: static type warning
+ }
+
+ print(a.a);
+ print(a.b); /// 13: static type warning
+ print(a.c); /// 14: static type warning
+ print(a.d); /// 15: static type warning
+
+ if (a is D) {
+ print(a.a);
+ print(a.b); /// 16: static type warning
+ print(a.c); /// 17: static type warning
+ print(a.d);
+ }
+
+ print(a.a);
+ print(a.b); /// 18: static type warning
+ print(a.c); /// 19: static type warning
+ print(a.d); /// 20: static type warning
+
+ var o1 = a is B ?
+ '${a.a}'
+ '${a.b}'
+ '${a.c}' /// 21: static type warning
+ '${a.d}' /// 22: static type warning
+ :
+ '${a.a}'
+ '${a.b}' /// 23: static type warning
+ '${a.c}' /// 24: static type warning
+ '${a.d}' /// 25: static type warning
+ ;
+
+ var o2 = a is C ?
+ '${a.a}'
+ '${a.b}'
+ '${a.c}'
+ '${a.d}' /// 26: static type warning
+ :
+ '${a.a}'
+ '${a.b}' /// 27: static type warning
+ '${a.c}' /// 28: static type warning
+ '${a.d}' /// 29: static type warning
+ ;
+
+ var o3 = a is D ?
+ '${a.a}'
+ '${a.b}' /// 30: static type warning
+ '${a.c}' /// 31: static type warning
+ '${a.d}'
+ :
+ '${a.a}'
+ '${a.b}' /// 32: static type warning
+ '${a.c}' /// 33: static type warning
+ '${a.d}' /// 34: static type warning
+ ;
+
+ if (a is B && a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c); /// 35: static type warning
+ print(a.d); /// 36: static type warning
+ }
+ if (a is B && a is C) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 37: static type warning
+ }
+ if (a is C && a is B) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 38: static type warning
+ }
+ if (a is C && a is D) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 39: static type warning
+ }
+ if (a is D && a is C) {
+ print(a.a);
+ print(a.b); /// 40: static type warning
+ print(a.c); /// 41: static type warning
+ print(a.d);
+ }
+ if (a is D
+ && a.a == ""
+ && a.b == "" /// 42: static type warning
+ && a.c == "" /// 43: static type warning
+ && a.d == "") {
+ print(a.a);
+ print(a.b); /// 44: static type warning
+ print(a.c); /// 45: static type warning
+ print(a.d);
+ }
+ if (a.a == ""
+ && a.b == "" /// 46: static type warning
+ && a.c == "" /// 47: static type warning
+ && a.d == "" /// 48: static type warning
+ && a is B
+ && a.a == ""
+ && a.b == ""
+ && a.c == "" /// 49: static type warning
+ && a.d == "" /// 50: static type warning
+ && a is C
+ && a.a == ""
+ && a.b == ""
+ && a.c == ""
+ && a.d == "" /// 51: static type warning
+ ) {
+ print(a.a);
+ print(a.b);
+ print(a.c);
+ print(a.d); /// 52: static type warning
+ }
+ if ((a is B)) {
+ print(a.a);
+ print(a.b); /// 53: static type warning
+ print(a.c); /// 54: static type warning
+ print(a.d); /// 55: static type warning
+ }
+}
« no previous file with comments | « tests/language/type_promotion_multiple_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698