Index: tests/compiler/dart2js_extra/js_array_removeLast_error_test.dart |
diff --git a/tests/compiler/dart2js_extra/js_array_removeLast_error_test.dart b/tests/compiler/dart2js_extra/js_array_removeLast_error_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6fc14dce16f8cbae9c59086f64e29b17c88a65f2 |
--- /dev/null |
+++ b/tests/compiler/dart2js_extra/js_array_removeLast_error_test.dart |
@@ -0,0 +1,39 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+// Test that optimized JSArray removeLast() calls generate the same error as |
+// dyncamically dispatched calls. |
+ |
+import 'package:expect/expect.dart'; |
+ |
+@NoInline() @AssumeDynamic() |
+confuse(x) => x; |
+ |
+ |
+Error getError(action()) { |
+ try { |
+ action(); |
+ Expect.fail('must throw'); |
+ } catch (e) { |
+ return e; |
+ } |
+} |
+ |
+main() { |
+ fault1() { |
+ return confuse([]).removeLast(); |
+ } |
+ |
+ fault2() { |
+ var a = []; |
+ while (confuse(false)) a.add(1); |
+ // This one should be optimized since [a] is a growable JSArray. |
+ return a.removeLast(); |
+ } |
+ |
+ var e1 = getError(fault1); |
+ var e2 = getError(fault2); |
+ |
+ Expect.equals('$e1', '$e2'); |
+} |