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: tests/compiler/dart2js_native/native_class_avoids_hidden_name_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 import "native_testing.dart"; 5 import "native_testing.dart";
6 6
7 // Test that hidden native class names are not used by generated code. 7 // Test that hidden native class names are not used by generated code.
8 8
9 @Native("BB") 9 @Native("BB")
10 class AA { 10 class AA {
11 get name => 'AA'; 11 get name => 'AA';
12 static AA create() => makeA(); 12 static AA create() => makeA();
13 } 13 }
14 14
15 @Native("CC") 15 @Native("CC")
16 class BB { 16 class BB {
17 get name => 'BB'; 17 get name => 'BB';
18 static BB create() => makeB(); 18 static BB create() => makeB();
19 } 19 }
20 20
21 class CC { 21 class CC {
22 // Ordinary class with name clashing with native class. 22 // Ordinary class with name clashing with native class.
23 get name => 'CC'; 23 get name => 'CC';
24 static CC create() => new CC(); 24 static CC create() => new CC();
25 } 25 }
26 26
27 makeA() native; 27 makeA() native;
28 makeB() native; 28 makeB() native;
29 29
30 void setup1() native """ 30 void setup1() {
31 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place 31 JS('', r"""
32 // anything on the hidden native class. 32 (function(){
33 BB = null; 33 // Poison hidden native names 'BB' and 'CC' to prove the compiler didn't place
34 CC = null; 34 // anything on the hidden native class.
35 """; 35 BB = null;
36 CC = null;
37 })()""");
38 }
36 39
37 void setup2() native """ 40 void setup2() {
38 // This code is all inside 'setup' and so not accessible from the global scope. 41 JS('', r"""
39 function BB(){} 42 (function(){
40 function CC(){} 43 // This code is inside 'setup' and so not accessible from the global scope.
41 makeA = function(){return new BB}; // AA is native "BB" 44 function BB(){}
42 makeB = function(){return new CC}; // BB is native "CC" 45 function CC(){}
43 self.nativeConstructor(BB); 46 makeA = function(){return new BB()}; // AA is native "BB"
44 self.nativeConstructor(CC); 47 makeB = function(){return new CC()}; // BB is native "CC"
45 """; 48 self.nativeConstructor(BB);
49 self.nativeConstructor(CC);
50 })()""");
51 }
46 52
47 main() { 53 main() {
48 nativeTesting(); 54 nativeTesting();
49 setup1(); 55 setup1();
50 setup2(); 56 setup2();
51 57
52 var a = confuse(AA.create()); 58 var a = confuse(AA.create());
53 var b = confuse(BB.create()); 59 var b = confuse(BB.create());
54 var c = confuse(CC.create()); 60 var c = confuse(CC.create());
55 61
56 Expect.equals('AA', a.name); 62 Expect.equals('AA', a.name);
57 Expect.equals('BB', b.name); 63 Expect.equals('BB', b.name);
58 Expect.equals('CC', c.name); 64 Expect.equals('CC', c.name);
59 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698