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) { |
(...skipping 21 matching lines...) Expand all Loading... |
32 Expect.equals("az", forwardN(scope, 25)); | 32 Expect.equals("az", forwardN(scope, 25)); |
33 // Then upper case letters | 33 // Then upper case letters |
34 Expect.equals("aA", forwardN(scope, 1)); | 34 Expect.equals("aA", forwardN(scope, 1)); |
35 Expect.equals("aZ", forwardN(scope, 25)); | 35 Expect.equals("aZ", forwardN(scope, 25)); |
36 // Overflow to first position. | 36 // Overflow to first position. |
37 Expect.equals("b_", forwardN(scope, 1)); | 37 Expect.equals("b_", forwardN(scope, 1)); |
38 // Make sure we skipe g. We have 1 + 10 + 26 + 26 = 63 digits. | 38 // Make sure we skipe g. We have 1 + 10 + 26 + 26 = 63 digits. |
39 Expect.equals("h_", forwardN(scope, 63 * 5)); | 39 Expect.equals("h_", forwardN(scope, 63 * 5)); |
40 // Likewise, ensure we skip s. | 40 // Likewise, ensure we skip s. |
41 Expect.equals("t_", forwardN(scope, 63 * 11)); | 41 Expect.equals("t_", forwardN(scope, 63 * 11)); |
42 // And wrap around another digit. | 42 // And wrap around another digit. |
43 Expect.equals("a__", forwardN(scope, 63 * 33)); | 43 Expect.equals("a__", forwardN(scope, 63 * 33)); |
44 | 44 |
45 // Test a filtered scope. | 45 // Test a filtered scope. |
46 Set<String> illegal = new Set.from(["b", "aa"]); | 46 Set<String> illegal = new Set.from(["b", "aa"]); |
47 scope = new TokenScope(illegal); | 47 scope = new TokenScope(illegal); |
48 | 48 |
49 // We start with 'a'. | 49 // We start with 'a'. |
50 Expect.equals("a", forwardN(scope, 1)); | 50 Expect.equals("a", forwardN(scope, 1)); |
51 // Make sure 'b' is skipped. | 51 // Make sure 'b' is skipped. |
52 Expect.equals("c", forwardN(scope, 1)); | 52 Expect.equals("c", forwardN(scope, 1)); |
53 // We have 24 lower case characters, as s and g are illegal. | 53 // We have 24 lower case characters, as s and g are illegal. |
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 |