Index: tests/corelib/expando_test.dart |
diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart |
index 614b1be25e4e00a3833505718fc771923a9ad9c2..f64fdc4509ad30a472bb05b74b371a96a7033822 100644 |
--- a/tests/corelib/expando_test.dart |
+++ b/tests/corelib/expando_test.dart |
@@ -2,109 +2,80 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-const Expando<int> visits = const Expando<int>('visits'); |
- |
-main() { |
- var legal = [ new Object(), |
- new List(), [1,2,3], const [1,2,3], |
- new Map(), {'x':1,'y':2}, const {'x':1,'y':2}, |
- new Expando(), new Expando('horse') ]; |
- for (var object in legal) { |
- testNamedExpando(object); |
- testUnnamedExpando(object); |
- testConstExpando(object); |
- } |
- for (var object in legal) { |
- Expect.equals(3, visits[object]); |
+class ExpandoTest { |
+ static Expando<int> visits; |
+ |
+ static testMain() { |
+ visits = new Expando<int>('visits'); |
+ var legal = [ new Object(), |
+ new List(), [1,2,3], const [1,2,3], |
+ new Map(), {'x':1,'y':2}, const {'x':1,'y':2}, |
+ new Expando(), new Expando('horse') ]; |
+ for (var object in legal) { |
+ testNamedExpando(object); |
+ testUnnamedExpando(object); |
+ } |
+ for (var object in legal) { |
+ Expect.equals(2, visits[object]); |
+ } |
+ testIllegal(); |
} |
- testIllegal(); |
-} |
- |
-visit(object) { |
- int count = visits[object]; |
- count = (count === null) ? 1 : count + 1; |
- visits[object] = count; |
-} |
- |
-testNamedExpando(object) { |
- Expando<int> expando = new Expando<int>('myexpando'); |
- Expect.equals('myexpando', expando.name); |
- Expect.isTrue(expando.toString().startsWith('Expando:myexpando')); |
- testExpando(expando, object); |
-} |
- |
-testUnnamedExpando(object) { |
- Expando<int> expando = new Expando<int>(); |
- Expect.isNull(expando.name); |
- Expect.isTrue(expando.toString().startsWith('Expando:')); |
- testExpando(expando, object); |
-} |
- |
-testExpando(Expando<int> expando, object) { |
- visit(object); |
- |
- Expect.isNull(expando[object]); |
- expando[object] = 42; |
- Expect.equals(42, expando[object]); |
- expando[object] = null; |
- Expect.isNull(expando[object]); |
- Expando<int> alternative = new Expando('myexpando'); |
- Expect.isNull(alternative[object]); |
- alternative[object] = 87; |
- Expect.isNull(expando[object]); |
- expando[object] = 99; |
- Expect.equals(99, expando[object]); |
- Expect.equals(87, alternative[object]); |
-} |
- |
-testConstExpando(object) { |
- visit(object); |
- |
- var e0 = const Expando<int>('horse'); |
- var e1 = const Expando<int>('horse'); |
- var e2 = new Expando<int>('horse'); |
- var e3 = new Expando<int>('horse'); |
- |
- e0[object] = 0; |
- Expect.equals(0, e0[object]); |
+ static visit(object) { |
+ int count = visits[object]; |
+ count = (count === null) ? 1 : count + 1; |
+ visits[object] = count; |
+ } |
- e1[object] = 1; |
- Expect.equals(1, e0[object]); |
- Expect.equals(1, e1[object]); |
+ static testNamedExpando(object) { |
+ Expando<int> expando = new Expando<int>('myexpando'); |
+ Expect.equals('myexpando', expando.name); |
+ Expect.isTrue(expando.toString().startsWith('Expando:myexpando')); |
+ testExpando(expando, object); |
+ } |
- e2[object] = 2; |
- Expect.equals(1, e0[object]); |
- Expect.equals(1, e1[object]); |
- Expect.equals(2, e2[object]); |
+ static testUnnamedExpando(object) { |
+ Expando<int> expando = new Expando<int>(); |
+ Expect.isNull(expando.name); |
+ Expect.isTrue(expando.toString().startsWith('Expando:')); |
+ testExpando(expando, object); |
+ } |
- e3[object] = 3; |
- Expect.equals(1, e0[object]); |
- Expect.equals(1, e1[object]); |
- Expect.equals(2, e2[object]); |
- Expect.equals(3, e3[object]); |
+ static testExpando(Expando<int> expando, object) { |
+ visit(object); |
+ |
+ Expect.isNull(expando[object]); |
+ expando[object] = 42; |
+ Expect.equals(42, expando[object]); |
+ expando[object] = null; |
+ Expect.isNull(expando[object]); |
+ |
+ Expando<int> alternative = new Expando('myexpando'); |
+ Expect.isNull(alternative[object]); |
+ alternative[object] = 87; |
+ Expect.isNull(expando[object]); |
+ expando[object] = 99; |
+ Expect.equals(99, expando[object]); |
+ Expect.equals(87, alternative[object]); |
+ } |
- e0[object] = null; |
- Expect.isNull(e0[object]); |
- Expect.isNull(e1[object]); |
- Expect.equals(2, e2[object]); |
- Expect.equals(3, e3[object]); |
+ static testIllegal() { |
+ Expando<int> expando = new Expando<int>(); |
+ Expect.throws(() => expando[null], (exception) |
+ => exception is NullPointerException); |
+ Expect.throws(() => expando['string'], (exception) |
+ => exception is IllegalArgumentException); |
+ Expect.throws(() => expando['string'], (exception) |
+ => exception is IllegalArgumentException); |
+ Expect.throws(() => expando[42], (exception) |
+ => exception is IllegalArgumentException); |
+ Expect.throws(() => expando[42.87], (exception) |
+ => exception is IllegalArgumentException); |
+ Expect.throws(() => expando[true], (exception) |
+ => exception is IllegalArgumentException); |
+ Expect.throws(() => expando[false], (exception) |
+ => exception is IllegalArgumentException); |
+ } |
} |
-testIllegal() { |
- Expando<int> expando = new Expando<int>(); |
- Expect.throws(() => expando[null], (exception) |
- => exception is NullPointerException); |
- Expect.throws(() => expando['string'], (exception) |
- => exception is IllegalArgumentException); |
- Expect.throws(() => expando['string'], (exception) |
- => exception is IllegalArgumentException); |
- Expect.throws(() => expando[42], (exception) |
- => exception is IllegalArgumentException); |
- Expect.throws(() => expando[42.87], (exception) |
- => exception is IllegalArgumentException); |
- Expect.throws(() => expando[true], (exception) |
- => exception is IllegalArgumentException); |
- Expect.throws(() => expando[false], (exception) |
- => exception is IllegalArgumentException); |
-} |
+main() => ExpandoTest.testMain(); |