| OLD | NEW | 
|---|
| 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 // Verify that native fields on classes are not renamed by the minifier. | 7 // Verify that native fields on classes are not renamed by the minifier. | 
| 8 @Native("A") | 8 @Native("A") | 
| 9 class A { | 9 class A { | 
| 10   int myLongPropertyName; | 10   int myLongPropertyName; | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 32                             } | 32                             } | 
| 33       }); | 33       }); | 
| 34   a.getValue = 0; | 34   a.getValue = 0; | 
| 35   return a; | 35   return a; | 
| 36 } | 36 } | 
| 37 | 37 | 
| 38 makeA = function(){return new A;}; | 38 makeA = function(){return new A;}; | 
| 39 self.nativeConstructor(A); | 39 self.nativeConstructor(A); | 
| 40 """; | 40 """; | 
| 41 | 41 | 
| 42 A makeA() native ; | 42 A makeA() native; | 
| 43 | 43 | 
| 44 main() { | 44 main() { | 
| 45   nativeTesting(); | 45   nativeTesting(); | 
| 46   setup(); | 46   setup(); | 
| 47   var a = makeA(); | 47   var a = makeA(); | 
| 48   a.myLongPropertyName = 21; | 48   a.myLongPropertyName = 21; | 
| 49   int gotten = a.myLongPropertyName; | 49   int gotten = a.myLongPropertyName; | 
| 50   Expect.equals(11, gotten); | 50   Expect.equals(11, gotten); | 
| 51 | 51 | 
| 52   // Force interceptor dispatch. | 52   // Force interceptor dispatch. | 
| 53   confuse(a).myLongPropertyName = 99; | 53   confuse(a).myLongPropertyName = 99; | 
| 54   gotten = confuse(a).myLongPropertyName; | 54   gotten = confuse(a).myLongPropertyName; | 
| 55   Expect.equals(22, gotten); | 55   Expect.equals(22, gotten); | 
| 56 | 56 | 
| 57   var a2 = makeA(); | 57   var a2 = makeA(); | 
| 58   if (a2 is A) { | 58   if (a2 is A) { | 
| 59     // Inside this 'if' the compiler knows that a2 is an A, so it is tempted | 59     // Inside this 'if' the compiler knows that a2 is an A, so it is tempted | 
| 60     // to access myLongPropertyName directly, using its minified name.  But | 60     // to access myLongPropertyName directly, using its minified name.  But | 
| 61     // renaming of native properties can only work using getters and setters | 61     // renaming of native properties can only work using getters and setters | 
| 62     // that access the original name. | 62     // that access the original name. | 
| 63     a2.myLongPropertyName = 21; | 63     a2.myLongPropertyName = 21; | 
| 64     int gotten = a2.myLongPropertyName; | 64     int gotten = a2.myLongPropertyName; | 
| 65     Expect.equals(11, gotten); | 65     Expect.equals(11, gotten); | 
| 66   } | 66   } | 
| 67 } | 67 } | 
| OLD | NEW | 
|---|