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

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

Issue 23477028: Remove dart2js_foreign. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 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
(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 // Test the feature where the native string declares the native method's name.
6
7 import "package:expect/expect.dart";
8 import 'native_metadata.dart';
9
10 @Native("*A")
11 class A {
12 @Native('fooA') int foo();
13 @Native('barA') int bar();
14 @Native('bazA') int baz();
15 }
16
17 @native A makeA();
18
19 class B {
20 int bar([x]) => 800;
21 int baz() => 900;
22 }
23
24 @Native("""
25 // This code is all inside 'setup' and so not accesible from the global scope.
26 function A(){}
27 A.prototype.fooA = function(){return 100;};
28 A.prototype.barA = function(){return 200;};
29 A.prototype.bazA = function(){return 300;};
30
31 makeA = function(){return new A};
32 """)
33 void setup();
34
35
36 testDynamic() {
37 setup();
38
39 var things = [makeA(), new B()];
40 var a = things[0];
41 var b = things[1];
42
43 Expect.equals(100, a.foo());
44 Expect.equals(200, a.bar());
45 Expect.equals(300, a.baz());
46 Expect.equals(800, b.bar());
47 Expect.equals(900, b.baz());
48 }
49
50 testTyped() {
51 A a = makeA();
52 B b = new B();
53
54 Expect.equals(100, a.foo());
55 Expect.equals(200, a.bar());
56 Expect.equals(300, a.baz());
57 Expect.equals(800, b.bar());
58 Expect.equals(900, b.baz());
59 }
60
61 main() {
62 setup();
63 testDynamic();
64 testTyped();
65 }
66
67 expectNoSuchMethod(action, note) {
68 bool caught = false;
69 try {
70 action();
71 } catch (ex) {
72 caught = true;
73 Expect.isTrue(ex is NoSuchMethodError, note);
74 }
75 Expect.isTrue(caught, note);
76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698