OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Check that we can use pseudo keywords as names in function level code. | 4 // Check that we can use pseudo keywords as names in function level code. |
5 | 5 |
6 | 6 |
7 class PseudoKWTest { | 7 class PseudoKWTest { |
8 static testMain() { | 8 static testMain() { |
9 | 9 |
10 // This is a list of built-in identifiers from the Dart spec. | 10 // This is a list of built-in identifiers from the Dart spec. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 static check() { | 69 static check() { |
70 var o = new A(); | 70 var o = new A(); |
71 o.set(55); | 71 o.set(55); |
72 Expect.equals(50, o.get()); | 72 Expect.equals(50, o.get()); |
73 static(); | 73 static(); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 class B { | 77 class B { |
78 var set = 100; | 78 var set = 100; |
79 get get() => set; | 79 get get => set; |
80 set get(get) => set = 2 * get.get; | 80 set get(get) => set = 2 * get.get; |
81 | 81 |
82 static() { | 82 static() { |
83 var set = new B(); | 83 var set = new B(); |
84 set.get = set; | 84 set.get = set; |
85 Expect.equals(200, set.get); | 85 Expect.equals(200, set.get); |
86 } | 86 } |
87 int operator() { | 87 int operator() { |
88 return 1; | 88 return 1; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 class C { | 92 class C { |
93 static int operator = (5); | 93 static int operator = (5); |
94 static var get; | 94 static var get; |
95 static get set() => 111; | 95 static get set => 111; |
96 static set set(set) { } | 96 static set set(set) { } |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 main() { | 100 main() { |
101 PseudoKWTest.testMain(); | 101 PseudoKWTest.testMain(); |
102 A.check(); | 102 A.check(); |
103 new B().static(); | 103 new B().static(); |
104 Expect.equals(1, new B().operator()); | 104 Expect.equals(1, new B().operator()); |
105 Expect.equals(1, A.static()); | 105 Expect.equals(1, A.static()); |
106 typedef("T"); | 106 typedef("T"); |
107 Expect.equals("typedef T", typedef("T")); | 107 Expect.equals("typedef T", typedef("T")); |
108 static("true"); | 108 static("true"); |
109 Expect.equals(false, static("true")); | 109 Expect.equals(false, static("true")); |
110 Expect.equals(5, C.operator); | 110 Expect.equals(5, C.operator); |
111 Expect.equals(null, C.get); | 111 Expect.equals(null, C.get); |
112 C.set = 0; | 112 C.set = 0; |
113 Expect.equals(111, C.set); | 113 Expect.equals(111, C.set); |
114 } | 114 } |
OLD | NEW |