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

Side by Side Diff: tests/language/src/NativeNamedConstructors1FrogTest.dart

Issue 8985010: Move tests using frog 'native' extension from tests/language to frog/tests (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #library('X');
6 #native('NativeNamedConstructors1FrogTest.js'); // Defines JS constructor 'A'.
7
8 // The native class has several constructors which partition the behaviour of
9 // the JS constructor function into several well-typed Dart constructors.
10
11 class A native "A" {
12
13 // factory constructors allow us to do computation ahead of the allocation.
14 factory A(int len) { return _construct(len); }
15
16 factory A.fromString(String s) {
17 return _construct(s.length); // convert string to int.
18 }
19
20 // Helper that does the actual allocation and construction.
21 static A _construct(v) native @'return new A(v);';
22
23 foo() native 'return this._x;';
24 }
25
26 main() {
27 var a1 = new A(100);
28 var a2 = new A.fromString('Hello');
29
30 Expect.equals(100, a1.foo());
31 Expect.equals(5, a2.foo());
32 }
OLDNEW
« no previous file with comments | « tests/language/src/NativeLibrarySameNameUsedLib2.dart ('k') | tests/language/src/NativeNamedConstructors1FrogTest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698