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

Side by Side Diff: tests/compiler/dart2js_extra/consistent_index_error_array_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) ? [10,11] : [10,11,12,13,14]; 16 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
17 try { 17 try {
18 // dynamic receiver causes method to be called via interceptor. 18 // dynamic receiver causes method to be called via interceptor.
19 return confuse(a)[3]; 19 return confuse(a)[3];
20 } catch (e) { 20 } catch (e) {
21 return e; 21 return e;
22 } 22 }
23 Expect.fail('unreached'); 23 Expect.fail('unreached');
24 } 24 }
25 25
26 static load2() { 26 static load2() {
27 try { 27 try {
28 confuse(load2x)(3); 28 confuse(load2x)(3);
29 } catch (e) { 29 } catch (e) {
30 return e; 30 return e;
31 } 31 }
32 Expect.fail('unreached'); 32 Expect.fail('unreached');
33 } 33 }
34
34 static load2x(i) { 35 static load2x(i) {
35 var a = confuse(true) ? [10,11] : [10,11,12,13,14]; 36 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
36 // 'a' is inferred as JSArray of unknown length so has optimized check. 37 // 'a' is inferred as JSArray of unknown length so has optimized check.
37 return a[i]; 38 return a[i];
38 } 39 }
39 40
40 static test() { 41 static test() {
41 var e1 = load1(); 42 var e1 = load1();
42 var e2 = load2(); 43 var e2 = load2();
43 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n'); 44 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
44 } 45 }
45 } 46 }
46 47
47 class Negative { 48 class Negative {
48 static load1() { 49 static load1() {
49 var a = confuse(true) ? [10,11] : [10,11,12,13,14]; 50 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
50 try { 51 try {
51 // dynamic receiver causes method to be called via interceptor. 52 // dynamic receiver causes method to be called via interceptor.
52 return confuse(a)[-3]; 53 return confuse(a)[-3];
53 } catch (e) { 54 } catch (e) {
54 return e; 55 return e;
55 } 56 }
56 Expect.fail('unreached'); 57 Expect.fail('unreached');
57 } 58 }
58 59
59 static load2() { 60 static load2() {
60 try { 61 try {
61 confuse(load2x)(-3); 62 confuse(load2x)(-3);
62 } catch (e) { 63 } catch (e) {
63 return e; 64 return e;
64 } 65 }
65 Expect.fail('unreached'); 66 Expect.fail('unreached');
66 } 67 }
68
67 static load2x(i) { 69 static load2x(i) {
68 var a = confuse(true) ? [10,11] : [10,11,12,13,14]; 70 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
69 // 'a' is inferred as JSArray of unknown length so has optimized check. 71 // 'a' is inferred as JSArray of unknown length so has optimized check.
70 return a[i]; 72 return a[i];
71 } 73 }
72 74
73 static test() { 75 static test() {
74 var e1 = load1(); 76 var e1 = load1();
75 var e2 = load2(); 77 var e2 = load2();
76 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n'); 78 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
77 } 79 }
78 } 80 }
79 81
80 class Empty { 82 class Empty {
81 static load1() { 83 static load1() {
82 var a = confuse(true) ? [] : [10,11,12,13,14]; 84 var a = confuse(true) ? [] : [10, 11, 12, 13, 14];
83 try { 85 try {
84 // dynamic receiver causes method to be called via interceptor. 86 // dynamic receiver causes method to be called via interceptor.
85 return confuse(a)[-3]; 87 return confuse(a)[-3];
86 } catch (e) { 88 } catch (e) {
87 return e; 89 return e;
88 } 90 }
89 Expect.fail('unreached'); 91 Expect.fail('unreached');
90 } 92 }
91 93
92 static load2() { 94 static load2() {
93 try { 95 try {
94 confuse(load2x)(-3); 96 confuse(load2x)(-3);
95 } catch (e) { 97 } catch (e) {
96 return e; 98 return e;
97 } 99 }
98 Expect.fail('unreached'); 100 Expect.fail('unreached');
99 } 101 }
102
100 static load2x(i) { 103 static load2x(i) {
101 var a = confuse(true) ? [] : [10,11,12,13,14]; 104 var a = confuse(true) ? [] : [10, 11, 12, 13, 14];
102 // 'a' is inferred as JSArray of unknown length so has optimized check. 105 // 'a' is inferred as JSArray of unknown length so has optimized check.
103 return a[i]; 106 return a[i];
104 } 107 }
105 108
106 static test() { 109 static test() {
107 var e1 = load1(); 110 var e1 = load1();
108 var e2 = load2(); 111 var e2 = load2();
109 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n'); 112 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
110 } 113 }
111 } 114 }
112 115
113 class BadType { 116 class BadType {
114 static load1() { 117 static load1() {
115 var a = confuse(true) ? [10,11] : [10,11,12,13,14]; 118 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
116 try { 119 try {
117 // dynamic receiver causes method to be called via interceptor. 120 // dynamic receiver causes method to be called via interceptor.
118 return confuse(a)['a']; 121 return confuse(a)['a'];
119 } catch (e) { 122 } catch (e) {
120 return e; 123 return e;
121 } 124 }
122 Expect.fail('unreached'); 125 Expect.fail('unreached');
123 } 126 }
124 127
125 static load2() { 128 static load2() {
126 try { 129 try {
127 confuse(load2x)('a'); 130 confuse(load2x)('a');
128 } catch (e) { 131 } catch (e) {
129 return e; 132 return e;
130 } 133 }
131 Expect.fail('unreached'); 134 Expect.fail('unreached');
132 } 135 }
136
133 static load2x(i) { 137 static load2x(i) {
134 var a = confuse(true) ? [10,11] : [10,11,12,13,14]; 138 var a = confuse(true) ? [10, 11] : [10, 11, 12, 13, 14];
135 // 'a' is inferred as JSArray of unknown length so has optimized check. 139 // 'a' is inferred as JSArray of unknown length so has optimized check.
136 return a[i]; 140 return a[i];
137 } 141 }
138 142
139 static test() { 143 static test() {
140 var e1 = load1(); 144 var e1 = load1();
141 var e2 = load2(); 145 var e2 = load2();
142 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n'); 146 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
143 } 147 }
144 } 148 }
145 149
146 main() { 150 main() {
147 TooHigh.test(); 151 TooHigh.test();
148 Negative.test(); 152 Negative.test();
149 Empty.test(); 153 Empty.test();
150 BadType.test(); 154 BadType.test();
151 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698