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

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

Issue 232213003: Allow function literals in string interpolation (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9 class FunctionLiteralsTest { 9 class FunctionLiteralsTest {
10 10
(...skipping 28 matching lines...) Expand all
39 Expect.equals(false, isOdd(8)); 39 Expect.equals(false, isOdd(8));
40 40
41 var b = new B(10); 41 var b = new B(10);
42 Expect.equals(10, b.n); 42 Expect.equals(10, b.n);
43 Expect.equals(100, (b.f)(10)); 43 Expect.equals(100, (b.f)(10));
44 44
45 b = new B.withZ(10); 45 b = new B.withZ(10);
46 Expect.equals(10, b.n); 46 Expect.equals(10, b.n);
47 Expect.equals(101, (b.f)(10)); 47 Expect.equals(101, (b.f)(10));
48 48
49 var c = new C(5);
50 Expect.equals("2*x is 10", c.s);
51
49 int x = 0; 52 int x = 0;
50 int y = 1; 53 int y = 1;
51 // make sure this isn't parsed as a generic type 54 // make sure this isn't parsed as a generic type
52 Expect.isTrue(x<y, "foo"); 55 Expect.isTrue(x<y, "foo");
53 } 56 }
54 } 57 }
55 58
56 apply(f, n) { 59 apply(f, n) {
57 return f(n); 60 return f(n);
58 } 61 }
59 62
60 bool isOdd(b) => b % 2 == 1; 63 bool isOdd(b) => b % 2 == 1;
61 64
62 class A { 65 class A {
63 int f; 66 int f;
64 int f2; 67 int f2;
65 A(p) : f = apply((j) => 2 - j, p) { /* constr. body */ f2 = -p; } 68 A(p) : f = apply((j) => 2 - j, p) { /* constr. body */ f2 = -p; }
66 A.n(p) : f = 1 + apply((j) => 2 - j, p) { /* constr. body */ f2 = -f; } 69 A.n(p) : f = 1 + apply((j) => 2 - j, p) { /* constr. body */ f2 = -f; }
67 } 70 }
68 71
69 class B { 72 class B {
70 var f; 73 var f;
71 int n; 74 int n;
72 B(z) : f = ((x) => x * x) { n = z; } 75 B(z) : f = ((x) => x * x) { n = z; }
73 B.withZ(z) : f = ((x) { return x * x + 1; }) { n = z; } 76 B.withZ(z) : f = ((x) { return x * x + 1; }) { n = z; }
74 } 77 }
75 78
79 class C {
80 String s;
81 C(x) : s = "2*x is ${() { return 2*x; }()}";
82 }
76 main() { 83 main() {
77 FunctionLiteralsTest.testMain(); 84 FunctionLiteralsTest.testMain();
78 } 85 }
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698