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

Side by Side Diff: tests/language/named_parameters_passing_falsy_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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Dart test program for testing named parameters with various values that might 5 // Dart test program for testing named parameters with various values that might
6 // be implemented as 'falsy' values in a JavaScript implementation. 6 // be implemented as 'falsy' values in a JavaScript implementation.
7 7
8 8
9 class TestClass { 9 class TestClass {
10 TestClass(); 10 TestClass();
11 11
12 method([value = 100]) => value; 12 method([value = 100]) => value;
13 method2({value: 100}) => value;
13 14
14 static staticMethod([value = 200]) => value; 15 static staticMethod([value = 200]) => value;
16 static staticMethod2({value: 200}) => value;
15 } 17 }
16 18
17 globalMethod([value = 300]) => value; 19 globalMethod([value = 300]) => value;
20 globalMethod2({value: 300}) => value;
18 21
19 const testValues = const [0, 0.0, '', false, null]; 22 const testValues = const [0, 0.0, '', false, null];
20 23
21 testFunction(f) { 24 testFunction(f, f2) {
22 Expect.isTrue(f() >= 100); 25 Expect.isTrue(f() >= 100);
23 for (var v in testValues) { 26 for (var v in testValues) {
24 Expect.equals(v, f(v)); 27 Expect.equals(v, f(v));
25 Expect.equals(v, f(value: v)); 28 Expect.equals(v, f2(value: v));
26 } 29 }
27 } 30 }
28 31
29 main() { 32 main() {
30 var obj = new TestClass(); 33 var obj = new TestClass();
31 34
32 Expect.equals(100, obj.method()); 35 Expect.equals(100, obj.method());
36 Expect.equals(100, obj.method2());
33 Expect.equals(200, TestClass.staticMethod()); 37 Expect.equals(200, TestClass.staticMethod());
38 Expect.equals(200, TestClass.staticMethod2());
34 Expect.equals(300, globalMethod()); 39 Expect.equals(300, globalMethod());
40 Expect.equals(300, globalMethod2());
35 41
36 for (var v in testValues) { 42 for (var v in testValues) {
37 Expect.equals(v, obj.method(v)); 43 Expect.equals(v, obj.method(v));
38 Expect.equals(v, obj.method(value: v)); 44 Expect.equals(v, obj.method2(value: v));
39 Expect.equals(v, TestClass.staticMethod(v)); 45 Expect.equals(v, TestClass.staticMethod(v));
40 Expect.equals(v, TestClass.staticMethod(value: v)); 46 Expect.equals(v, TestClass.staticMethod2(value: v));
41 Expect.equals(v, globalMethod(v)); 47 Expect.equals(v, globalMethod(v));
42 Expect.equals(v, globalMethod(value: v)); 48 Expect.equals(v, globalMethod2(value: v));
43 } 49 }
44 50
45 // Test via indirect call. 51 // Test via indirect call.
46 testFunction(obj.method); 52 testFunction(obj.method, obj.method2);
47 testFunction(TestClass.staticMethod); 53 testFunction(TestClass.staticMethod, TestClass.staticMethod2);
48 testFunction(globalMethod); 54 testFunction(globalMethod, globalMethod2);
49 } 55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698