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

Unified Diff: tests/compiler/dart2js_extra/js_array_removeLast_error_test.dart

Issue 1315523012: dart2js ssa: Open coding of removeLast should use -1 as index (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_array.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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');
+}
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/js_array.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698