comparison truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java @ 22394:f56fa795a5a5

SourceSection: clearify string representations, add tests
author Andreas Woess <andreas.woess@oracle.com>
date Thu, 19 Nov 2015 15:58:26 +0100
parents 0e13cbebc04c
children 7a147c6abace
comparison
equal deleted inserted replaced
22393:ab33db2c148c 22394:f56fa795a5a5
36 36
37 private final Source emptyLineSource = Source.fromText("\n", null); 37 private final Source emptyLineSource = Source.fromText("\n", null);
38 38
39 private final Source shortSource = Source.fromText("01", null); 39 private final Source shortSource = Source.fromText("01", null);
40 40
41 private final Source longSource = Source.fromText("01234\n67\n9\n", null); 41 private final Source longSource = Source.fromText("01234\n67\n9\n", "long");
42 42
43 public void emptySourceTest0() { 43 public void emptySourceTest0() {
44 SourceSection section = emptySource.createSection("test", 0, 0); 44 SourceSection section = emptySource.createSection("test", 0, 0);
45 assertNotNull(section); 45 assertNotNull(section);
46 assertEquals(section.getCode(), ""); 46 assertEquals(section.getCode(), "");
82 SourceSection section = longSource.createSection("test", 0, 0); 82 SourceSection section = longSource.createSection("test", 0, 0);
83 assertNotNull(section); 83 assertNotNull(section);
84 assertEquals(section.getCode(), ""); 84 assertEquals(section.getCode(), "");
85 } 85 }
86 86
87 @Test
88 public void testGetCode() {
89 assertEquals("01234", longSource.createSection("test", 0, 5).getCode());
90 assertEquals("67", longSource.createSection("test", 6, 2).getCode());
91 assertEquals("9", longSource.createSection("test", 9, 1).getCode());
92 }
93
94 @Test
95 public void testGetShortDescription() {
96 assertEquals("long:1", longSource.createSection("test", 0, 5).getShortDescription());
97 assertEquals("long:2", longSource.createSection("test", 6, 2).getShortDescription());
98 assertEquals("long:3", longSource.createSection("test", 9, 1).getShortDescription());
99 }
87 } 100 }