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

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

Issue 1187553005: Revert "Better messages for optimized index errors." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import "dart:typed_data";
7
8 // Test that optimized indexing and slow path indexing produce the same error.
9
10 @NoInline()
11 @AssumeDynamic()
12 confuse(x) => x;
13
14 class TooHigh {
15 static load1() {
16 var a = confuse(true) ? [10,11] : [10,11,12,13,14];
17 try {
18 // dynamic receiver causes method to be called via interceptor.
19 return confuse(a)[3];
20 } catch (e) {
21 return e;
22 }
23 Expect.fail('unreached');
24 }
25
26 static load2() {
27 try {
28 confuse(load2x)(3);
29 } catch (e) {
30 return e;
31 }
32 Expect.fail('unreached');
33 }
34 static load2x(i) {
35 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 return a[i];
38 }
39
40 static test() {
41 var e1 = load1();
42 var e2 = load2();
43 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
44 }
45 }
46
47 class Negative {
48 static load1() {
49 var a = confuse(true) ? [10,11] : [10,11,12,13,14];
50 try {
51 // dynamic receiver causes method to be called via interceptor.
52 return confuse(a)[-3];
53 } catch (e) {
54 return e;
55 }
56 Expect.fail('unreached');
57 }
58
59 static load2() {
60 try {
61 confuse(load2x)(-3);
62 } catch (e) {
63 return e;
64 }
65 Expect.fail('unreached');
66 }
67 static load2x(i) {
68 var a = confuse(true) ? [10,11] : [10,11,12,13,14];
69 // 'a' is inferred as JSArray of unknown length so has optimized check.
70 return a[i];
71 }
72
73 static test() {
74 var e1 = load1();
75 var e2 = load2();
76 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
77 }
78 }
79
80 class Empty {
81 static load1() {
82 var a = confuse(true) ? [] : [10,11,12,13,14];
83 try {
84 // dynamic receiver causes method to be called via interceptor.
85 return confuse(a)[-3];
86 } catch (e) {
87 return e;
88 }
89 Expect.fail('unreached');
90 }
91
92 static load2() {
93 try {
94 confuse(load2x)(-3);
95 } catch (e) {
96 return e;
97 }
98 Expect.fail('unreached');
99 }
100 static load2x(i) {
101 var a = confuse(true) ? [] : [10,11,12,13,14];
102 // 'a' is inferred as JSArray of unknown length so has optimized check.
103 return a[i];
104 }
105
106 static test() {
107 var e1 = load1();
108 var e2 = load2();
109 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
110 }
111 }
112
113 class BadType {
114 static load1() {
115 var a = confuse(true) ? [10,11] : [10,11,12,13,14];
116 try {
117 // dynamic receiver causes method to be called via interceptor.
118 return confuse(a)['a'];
119 } catch (e) {
120 return e;
121 }
122 Expect.fail('unreached');
123 }
124
125 static load2() {
126 try {
127 confuse(load2x)('a');
128 } catch (e) {
129 return e;
130 }
131 Expect.fail('unreached');
132 }
133 static load2x(i) {
134 var a = confuse(true) ? [10,11] : [10,11,12,13,14];
135 // 'a' is inferred as JSArray of unknown length so has optimized check.
136 return a[i];
137 }
138
139 static test() {
140 var e1 = load1();
141 var e2 = load2();
142 Expect.equals('$e1', '$e2', '\n A: "$e1"\n B: "$e2"\n');
143 }
144 }
145
146 main() {
147 TooHigh.test();
148 Negative.test();
149 Empty.test();
150 BadType.test();
151 }
OLDNEW
« no previous file with comments | « sdk/lib/core/errors.dart ('k') | tests/compiler/dart2js_extra/consistent_index_error_string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698