diff 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
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java	Mon Nov 16 18:00:16 2015 +0100
+++ b/truffle/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java	Thu Nov 19 15:58:26 2015 +0100
@@ -38,7 +38,7 @@
 
     private final Source shortSource = Source.fromText("01", null);
 
-    private final Source longSource = Source.fromText("01234\n67\n9\n", null);
+    private final Source longSource = Source.fromText("01234\n67\n9\n", "long");
 
     public void emptySourceTest0() {
         SourceSection section = emptySource.createSection("test", 0, 0);
@@ -84,4 +84,17 @@
         assertEquals(section.getCode(), "");
     }
 
+    @Test
+    public void testGetCode() {
+        assertEquals("01234", longSource.createSection("test", 0, 5).getCode());
+        assertEquals("67", longSource.createSection("test", 6, 2).getCode());
+        assertEquals("9", longSource.createSection("test", 9, 1).getCode());
+    }
+
+    @Test
+    public void testGetShortDescription() {
+        assertEquals("long:1", longSource.createSection("test", 0, 5).getShortDescription());
+        assertEquals("long:2", longSource.createSection("test", 6, 2).getShortDescription());
+        assertEquals("long:3", longSource.createSection("test", 9, 1).getShortDescription());
+    }
 }