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

Side by Side Diff: tests/language/src/NativeClassInheritance3FrogTest.dart

Issue 8985010: Move tests using frog 'native' extension from tests/language to frog/tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 foo() native;
11 }
12
13 class B1 extends A1 native "*B1" {
14 }
15
16 makeA1() native;
17 makeB1() native;
18
19
20 class A2 native "*A2" {
21 foo([a=99]) native;
22 }
23
24 class B2 extends A2 native "*B2" {
25 }
26
27 makeA2() native;
28 makeB2() native;
29
30 makeObject() native;
31
32 void setup() native """
33 // This code is all inside 'setup' and so not accesible from the global scope.
34 function inherits(child, parent) {
35 if (child.prototype.__proto__) {
36 child.prototype.__proto__ = parent.prototype;
37 } else {
38 function tmp() {};
39 tmp.prototype = parent.prototype;
40 child.prototype = new tmp();
41 child.prototype.constructor = child;
42 }
43 }
44 function A1(){}
45 function B1(){}
46 inherits(B1, A1);
47
48 makeA1 = function(){return new A1};
49 makeB1 = function(){return new B1};
50
51 function A2(){}
52 function B2(){}
53 inherits(B2, A2);
54 A2.prototype.foo = function(a){return 'A2.foo(' + a + ')';}
55
56 makeA2 = function(){return new A2};
57 makeB2 = function(){return new B2};
58
59 makeObject = function(){return new Object};
60 """;
61
62
63 main() {
64 setup();
65
66 var a1 = makeA1();
67 var b1 = makeB1();
68 var ob = makeObject();
69
70 // Does calling missing methods in one tree of inheritance forest affect other
71 // trees?
72 expectNoSuchMethod(() => b1.foo(), 'b1.foo()');
73 expectNoSuchMethod(() => a1.foo(), 'a1.foo()');
74 expectNoSuchMethod(() => ob.foo(), 'ob.foo()');
75
76 var a2 = makeA2();
77 var b2 = makeB2();
78
79 Expect.equals('A2.foo(99)', a2.foo());
80 Expect.equals('A2.foo(99)', b2.foo());
81 Expect.equals('A2.foo(1)', a2.foo(1));
82 Expect.equals('A2.foo(2)', b2.foo(2));
83
84
85 expectNoSuchMethod(() => b1.foo(3), 'b1.foo(3)');
86 expectNoSuchMethod(() => a1.foo(4), 'a1.foo(4)');
87 }
88
89 expectNoSuchMethod(action, note) {
90 bool caught = false;
91 try {
92 action();
93 } catch (var ex) {
94 caught = true;
95 Expect.isTrue(ex is NoSuchMethodException, note);
96 }
97 Expect.isTrue(caught, note);
98 }
OLDNEW
« no previous file with comments | « tests/language/src/NativeClassInheritance2FrogTest.dart ('k') | tests/language/src/NativeClassIsCheck1FrogTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698