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

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

Issue 2561723003: Merge kernel closure conversion into the Dart SDK (Closed)
Patch Set: Remove path constraint Created 4 years 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/static_tear_off.dart
diff --git a/pkg/kernel/testcases/closures/static_tear_off.dart b/pkg/kernel/testcases/closures/static_tear_off.dart
new file mode 100644
index 0000000000000000000000000000000000000000..29de7c752d0d056b9abd02153763dd21cfef39da
--- /dev/null
+++ b/pkg/kernel/testcases/closures/static_tear_off.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2016, 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.md file.
+
+f_1_1_no_default(a, [b]) => a + b;
+
+f_1_1_default(a, [b = 2]) => a + b;
+
+f_1_b_no_default(a, {b}) => a + b;
+
+f_1_b_default(a, {b: 2}) => a + b;
+
+test_1_1(Function f, bool hasDefault) {
+ var result = f(40, 2);
+ if (42 != result) throw "Unexpected result: $result";
+ test_1(f, hasDefault);
+}
+
+test_1_b(Function f, bool hasDefault) {
+ var result = f(40, b: 2);
+ if (42 != result) throw "Unexpected result: $result";
+ test_1(f, hasDefault);
+}
+
+test_1(Function f, bool hasDefault) {
+ var result = 0;
+ bool threw = true;
+ try {
+ result = f(40);
+ threw = false;
+ } catch (_) {
+ // Ignored.
+ }
+ if (hasDefault) {
+ if (threw) throw "Unexpected exception.";
+ if (42 != result) throw "Unexpected result: $result.";
+ } else {
+ if (!threw) throw "Expected exception missing.";
+ if (0 != result) throw "Unexpected result: $result.";
+ }
+}
+
+main(arguments) {
+ test_1_1(f_1_1_no_default, false);
+ test_1_1(f_1_1_default, true);
+ test_1_b(f_1_b_no_default, false);
+ test_1_b(f_1_b_default, true);
+}
« no previous file with comments | « pkg/kernel/testcases/closures/non_void_context.dart.expect ('k') | pkg/kernel/testcases/closures/static_tear_off.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698