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

Side by Side Diff: frog/tests/frog_native/native_class_avoids_hidden_name_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 that hidden native class names are not used by generated code.
6
7 class A native "*B" {
8 get name() => 'A';
9 static A create() => makeA();
10 }
11
12 class B native "*C" {
13 get name() => 'B';
14 static B create() => makeB();
15 }
16
17 class C { // Ordinary class with name clashing with native class.
18 get name() => 'C';
19 static C create() => new C();
20 }
21
22 makeA() native;
23 makeB() native;
24
25 void setup1() native """
26 // Poison hidden native names 'B' and 'C' to prove the compiler didn't place
27 // anthing on the hidden native class.
28 B = null;
29 C = null;
30 """;
31
32 void setup2() native """
33 // This code is all inside 'setup' and so not accesible from the global scope.
34 function B(){}
35 function C(){}
36 makeA = function(){return new B}; // A is "*B"
37 makeB = function(){return new C}; // B is "*C"
38 """;
39
40 int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
41
42 main() {
43 setup1();
44 setup2();
45
46 var things = [A.create(), B.create(), C.create()];
47 var a = things[inscrutable(0)];
48 var b = things[inscrutable(1)];
49 var c = things[inscrutable(2)];
50
51 Expect.equals('A', a.name);
52 Expect.equals('B', b.name);
53 Expect.equals('C', c.name);
54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698