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

Side by Side Diff: tests/compiler/dart2js_native/native_method_rename1_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) 2011, the Dart project authors. Please see the AUTHORS file 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 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 // Test the feature where the native string declares the native method's name. 5 // Test the feature where the native string declares the native method's name.
6 6
7 import 'native_testing.dart'; 7 import 'native_testing.dart';
8 import 'dart:_js_helper' show Native, JSName; 8 import 'dart:_js_helper' show Native, JSName;
9 9
10 @Native("A") 10 @Native("A")
11 class A { 11 class A {
12 @JSName('fooA') 12 @JSName('fooA')
13 int foo() native; 13 int foo() native;
14 14
15 @JSName('barA') 15 @JSName('barA')
16 int bar() native; 16 int bar() native;
17 17
18 @JSName('bazA') 18 @JSName('bazA')
19 int baz() native; 19 int baz() native;
20 } 20 }
21 21
22 A makeA() native; 22 A makeA() native;
23 23
24 class B { 24 class B {
25 int bar([x]) => 800; 25 int bar([x]) => 800;
26 int baz() => 900; 26 int baz() => 900;
27 } 27 }
28 28
29 void setup() native """ 29 void setup() {
30 // This code is all inside 'setup' and so not accessible from the global scope. 30 JS('', r"""
31 function A(){} 31 (function(){
32 A.prototype.fooA = function(){return 100;}; 32 // This code is inside 'setup' and so not accessible from the global scope.
33 A.prototype.barA = function(){return 200;}; 33 function A(){}
34 A.prototype.bazA = function(){return 300;}; 34 A.prototype.fooA = function(){return 100;};
35 A.prototype.barA = function(){return 200;};
36 A.prototype.bazA = function(){return 300;};
35 37
36 makeA = function(){return new A}; 38 makeA = function(){return new A()};
37 39
38 self.nativeConstructor(A); 40 self.nativeConstructor(A);
39 """; 41 })()""");
42 }
40 43
41 testDynamic() { 44 testDynamic() {
42 var a = confuse(makeA()); 45 var a = confuse(makeA());
43 var b = confuse(new B()); 46 var b = confuse(new B());
44 47
45 Expect.equals(100, a.foo()); 48 Expect.equals(100, a.foo());
46 Expect.equals(200, a.bar()); 49 Expect.equals(200, a.bar());
47 Expect.equals(300, a.baz()); 50 Expect.equals(300, a.baz());
48 Expect.equals(800, b.bar()); 51 Expect.equals(800, b.bar());
49 Expect.equals(900, b.baz()); 52 Expect.equals(900, b.baz());
(...skipping 20 matching lines...) Expand all
70 expectNoSuchMethod(action, note) { 73 expectNoSuchMethod(action, note) {
71 bool caught = false; 74 bool caught = false;
72 try { 75 try {
73 action(); 76 action();
74 } catch (ex) { 77 } catch (ex) {
75 caught = true; 78 caught = true;
76 Expect.isTrue(ex is NoSuchMethodError, note); 79 Expect.isTrue(ex is NoSuchMethodError, note);
77 } 80 }
78 Expect.isTrue(caught, note); 81 Expect.isTrue(caught, note);
79 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698