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

Side by Side Diff: frog/tests/frog_native/native_method_rename1_frog_test.dart

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

Powered by Google App Engine
This is Rietveld 408576698