Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: tests/compiler/dart2js_extra/consistent_index_error_string_test.dart

Issue 2345083003: dart2js: run dartfmt on tests (Closed)
Patch Set: revert another multipart test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import "dart:typed_data"; 6 import "dart:typed_data";
7 7
8 // Test that optimized indexing and slow path indexing produce the same error. 8 // Test that optimized indexing and slow path indexing produce the same error.
9 9
10 @NoInline() 10 @NoInline()
11 @AssumeDynamic() 11 @AssumeDynamic()
12 confuse(x) => x; 12 confuse(x) => x;
13 13
14 class TooHigh { 14 class TooHigh {
15 static load1() { 15 static load1() {
16 var a = confuse(true) ? 'AB' : 'ABCDE'; 16 var a = confuse(true) ? 'AB' : 'ABCDE';
17 try { 17 try {
18 return confuse(a)[3]; // dynamic receiver for indexer. 18 return confuse(a)[3]; // dynamic receiver for indexer.
19 } catch (e) { 19 } catch (e) {
20 return e; 20 return e;
21 } 21 }
22 Expect.fail('unreached'); 22 Expect.fail('unreached');
23 } 23 }
24 24
25 static load2() { 25 static load2() {
26 try { 26 try {
27 confuse(load2x)(3); 27 confuse(load2x)(3);
28 } catch (e) { 28 } catch (e) {
29 return e; 29 return e;
30 } 30 }
31 Expect.fail('unreached'); 31 Expect.fail('unreached');
32 } 32 }
33
33 static load2x(i) { 34 static load2x(i) {
34 var a = confuse(true) ? 'AB' : 'ABCDE'; 35 var a = confuse(true) ? 'AB' : 'ABCDE';
35 return a[i]; // 'a' is String of unknown length. 36 return a[i]; // 'a' is String of unknown length.
36 } 37 }
37 38
38 static test() { 39 static test() {
39 var e1 = load1(); 40 var e1 = load1();
40 var e2 = load2(); 41 var e2 = load2();
41 print(" A: '$e1'\n B: '$e2'"); 42 print(" A: '$e1'\n B: '$e2'");
42 Expect.equals('$e1', '$e2'); 43 Expect.equals('$e1', '$e2');
43 } 44 }
44 } 45 }
45 46
46 class Negative { 47 class Negative {
47 static load1() { 48 static load1() {
48 var a = confuse(true) ? 'AB' : 'ABCDE'; 49 var a = confuse(true) ? 'AB' : 'ABCDE';
49 try { 50 try {
50 return confuse(a)[-3]; // dynamic receiver for indexer. 51 return confuse(a)[-3]; // dynamic receiver for indexer.
51 } catch (e) { 52 } catch (e) {
52 return e; 53 return e;
53 } 54 }
54 Expect.fail('unreached'); 55 Expect.fail('unreached');
55 } 56 }
56 57
57 static load2() { 58 static load2() {
58 try { 59 try {
59 confuse(load2x)(-3); 60 confuse(load2x)(-3);
60 } catch (e) { 61 } catch (e) {
61 return e; 62 return e;
62 } 63 }
63 Expect.fail('unreached'); 64 Expect.fail('unreached');
64 } 65 }
66
65 static load2x(i) { 67 static load2x(i) {
66 var a = confuse(true) ? 'AB' : 'ABCDE'; 68 var a = confuse(true) ? 'AB' : 'ABCDE';
67 return a[i]; // 'a' is String of unknown length. 69 return a[i]; // 'a' is String of unknown length.
68 } 70 }
69 71
70 static test() { 72 static test() {
71 var e1 = load1(); 73 var e1 = load1();
72 var e2 = load2(); 74 var e2 = load2();
73 print(" A: '$e1'\n B: '$e2'"); 75 print(" A: '$e1'\n B: '$e2'");
74 Expect.equals('$e1', '$e2'); 76 Expect.equals('$e1', '$e2');
75 } 77 }
76 } 78 }
77 79
78 class Empty { 80 class Empty {
79 static load1() { 81 static load1() {
80 var a = confuse(true) ? '' : 'ABCDE'; 82 var a = confuse(true) ? '' : 'ABCDE';
81 try { 83 try {
82 return confuse(a)[-3]; // dynamic receiver for indexer. 84 return confuse(a)[-3]; // dynamic receiver for indexer.
83 } catch (e) { 85 } catch (e) {
84 return e; 86 return e;
85 } 87 }
86 Expect.fail('unreached'); 88 Expect.fail('unreached');
87 } 89 }
88 90
89 static load2() { 91 static load2() {
90 try { 92 try {
91 confuse(load2x)(-3); 93 confuse(load2x)(-3);
92 } catch (e) { 94 } catch (e) {
93 return e; 95 return e;
94 } 96 }
95 Expect.fail('unreached'); 97 Expect.fail('unreached');
96 } 98 }
99
97 static load2x(i) { 100 static load2x(i) {
98 var a = confuse(true) ? '' : 'ABCDE'; 101 var a = confuse(true) ? '' : 'ABCDE';
99 return a[i]; // 'a' is String of unknown length. 102 return a[i]; // 'a' is String of unknown length.
100 } 103 }
101 104
102 static test() { 105 static test() {
103 var e1 = load1(); 106 var e1 = load1();
104 var e2 = load2(); 107 var e2 = load2();
105 print(" A: '$e1'\n B: '$e2'"); 108 print(" A: '$e1'\n B: '$e2'");
106 Expect.equals('$e1', '$e2'); 109 Expect.equals('$e1', '$e2');
107 } 110 }
108 } 111 }
109 112
110 class BadType { 113 class BadType {
111 static load1() { 114 static load1() {
112 var a = confuse(true) ? 'AB' : 'ABCDE'; 115 var a = confuse(true) ? 'AB' : 'ABCDE';
113 try { 116 try {
114 return confuse(a)['a']; // dynamic receiver for indexer. 117 return confuse(a)['a']; // dynamic receiver for indexer.
115 } catch (e) { 118 } catch (e) {
116 return e; 119 return e;
117 } 120 }
118 Expect.fail('unreached'); 121 Expect.fail('unreached');
119 } 122 }
120 123
121 static load2() { 124 static load2() {
122 try { 125 try {
123 confuse(load2x)('a'); 126 confuse(load2x)('a');
124 } catch (e) { 127 } catch (e) {
125 return e; 128 return e;
126 } 129 }
127 Expect.fail('unreached'); 130 Expect.fail('unreached');
128 } 131 }
132
129 static load2x(i) { 133 static load2x(i) {
130 var a = confuse(true) ? 'AB' : 'ABCDE'; 134 var a = confuse(true) ? 'AB' : 'ABCDE';
131 return a[i]; // 'a' is String of unknown length. 135 return a[i]; // 'a' is String of unknown length.
132 } 136 }
133 137
134 static test() { 138 static test() {
135 var e1 = load1(); 139 var e1 = load1();
136 var e2 = load2(); 140 var e2 = load2();
137 print(" A: '$e1'\n B: '$e2'"); 141 print(" A: '$e1'\n B: '$e2'");
138 Expect.equals('$e1', '$e2'); 142 Expect.equals('$e1', '$e2');
139 } 143 }
140 } 144 }
141 145
142 main() { 146 main() {
143 TooHigh.test(); 147 TooHigh.test();
144 Negative.test(); 148 Negative.test();
145 Empty.test(); 149 Empty.test();
146 BadType.test(); 150 BadType.test();
147 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698