OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 "package:compiler/src/js_backend/js_backend.dart" show TokenScope; | 5 import "package:compiler/src/js_backend/js_backend.dart" show TokenScope; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 String forwardN(TokenScope scope, int N) { | 9 String forwardN(TokenScope scope, int N) { |
10 for (int i = 1; i < N; ++i) { | 10 for (int i = 1; i < N; ++i) { |
11 scope.getNextName(); | 11 scope.getNextName(); |
12 } | 12 } |
13 | 13 |
14 return scope.getNextName(); | 14 return scope.getNextName(); |
15 } | 15 } |
16 | 16 |
17 int main() { | 17 void main() { |
18 // Test a normal scope. | 18 // Test a normal scope. |
19 TokenScope scope = new TokenScope(); | 19 TokenScope scope = new TokenScope(); |
20 | 20 |
21 // We start with 'a'. | 21 // We start with 'a'. |
22 Expect.equals("a", scope.getNextName()); | 22 Expect.equals("a", scope.getNextName()); |
23 // We have 24 lower case characters, as s and g are illegal. | 23 // We have 24 lower case characters, as s and g are illegal. |
24 Expect.equals("A", forwardN(scope, 24)); | 24 Expect.equals("A", forwardN(scope, 24)); |
25 // Make it overflow by skipping all uppercase. | 25 // Make it overflow by skipping all uppercase. |
26 Expect.equals("a_", forwardN(scope, 26)); | 26 Expect.equals("a_", forwardN(scope, 26)); |
27 // Now numbers. | 27 // Now numbers. |
(...skipping 26 matching lines...) Expand all Loading... |
54 Expect.equals("A", forwardN(scope, 22)); | 54 Expect.equals("A", forwardN(scope, 22)); |
55 // Make it overflow by skipping all uppercase. | 55 // Make it overflow by skipping all uppercase. |
56 Expect.equals("a_", forwardN(scope, 26)); | 56 Expect.equals("a_", forwardN(scope, 26)); |
57 // Now numbers. | 57 // Now numbers. |
58 Expect.equals("a0", forwardN(scope, 1)); | 58 Expect.equals("a0", forwardN(scope, 1)); |
59 Expect.equals("a9", forwardN(scope, 9)); | 59 Expect.equals("a9", forwardN(scope, 9)); |
60 // Make sure 'aa' is skipped on wrapping | 60 // Make sure 'aa' is skipped on wrapping |
61 Expect.equals("ab", forwardN(scope, 1)); | 61 Expect.equals("ab", forwardN(scope, 1)); |
62 Expect.equals("az", forwardN(scope, 24)); | 62 Expect.equals("az", forwardN(scope, 24)); |
63 } | 63 } |
OLD | NEW |