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

Side by Side Diff: frog/tests/frog_native/native_class_inheritance3_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 to see if resolving a hidden native class's method to noSuchMethod
6 // interferes with subsequent resolving of the method. This might happen if the
7 // noSuchMethod is cached on Object.prototype.
8
9 class A1 native "*A1" {
10 }
11
12 class B1 extends A1 native "*B1" {
13 }
14
15 makeA1() native;
16 makeB1() native;
17
18
19 class A2 native "*A2" {
20 foo([a=99]) native;
21 }
22
23 class B2 extends A2 native "*B2" {
24 }
25
26 makeA2() native;
27 makeB2() native;
28
29 makeObject() native;
30
31 void setup() native """
32 // This code is all inside 'setup' and so not accesible from the global scope.
33 function inherits(child, parent) {
34 if (child.prototype.__proto__) {
35 child.prototype.__proto__ = parent.prototype;
36 } else {
37 function tmp() {};
38 tmp.prototype = parent.prototype;
39 child.prototype = new tmp();
40 child.prototype.constructor = child;
41 }
42 }
43 function A1(){}
44 function B1(){}
45 inherits(B1, A1);
46
47 makeA1 = function(){return new A1};
48 makeB1 = function(){return new B1};
49
50 function A2(){}
51 function B2(){}
52 inherits(B2, A2);
53 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';}
54
55 makeA2 = function(){return new A2};
56 makeB2 = function(){return new B2};
57
58 makeObject = function(){return new Object};
59 """;
60
61
62 main() {
63 setup();
64
65 var a1 = makeA1();
66 var b1 = makeB1();
67 var ob = makeObject();
68
69 // Does calling missing methods in one tree of inheritance forest affect other
70 // trees?
71 expectNoSuchMethod(() => b1.foo(), 'b1.foo()');
72 expectNoSuchMethod(() => a1.foo(), 'a1.foo()');
73 expectNoSuchMethod(() => ob.foo(), 'ob.foo()');
74
75 var a2 = makeA2();
76 var b2 = makeB2();
77
78 Expect.equals('A2.foo(99)', a2.foo());
79 Expect.equals('A2.foo(99)', b2.foo());
80 Expect.equals('A2.foo(1)', a2.foo(1));
81 Expect.equals('A2.foo(2)', b2.foo(2));
82
83
84 expectNoSuchMethod(() => b1.foo(3), 'b1.foo(3)');
85 expectNoSuchMethod(() => a1.foo(4), 'a1.foo(4)');
86 }
87
88 expectNoSuchMethod(action, note) {
89 bool caught = false;
90 try {
91 action();
92 } catch (var ex) {
93 caught = true;
94 Expect.isTrue(ex is NoSuchMethodException, note);
95 }
96 Expect.isTrue(caught, note);
97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698