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

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

Issue 10905109: Add named constructor name checking (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 for new function type alias. 5 // Dart test for new function type alias.
6 6
7 class FunctionLiteralsTest { 7 class FunctionLiteralsTest {
8 8
9 static void testMain() { 9 static void testMain() {
10 f(x) { return x * 2;} 10 f(x) { return x * 2;}
(...skipping 22 matching lines...) Expand all
33 Expect.equals(-2, a.f); 33 Expect.equals(-2, a.f);
34 Expect.equals(2, a.f2); 34 Expect.equals(2, a.f2);
35 35
36 Expect.equals(true, isOdd(5)); 36 Expect.equals(true, isOdd(5));
37 Expect.equals(false, isOdd(8)); 37 Expect.equals(false, isOdd(8));
38 38
39 var b = new B(10); 39 var b = new B(10);
40 Expect.equals(10, b.n); 40 Expect.equals(10, b.n);
41 Expect.equals(100, (b.f)(10)); 41 Expect.equals(100, (b.f)(10));
42 42
43 b = new B.n(10); 43 b = new B.withZ(10);
44 Expect.equals(10, b.n); 44 Expect.equals(10, b.n);
45 Expect.equals(101, (b.f)(10)); 45 Expect.equals(101, (b.f)(10));
46 46
47 int x = 0; 47 int x = 0;
48 int y = 1; 48 int y = 1;
49 // make sure this isn't parsed as a generic type 49 // make sure this isn't parsed as a generic type
50 Expect.isTrue(x<y, "foo"); 50 Expect.isTrue(x<y, "foo");
51 } 51 }
52 } 52 }
53 53
54 apply(f, n) { 54 apply(f, n) {
55 return f(n); 55 return f(n);
56 } 56 }
57 57
58 bool isOdd(b) => b % 2 == 1; 58 bool isOdd(b) => b % 2 == 1;
59 59
60 class A { 60 class A {
61 int f; 61 int f;
62 int f2; 62 int f2;
63 A(p) : f = apply((j) => 2 - j, p) { /* constr. body */ f2 = -p; } 63 A(p) : f = apply((j) => 2 - j, p) { /* constr. body */ f2 = -p; }
64 A.n(p) : f = 1 + apply((j) => 2 - j, p) { /* constr. body */ f2 = -f; } 64 A.n(p) : f = 1 + apply((j) => 2 - j, p) { /* constr. body */ f2 = -f; }
65 } 65 }
66 66
67 class B { 67 class B {
68 var f; 68 var f;
69 int n; 69 int n;
70 B(z) : f = ((x) => x * x) { n = z; } 70 B(z) : f = ((x) => x * x) { n = z; }
71 B.n(z) : f = ((x) { return x * x + 1; }) { n = z; } 71 B.withZ(z) : f = ((x) { return x * x + 1; }) { n = z; }
72 } 72 }
73 73
74 main() { 74 main() {
75 FunctionLiteralsTest.testMain(); 75 FunctionLiteralsTest.testMain();
76 } 76 }
OLDNEW
« tests/language/bad_constructor_test.dart ('K') | « tests/language/bad_constructor_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698