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

Side by Side Diff: tests/language/closure7_test.dart

Issue 10918261: Update language tests to new optional parameter syntax and semantics. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // Test that implicitly bound closures work correctly 5 // Test that implicitly bound closures work correctly
6 6
7 class A { 7 class A {
8 foo() => 499; 8 foo() => 499;
9 fooo() => 4999; // Implicit closure class can be shared with foo. 9 fooo() => 4999; // Implicit closure class can be shared with foo.
10 bar(x, [y = 8, z = 10]) => "1 $x $y $z"; 10 bar(x, {y: 8, z: 10}) => "1 $x $y $z";
11 gee(x, [y = 9, z = 11]) => "2 $x $y $z"; // Must not be shared with "bar". 11 gee(x, {y: 9, z: 11}) => "2 $x $y $z"; // Must not be shared with "bar".
12 toto(x, [y = 8, z = 10]) => "3 $x $y $z"; // Could be shared with "bar". 12 toto(x, {y: 8, z: 10}) => "3 $x $y $z"; // Could be shared with "bar".
13 13
14 fisk(x, [y = 8, zz = 10]) => "4 $x $y $zz"; 14 fisk(x, {y: 8, zz: 10}) => "4 $x $y $zz";
15 titi(x, [y = 8, zz = 77]) => "5 $x $y $zz"; // Could be shared with "fisk", 15 titi(x, {y: 8, zz: 77}) => "5 $x $y $zz"; // Could be shared with "fisk",
16 // because default-val is never used. 16 // because default-val is never used.
17 } 17 }
18 18
19 class B { 19 class B {
20 // All implicit closures of B can be shared with their equivalent functions 20 // All implicit closures of B can be shared with their equivalent functions
21 // of A. 21 // of A.
22 foo() => 4990; 22 foo() => 4990;
23 fooo() => 49990; 23 fooo() => 49990;
24 bar(x, [y = 8, z = 10]) => "1B $x $y $z"; 24 bar(x, {y: 8, z: 10}) => "1B $x $y $z";
25 gee(x, [y = 9, z = 11]) => "2B $x $y $z"; 25 gee(x, {y: 9, z: 11}) => "2B $x $y $z";
26 toto(x, [y = 8, z = 10]) => "3B $x $y $z"; 26 toto(x, {y: 8, z: 10}) => "3B $x $y $z";
27 fisk(x, [y = 8, zz = 10]) => "4B $x $y $zz"; 27 fisk(x, {y: 8, zz: 10}) => "4B $x $y $zz";
28 titi(x, [y = 8, zz = 77]) => "5B $x $y $zz"; 28 titi(x, {y: 8, zz: 77}) => "5B $x $y $zz";
29 } 29 }
30 30
31 31
32 tearOffFoo(o) => o.foo; 32 tearOffFoo(o) => o.foo;
33 tearOffFooo(o) => o.fooo; 33 tearOffFooo(o) => o.fooo;
34 tearOffBar(o) => o.bar; 34 tearOffBar(o) => o.bar;
35 tearOffGee(o) => o.gee; 35 tearOffGee(o) => o.gee;
36 tearOffToto(o) => o.toto; 36 tearOffToto(o) => o.toto;
37 tearOffFisk(o) => o.fisk; 37 tearOffFisk(o) => o.fisk;
38 tearOffTiti(o) => o.titi; 38 tearOffTiti(o) => o.titi;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 var fiskA = tearOffFisk(a); 82 var fiskA = tearOffFisk(a);
83 var fiskB = tearOffFisk(b); 83 var fiskB = tearOffFisk(b);
84 var titiA = tearOffTiti(a); 84 var titiA = tearOffTiti(a);
85 var titiB = tearOffTiti(b); 85 var titiB = tearOffTiti(b);
86 86
87 Expect.equals("4 311 8 987", fiskA(311, zz: 987)); 87 Expect.equals("4 311 8 987", fiskA(311, zz: 987));
88 Expect.equals("4B 311 8 987", fiskB(311, zz: 987)); 88 Expect.equals("4B 311 8 987", fiskB(311, zz: 987));
89 Expect.equals("5 311 8 987", titiA(311, zz: 987)); 89 Expect.equals("5 311 8 987", titiA(311, zz: 987));
90 Expect.equals("5B 311 8 987", titiB(311, zz: 987)); 90 Expect.equals("5B 311 8 987", titiB(311, zz: 987));
91 91
92 Expect.equals("4 311 765 987", fiskA(311, 765, 987)); 92 Expect.equals("4 311 765 987", fiskA(311, y: 765, zz: 987));
93 Expect.equals("4B 311 765 987", fiskB(311, 765, 987)); 93 Expect.equals("4B 311 765 987", fiskB(311, y: 765, zz: 987));
94 Expect.equals("5 311 765 987", titiA(311, 765, 987)); 94 Expect.equals("5 311 765 987", titiA(311, y: 765, zz: 987));
95 Expect.equals("5B 311 765 987", titiB(311, 765, 987)); 95 Expect.equals("5B 311 765 987", titiB(311, y: 765, zz: 987));
96 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698