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

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

Issue 232823002: Allow closures in string literals in initializer expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge. 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 | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, 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 import 'package:expect/expect.dart';
6
7 // Test that function literals are parsed correctly in initializers.
8
9 class A {
10 final x;
11 static foo(f) => f();
12
13 A.parenthesized(y) : x = (() => y);
14 A.stringLiteral(y) : x = "**${() => y}--";
15 A.listLiteral(y) : x = [() => y];
16 A.mapLiteral(y) : x = { "fun": () => y };
17 A.arg(y) : x = foo(() => y);
18 }
19
20 main() {
21 var a, f;
22 a = new A.parenthesized(499);
23 f = a.x;
24 Expect.isTrue(f is Function);
25 Expect.equals(499, f());
26
27 // The toString of closures is not specified. Just make sure that there is no
28 // crash.
29 a = new A.stringLiteral(42);
30 Expect.isTrue(a.x.startsWith("**"));
31 Expect.isTrue(a.x.endsWith("--"));
32
33 a = new A.listLiteral(99);
34 f = a.x[0];
35 Expect.isTrue(f is Function);
36 Expect.equals(99, f());
37
38 a = new A.mapLiteral(314);
39 f = a.x["fun"];
40 Expect.isTrue(f is Function);
41 Expect.equals(314, f());
42
43 a = new A.arg(123);
44 Expect.equals(123, a.x);
45 }
OLDNEW
« no previous file with comments | « tests/language/language_dart2js.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698