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

Unified Diff: tests/compiler/dart2js_native/runtimetype_test.dart

Issue 14049034: Revert "Revert "Fix x.runtimeType for native classes"" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
Index: tests/compiler/dart2js_native/runtimetype_test.dart
diff --git a/tests/compiler/dart2js_native/runtimetype_test.dart b/tests/compiler/dart2js_native/runtimetype_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..dc8d7a4d5b9e34a7d5733ccffdbdc91e4cf234c6
--- /dev/null
+++ b/tests/compiler/dart2js_native/runtimetype_test.dart
@@ -0,0 +1,65 @@
+// 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.
+
+import "package:expect/expect.dart";
+import 'dart:_foreign_helper' show JS;
+
+// Test to see runtimeType works on native classes and does not use the native
+// constructor name.
+
+class A native "TAGX" {
+}
+
+class B extends A native "TAGY" {
+}
+
+makeA() native;
+makeB() native;
+
+void setup() native """
+// This code is all inside 'setup' and so not accesible from the global scope.
+function inherits(child, parent) {
+ function tmp() {};
+ tmp.prototype = parent.prototype;
+ child.prototype = new tmp();
+ child.prototype.constructor = child;
+}
+
+function TAGX(){}
+function TAGY(){}
+inherits(TAGY, TAGX);
+
+makeA = function(){return new TAGX};
+makeB = function(){return new TAGY};
+""";
+
+
+testDynamicContext() {
+ var a = makeA();
+ var b = makeB();
+
+ var aT = a.runtimeType;
+ var bT = b.runtimeType;
+
+ Expect.notEquals('TAGX', '$aT');
+ Expect.notEquals('TAGY', '$bT');
+}
+
+testStaticContext() {
+ var a = JS('A', '#', makeA()); // Force compiler to know type.
+ var b = JS('B', '#', makeB());
+
+ var aT = a.runtimeType;
+ var bT = b.runtimeType;
+
+ Expect.notEquals('TAGX', '$aT');
+ Expect.notEquals('TAGY', '$bT');
+}
+
+main() {
+ setup();
+
+ testDynamicContext();
+ testStaticContext();
+}
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/resolution/members.dart ('k') | tests/utils/dummy_compiler_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698