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 // A native class has no defined constructor. | 5 // A native class has no defined constructor. |
6 // This regression test verifies that compiler accounts for hidden constructor | 6 // This regression test verifies that compiler accounts for hidden constructor |
7 // when analysing field values. | 7 // when analysing field values. |
8 | 8 |
9 import "native_testing.dart"; | 9 import "native_testing.dart"; |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 makeNode(parent) native; | 38 makeNode(parent) native; |
39 | 39 |
40 class ModelSource { | 40 class ModelSource { |
41 var name; | 41 var name; |
42 ModelSource(this.name); | 42 ModelSource(this.name); |
43 toString() => 'ModelSource($name)'; | 43 toString() => 'ModelSource($name)'; |
44 } | 44 } |
45 | 45 |
46 void setup() native """ | 46 void setup() native """ |
47 // This code is all inside 'setup' and so not accesible from the global scope. | 47 // This code is all inside 'setup' and so not accessible from the global scope. |
48 function Node(parent){ this.parentNode = parent; } | 48 function Node(parent){ this.parentNode = parent; } |
49 makeNode = function(p){return new Node(p);}; | 49 makeNode = function(p){return new Node(p);}; |
50 self.nativeConstructor(Node); | 50 self.nativeConstructor(Node); |
51 """; | 51 """; |
52 | 52 |
53 main() { | 53 main() { |
54 nativeTesting(); | 54 nativeTesting(); |
55 setup(); | 55 setup(); |
56 | 56 |
57 var n1 = makeNode(null); | 57 var n1 = makeNode(null); |
58 var n2 = makeNode(n1); | 58 var n2 = makeNode(n1); |
59 var n3 = makeNode(n2); | 59 var n3 = makeNode(n2); |
60 | 60 |
61 var m1 = new ModelSource('1'); | 61 var m1 = new ModelSource('1'); |
62 n2._modelSource = null; // null write. | 62 n2._modelSource = null; // null write. |
63 n2._modelSource = m1; // Non-null write. | 63 n2._modelSource = m1; // Non-null write. |
64 var x1 = n3.modelSource; | 64 var x1 = n3.modelSource; |
65 Expect.identical(m1, x1); | 65 Expect.identical(m1, x1); |
66 | 66 |
67 var m2 = new ModelSource('2'); | 67 var m2 = new ModelSource('2'); |
68 n2._modelSource2 = m2; // The only write is non-null. | 68 n2._modelSource2 = m2; // The only write is non-null. |
69 var x2 = n3.modelSource2; | 69 var x2 = n3.modelSource2; |
70 Expect.identical(m2, x2); | 70 Expect.identical(m2, x2); |
71 } | 71 } |
OLD | NEW |