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

Unified Diff: tests/language/src/NativeNamedConstructors2FrogTest.dart

Issue 8894027: Add test for static methods and named constructors on hidden native class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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/language.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/src/NativeNamedConstructors2FrogTest.dart
diff --git a/tests/language/src/NativeNamedConstructors2FrogTest.dart b/tests/language/src/NativeNamedConstructors2FrogTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..685949323eb5a56a39e3b17940a6edac57634161
--- /dev/null
+++ b/tests/language/src/NativeNamedConstructors2FrogTest.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2011, 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.
+
+// Hidden native class wwith named constructors and static methods.
+
+
+class A native "*A" {
+
+ factory A(int len) => _construct(len);
+
+ factory A.fromString(String s) => _construct(s.length);
+
+ factory A.nativeConstructor(int a, int b) native @'return makeA(a+b);';
+
+ static A _construct(v) { return makeA(v); }
+
+ foo() native 'return this._x;';
+}
+
+makeA(v) native;
+
+void setup() native """
+// This code is all inside 'setup' and so not accesible from the global scope.
+function A(arg) { this._x = arg; }
+makeA = function(arg) { return new A(arg); }
+""";
+
+main() {
+ setup();
+ var a1 = new A(100);
+ var a2 = new A.fromString('Hello');
+ var a3 = new A.nativeConstructor(100, 2);
+
+ Expect.equals(100, a1.foo());
+ Expect.equals(5, a2.foo());
+ Expect.equals(102, a3.foo());
+}
« no previous file with comments | « tests/language/language.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698