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

Side by Side Diff: tests/compiler/dart2js_native/native_no_such_method_exception2_frog_test.dart

Issue 2984403002: dart2js_native tests: Migrate 'native STRING' to JS-calls (Closed)
Patch Set: the rest of the files Created 3 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 import "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 @Native("A") 7 @Native("A")
8 class A {} 8 class A {}
9 9
10 @Native("B") 10 @Native("B")
11 class B extends A { 11 class B extends A {
12 foo() native; 12 foo() native;
13 } 13 }
14 14
15 makeA() native; 15 makeA() native;
16 makeB() native; 16 makeB() native;
17 17
18 setup() native """ 18 setup() {
19 function inherits(child, parent) { 19 JS('', r"""
20 if (child.prototype.__proto__) { 20 (function(){
21 child.prototype.__proto__ = parent.prototype; 21 function inherits(child, parent) {
22 } else { 22 if (child.prototype.__proto__) {
23 function tmp() {}; 23 child.prototype.__proto__ = parent.prototype;
24 tmp.prototype = parent.prototype; 24 } else {
25 child.prototype = new tmp(); 25 function tmp() {};
26 child.prototype.constructor = child; 26 tmp.prototype = parent.prototype;
27 child.prototype = new tmp();
28 child.prototype.constructor = child;
29 }
27 } 30 }
31 function A() {}
32 function B() {}
33 inherits(B, A);
34 makeA = function() { return new A() };
35 makeB = function() { return new B() };
36 B.prototype.foo = function() { return 42; };
37
38 self.nativeConstructor(A);
39 self.nativeConstructor(B);
40 })()""");
28 } 41 }
29 function A() {}
30 function B() {}
31 inherits(B, A);
32 makeA = function() { return new A; }
33 makeB = function() { return new B; }
34 B.prototype.foo = function() { return 42; }
35
36 self.nativeConstructor(A);
37 self.nativeConstructor(B);
38 """;
39 42
40 main() { 43 main() {
41 nativeTesting(); 44 nativeTesting();
42 setup(); 45 setup();
43 var a = makeA(); 46 var a = makeA();
44 var exception; 47 var exception;
45 try { 48 try {
46 a.foo(); 49 a.foo();
47 } on NoSuchMethodError catch (e) { 50 } on NoSuchMethodError catch (e) {
48 exception = e; 51 exception = e;
49 } 52 }
50 Expect.isNotNull(exception); 53 Expect.isNotNull(exception);
51 54
52 var b = makeB(); 55 var b = makeB();
53 Expect.equals(42, b.foo()); 56 Expect.equals(42, b.foo());
54 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698