PageRenderTime 17ms CodeModel.GetById 12ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/reactive-pattern-matching/test/edu/vub/at/objects/natives/TestFieldMap.java

http://ambienttalk.googlecode.com/
Java | 56 lines | 32 code | 7 blank | 17 comment | 0 complexity | 447e4e557545e3f214037496f377b408 MD5 | raw file
 1package edu.vub.at.objects.natives;
 2
 3import edu.vub.at.AmbientTalkTestCase;
 4import edu.vub.at.objects.natives.grammar.AGSymbol;
 5
 6/**
 7 * @author tvc
 8 *
 9 * A Unit Test for the FieldMap class.
10 * Tests the Field Map's behaviour for adding and looking up field names.
11 */
12public class TestFieldMap extends AmbientTalkTestCase {
13
14	public static void main(String[] args) {
15		junit.swingui.TestRunner.run(TestFieldMap.class);
16	}
17
18	private FieldMap map_;
19
20	/**
21	 * Constructs the map
22	 * [ x -> 0
23	 *   y -> 1
24	 *   z -> 2
25	 *   u -> 3
26	 *   v -> 4
27	 *   w -> 5
28	 *   a -> 6
29	 *   b -> 7 ]
30	 */
31	protected void setUp() throws Exception {
32		map_ = new FieldMap();
33		assertTrue(map_.put(AGSymbol.jAlloc("x")));
34		map_.put(AGSymbol.jAlloc("y"));
35		map_.put(AGSymbol.jAlloc("z"));
36		map_.put(AGSymbol.jAlloc("u"));
37		assertTrue(map_.put(AGSymbol.jAlloc("v")));
38		map_.put(AGSymbol.jAlloc("w"));
39		map_.put(AGSymbol.jAlloc("a"));
40		map_.put(AGSymbol.jAlloc("b"));
41		assertFalse(map_.put(AGSymbol.jAlloc("x")));
42	}
43
44	public void testMap() {
45		assertEquals(0, map_.get(AGSymbol.jAlloc("x")));
46		assertEquals(1, map_.get(AGSymbol.jAlloc("y")));
47		assertEquals(2, map_.get(AGSymbol.jAlloc("z")));
48		assertEquals(3, map_.get(AGSymbol.jAlloc("u")));
49		assertEquals(4, map_.get(AGSymbol.jAlloc("v")));
50		assertEquals(5, map_.get(AGSymbol.jAlloc("w")));
51		assertEquals(6, map_.get(AGSymbol.jAlloc("a")));
52		assertEquals(7, map_.get(AGSymbol.jAlloc("b")));
53		assertEquals(-1, map_.get(AGSymbol.jAlloc("c")));
54	}
55
56}