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

Unified Diff: tests/language/argument_definition4_test.dart

Issue 12036088: Fix argument test for the captured parameter of an outer function (issue 8007). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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 | « runtime/vm/parser.cc ('k') | tests/language/argument_definition5_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/argument_definition4_test.dart
===================================================================
--- tests/language/argument_definition4_test.dart (revision 0)
+++ tests/language/argument_definition4_test.dart (revision 0)
@@ -0,0 +1,80 @@
+// Copyright (c) 2013, 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.
+
+test1(bool passed, {a: 42}) {
+ if (passed) {
+ Expect.equals(54, a);
+ Expect.isTrue(?a);
+ } else {
+ Expect.equals(42, a);
+ Expect.isFalse(?a);
+ }
+ Expect.isTrue(?passed);
+}
+
+test2() {
+ var closure = (passed, {a: 42}) {
+ if (passed) {
+ Expect.equals(54, a);
+ Expect.isTrue(?a);
+ } else {
+ Expect.equals(42, a);
+ Expect.isFalse(?a);
+ }
+ Expect.isTrue(?passed);
+ };
+ closure(true, a:54);
+ closure(false);
+}
+
+class A {
+ test3(bool passed, {a: 42}) {
+ if (passed) {
+ Expect.equals(54, a);
+ Expect.isTrue(?a);
+ } else {
+ Expect.equals(42, a);
+ Expect.isFalse(?a);
+ }
+ Expect.isTrue(?passed);
+ }
+}
+
+
+test4(bool passed, {a}) {
+ if (passed) {
+ Expect.equals(54, a);
+ Expect.isTrue(?a);
+ } else {
+ Expect.equals(null, a);
+ Expect.isFalse(?a);
+ }
+ Expect.isTrue(?passed);
+}
+
+int inscrutable(int x) => x == 0 ? 0 : x | inscrutable(x & (x - 1));
+
+main() {
+ test1(true, a:54);
+ test1(false);
+ test2();
+ new A().test3(true, a:54);
+ new A().test3(false);
+
+ var things = [test1, test2, new A().test3];
+
+ var closure = things[inscrutable(0)];
+ closure(true, a:54);
+ closure(false);
+
+ closure = things[inscrutable(1)];
+ closure();
+
+ closure = things[inscrutable(2)];
+ closure(true, a:54);
+ closure(false);
+
+ test4(true, a:54);
+ test4(false);
+}
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/argument_definition5_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698