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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_method_rename3_test.dart

Issue 10823423: Change dart2js_foreign suite to use metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test the feature where the native string declares the native method's name. 5 // Test the feature where the native string declares the native method's name.
6 // #3. The name does not get 6 // #3. The name does not get
7 7
8 class A native "*A" { 8 @native("*A")
9 int foo() native 'fooA'; 9 class A {
10 @native('fooA')
11 int foo();
10 } 12 }
11 13
12 class B extends A native "*B" { 14 @native("*B")
13 int foo() native 'fooB'; 15 class B extends A {
16 @native('fooB')
17 int foo();
14 int fooA() => 333; 18 int fooA() => 333;
15 } 19 }
16 20
17 class Decoy { 21 class Decoy {
18 int fooA() => 666; 22 int fooA() => 666;
19 int fooB() => 999; 23 int fooB() => 999;
20 } 24 }
21 25
22 makeA() native; 26 @native makeA();
23 makeB() native; 27 @native makeB();
24 28
25 29
26 void setup() native """ 30 @native("""
27 // This code is all inside 'setup' and so not accesible from the global scope. 31 // This code is all inside 'setup' and so not accesible from the global scope.
28 function inherits(child, parent) { 32 function inherits(child, parent) {
29 if (child.prototype.__proto__) { 33 if (child.prototype.__proto__) {
30 child.prototype.__proto__ = parent.prototype; 34 child.prototype.__proto__ = parent.prototype;
31 } else { 35 } else {
32 function tmp() {}; 36 function tmp() {};
33 tmp.prototype = parent.prototype; 37 tmp.prototype = parent.prototype;
34 child.prototype = new tmp(); 38 child.prototype = new tmp();
35 child.prototype.constructor = child; 39 child.prototype.constructor = child;
36 } 40 }
37 } 41 }
38 function A(){} 42 function A(){}
39 A.prototype.fooA = function(){return 100;}; 43 A.prototype.fooA = function(){return 100;};
40 function B(){} 44 function B(){}
41 inherits(B, A); 45 inherits(B, A);
42 B.prototype.fooB = function(){return 200;}; 46 B.prototype.fooB = function(){return 200;};
43 47
44 makeA = function(){return new A}; 48 makeA = function(){return new A};
45 makeB = function(){return new B}; 49 makeB = function(){return new B};
46 """; 50 """)
51 void setup();
47 52
48 testDynamic() { 53 testDynamic() {
49 var things = [makeA(), makeB(), new Decoy()]; 54 var things = [makeA(), makeB(), new Decoy()];
50 var a = things[0]; 55 var a = things[0];
51 var b = things[1]; 56 var b = things[1];
52 var d = things[2]; 57 var d = things[2];
53 58
54 Expect.equals(100, a.foo()); 59 Expect.equals(100, a.foo());
55 Expect.equals(200, b.foo()); 60 Expect.equals(200, b.foo());
56 Expect.equals(666, d.fooA()); 61 Expect.equals(666, d.fooA());
(...skipping 27 matching lines...) Expand all
84 expectNoSuchMethod(action, note) { 89 expectNoSuchMethod(action, note) {
85 bool caught = false; 90 bool caught = false;
86 try { 91 try {
87 action(); 92 action();
88 } catch (NoSuchMethodException ex) { 93 } catch (NoSuchMethodException ex) {
89 caught = true; 94 caught = true;
90 Expect.isTrue(ex is NoSuchMethodException, note); 95 Expect.isTrue(ex is NoSuchMethodException, note);
91 } 96 }
92 Expect.isTrue(caught, note); 97 Expect.isTrue(caught, note);
93 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698