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

Side by Side Diff: dart/tests/compiler/dart2js_foreign/native_method_rename2_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 6
7 class A native "*A" { 7 @native("*A")
8 int foo() native 'fooA'; 8 class A {
9 @native('fooA')
10 int foo();
9 } 11 }
10 12
11 class B extends A native "*B" { 13 @native("*B")
12 int foo() native 'fooB'; 14 class B extends A {
15 @native('fooB')
16 int foo();
13 } 17 }
14 18
15 makeA() native; 19 @native makeA();
16 makeB() native; 20 @native makeB();
17 21
18 void setup() native """ 22 @native("""
19 // This code is all inside 'setup' and so not accesible from the global scope. 23 // This code is all inside 'setup' and so not accesible from the global scope.
20 function inherits(child, parent) { 24 function inherits(child, parent) {
21 if (child.prototype.__proto__) { 25 if (child.prototype.__proto__) {
22 child.prototype.__proto__ = parent.prototype; 26 child.prototype.__proto__ = parent.prototype;
23 } else { 27 } else {
24 function tmp() {}; 28 function tmp() {};
25 tmp.prototype = parent.prototype; 29 tmp.prototype = parent.prototype;
26 child.prototype = new tmp(); 30 child.prototype = new tmp();
27 child.prototype.constructor = child; 31 child.prototype.constructor = child;
28 } 32 }
29 } 33 }
30 function A(){} 34 function A(){}
31 A.prototype.fooA = function(){return 100;}; 35 A.prototype.fooA = function(){return 100;};
32 function B(){} 36 function B(){}
33 inherits(B, A); 37 inherits(B, A);
34 B.prototype.fooB = function(){return 200;}; 38 B.prototype.fooB = function(){return 200;};
35 39
36 makeA = function(){return new A}; 40 makeA = function(){return new A};
37 makeB = function(){return new B}; 41 makeB = function(){return new B};
38 """; 42 """)
43 void setup();
39 44
40 testDynamic() { 45 testDynamic() {
41 var things = [makeA(), makeB()]; 46 var things = [makeA(), makeB()];
42 var a = things[0]; 47 var a = things[0];
43 var b = things[1]; 48 var b = things[1];
44 49
45 Expect.equals(100, a.foo()); 50 Expect.equals(100, a.foo());
46 Expect.equals(200, b.foo()); 51 Expect.equals(200, b.foo());
47 52
48 expectNoSuchMethod((){ a.fooA(); }, 'fooA should be invisible on A'); 53 expectNoSuchMethod((){ a.fooA(); }, 'fooA should be invisible on A');
(...skipping 21 matching lines...) Expand all
70 expectNoSuchMethod(action, note) { 75 expectNoSuchMethod(action, note) {
71 bool caught = false; 76 bool caught = false;
72 try { 77 try {
73 action(); 78 action();
74 } catch (var ex) { 79 } catch (var ex) {
75 caught = true; 80 caught = true;
76 Expect.isTrue(ex is NoSuchMethodException, note); 81 Expect.isTrue(ex is NoSuchMethodException, note);
77 } 82 }
78 Expect.isTrue(caught, note); 83 Expect.isTrue(caught, note);
79 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698