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

Unified Diff: pkg/kernel/testcases/closures/arity.dart

Issue 3000333002: Fix several bugs in closure conversion. (Closed)
Patch Set: Comments. Created 3 years, 4 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
Index: pkg/kernel/testcases/closures/arity.dart
diff --git a/pkg/kernel/testcases/closures/arity.dart b/pkg/kernel/testcases/closures/arity.dart
new file mode 100644
index 0000000000000000000000000000000000000000..e4285d58bc35b29dd9d2a175c5ad14f8dbf7adb2
--- /dev/null
+++ b/pkg/kernel/testcases/closures/arity.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2017, 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 closures check their argument count.
+//
+main() {
+ var closures = [
+ (x, y, [z]) {},
+ (x, y, z) {},
+ (x, y, {z}) {},
+ (x, y, z, w, v) {}
+ ];
+ for (var c in closures) {
+ bool ok = false;
+ try {
+ c(1, 2, 3, 4);
+ } on NoSuchMethodError catch (_) {
+ ok = true;
+ }
+ if (!ok) {
+ throw new Exception("Expected an error!");
+ }
+ }
+
+ (x, y, [z]) {}(1, 2);
+ (x, y, [z]) {}(1, 2, 3);
+}
« no previous file with comments | « pkg/kernel/lib/transformations/closure/invalidate_closures.dart ('k') | pkg/kernel/testcases/closures/arity.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698