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

Side by Side Diff: tests/corelib/expando_test.dart

Issue 10534089: Add experimental expando support. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test case. Created 8 years, 6 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/corelib/corelib.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) 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
5 main() {
6 var legal = [ new Object(),
7 new List(), [1,2,3], const [1,2,3],
8 new Map(), {'x':1,'y':2}, const {'x':1,'y':2},
9 new Expando(), new Expando('horse') ];
10 for (var object in legal) {
11 testNamedExpando(object);
12 testUnnamedExpando(object);
13 }
Ivan Posva 2012/06/11 12:08:08 Currently you are only testing adding a specific e
kasperl 2012/06/11 12:44:39 Done.
14 testIllegal();
15 }
16
17 testNamedExpando(object) {
18 Expando<int> expando = new Expando<int>('myexpando');
19 Expect.equals('myexpando', expando.name);
20 Expect.isTrue(expando.toString().startsWith('Expando:myexpando'));
21 testExpando(expando, object);
22 }
23
24 testUnnamedExpando(object) {
25 Expando<int> expando = new Expando<int>();
26 Expect.isNull(expando.name);
27 Expect.isTrue(expando.toString().startsWith('Expando:'));
28 testExpando(expando, object);
29 }
30
31 testExpando(Expando<int> expando, object) {
32 Expect.isNull(expando[object]);
33 expando[object] = 42;
34 Expect.equals(42, expando[object]);
35 expando[object] = null;
36 Expect.isNull(expando[object]);
37
38 Expando<int> alternative = new Expando('myexpando');
Ivan Posva 2012/06/11 12:08:08 You might also want to do this while having the or
kasperl 2012/06/11 12:44:39 Done.
39 Expect.isNull(alternative[object]);
40 alternative[object] = 87;
41 Expect.isNull(expando[object]);
42 Expect.equals(87, alternative[object]);
43 }
44
45 testIllegal() {
46 Expando<int> expando = new Expando<int>();
47 Expect.throws(() => expando[null], (exception)
48 => exception is NullPointerException);
49 Expect.throws(() => expando['string'], (exception)
50 => exception is IllegalArgumentException);
51 Expect.throws(() => expando['string'], (exception)
52 => exception is IllegalArgumentException);
53 Expect.throws(() => expando[42], (exception)
54 => exception is IllegalArgumentException);
55 Expect.throws(() => expando[42.87], (exception)
56 => exception is IllegalArgumentException);
57 Expect.throws(() => expando[true], (exception)
58 => exception is IllegalArgumentException);
59 Expect.throws(() => expando[false], (exception)
60 => exception is IllegalArgumentException);
61 }
OLDNEW
« no previous file with comments | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698