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

Side by Side Diff: tests/language/src/PseudoKWTest.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
« no previous file with comments | « tests/language/src/PseudoKWIllegalTest.dart ('k') | tests/language/src/RawStringTest.dart » ('j') | 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) 2012, 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 // Check that we can use pseudo keywords as names in function level code.
5
6
7 class PseudoKWTest {
8 static testMain() {
9
10 // This is a list of built-in identifiers from the Dart spec.
11 // It sanity checks that these pseudo-keywords are legal identifiers.
12
13 var abstract = 0;
14 var assert = 0;
15 var call = 0;
16 var Dynamic = 0;
17 var factory = 0;
18 var get = 0;
19 var implements = 0;
20 var import = 0;
21 var interface = 0;
22 var library = 0;
23 var negate = 0;
24 var operator = 0;
25 var set = 0;
26 var source = 0;
27 var static = 0;
28 var typedef = 0;
29
30 // "native" is a per-implementation extension that is not a part of the
31 // Dart language. While it is not an official built-in identifier, it
32 // is useful to ensure that it remains a legal identifier.
33 var native = 0;
34
35
36 // The code below adds a few additional variants of usage without any
37 // attempt at complete coverage.
38 {
39 void factory(set) {
40 return 0;
41 }
42 }
43
44 get: while (import > 0) {
45 break get;
46 }
47
48 return static + library * operator;
49 }
50 }
51
52 typedef(x) => "typedef " + x;
53
54 static(abstract) {
55 return abstract == true;
56 }
57
58 class A {
59 var typedef = 0;
60 final operator = "smooth";
61
62 set(x) { typedef = x; }
63 get() => typedef - 5;
64
65 static static() {
66 return 1;
67 }
68 static check() {
69 var o = new A();
70 o.set(55);
71 Expect.equals(50, o.get());
72 static();
73 }
74 }
75
76 class B {
77 var set = 100;
78 get get() => set;
79 set get(get) => set = 2 * get.get;
80
81 static() {
82 var set = new B();
83 set.get = set;
84 Expect.equals(200, set.get);
85 }
86 int operator() {
87 return 1;
88 }
89 }
90
91 class C {
92 static int operator = (5);
93 static var get;
94 static get set() => 111;
95 static set set(set) { }
96 }
97
98
99 main() {
100 PseudoKWTest.testMain();
101 A.check();
102 new B().static();
103 Expect.equals(1, new B().operator());
104 Expect.equals(1, A.static());
105 typedef("T");
106 Expect.equals("typedef T", typedef("T"));
107 static("true");
108 Expect.equals(false, static("true"));
109 Expect.equals(5, C.operator);
110 Expect.equals(null, C.get);
111 C.set = 0;
112 Expect.equals(111, C.set);
113 }
OLDNEW
« no previous file with comments | « tests/language/src/PseudoKWIllegalTest.dart ('k') | tests/language/src/RawStringTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698