Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Check that we can use pseudo keywords as names in function level code. | 4 // Check that we can use pseudo keywords as names in function level code. |
| 5 | 5 |
| 6 | 6 |
| 7 class PseudoKWTest { | 7 class PseudoKWTest { |
| 8 static testMain() { | 8 static testMain() { |
| 9 | 9 |
| 10 // This is a list of built-in identifiers from the Dart spec. | 10 // This is a list of built-in identifiers from the Dart spec. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 } | 42 } |
| 43 | 43 |
| 44 get: while (import > 0) { | 44 get: while (import > 0) { |
| 45 break get; | 45 break get; |
| 46 } | 46 } |
| 47 | 47 |
| 48 return static + library * operator; | 48 return static + library * operator; |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 typedef(x) => "typedef " + x; | |
| 53 | |
| 54 static(abstract) { | |
| 55 return abstract == true; | |
| 56 } | |
| 57 | |
| 58 class A { | |
| 59 var typedef = 0; | |
| 60 set(x) { typedef = x; } | |
| 61 get() => typedef - 5; | |
| 62 | |
| 63 static static() { | |
| 64 return 1; | |
| 65 } | |
| 66 static check() { | |
| 67 var o = new A(); | |
| 68 o.set(55); | |
| 69 Expect.equals(50, o.get()); | |
| 70 static(); | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 class B { | |
| 75 var abstract; | |
| 76 get get() => abstract; | |
| 77 set get(x) => abstract = 2 * x; | |
|
siva
2012/01/13 18:48:20
set get(B get) => abstract = 2 * get.get?
hausner
2012/01/13 19:22:47
Nice :) I made it even more pathological and promp
| |
| 78 | |
| 79 static() { | |
| 80 var o = new B(); | |
| 81 o.get = 100; | |
| 82 Expect.equals(200, o.get); | |
| 83 } | |
| 84 int operator() { | |
| 85 return 1; | |
| 86 } | |
| 87 } | |
| 88 | |
| 52 | 89 |
| 53 main() { | 90 main() { |
| 54 PseudoKWTest.testMain(); | 91 PseudoKWTest.testMain(); |
| 92 A.check(); | |
| 93 new B().static(); | |
| 94 Expect.equals(1, new B().operator()); | |
| 95 Expect.equals(1, A.static()); | |
| 96 typedef("T"); | |
| 97 Expect.equals("typedef T", typedef("T")); | |
| 98 static("true"); | |
| 99 Expect.equals(false, static("true")); | |
| 55 } | 100 } |
| OLD | NEW |