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

Side by Side Diff: tests/language/src/NamedParametersPassingFalsyTest.dart

Issue 10248007: test rename overhaul: step 8 - language tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Dart test program for testing named parameters with various values that might
6 // be implemented as 'falsy' values in a JavaScript implementation.
7
8
9 class TestClass {
10 TestClass();
11
12 method([value = 100]) => value;
13
14 static staticMethod([value = 200]) => value;
15 }
16
17 globalMethod([value = 300]) => value;
18
19 final testValues = const [0, 0.0, '', false, null];
20
21 testFunction(f) {
22 Expect.isTrue(f() >= 100);
23 for (var v in testValues) {
24 Expect.equals(v, f(v));
25 Expect.equals(v, f(value: v));
26 }
27 }
28
29 main() {
30 var obj = new TestClass();
31
32 Expect.equals(100, obj.method());
33 Expect.equals(200, TestClass.staticMethod());
34 Expect.equals(300, globalMethod());
35
36 for (var v in testValues) {
37 Expect.equals(v, obj.method(v));
38 Expect.equals(v, obj.method(value: v));
39 Expect.equals(v, TestClass.staticMethod(v));
40 Expect.equals(v, TestClass.staticMethod(value: v));
41 Expect.equals(v, globalMethod(v));
42 Expect.equals(v, globalMethod(value: v));
43 }
44
45 // Test via indirect call.
46 testFunction(obj.method);
47 testFunction(TestClass.staticMethod);
48 testFunction(globalMethod);
49 }
OLDNEW
« no previous file with comments | « tests/language/src/NamedParametersPassingFalseTest.dart ('k') | tests/language/src/NamedParametersPassingNullTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698