package alabno.simple_haskell_marker;

import java.util.List;

import org.junit.Test;

import static org.junit.Assert.*;

public class HaskellSplitterTest {

    final boolean PRINT_RESULTS = false;
    
    String filePath = "samples/sequences_model.hs";

    @Test
    public void isEmptyTest() {
        String test1 = "hello\nworld";
        String test2 = "\n\n  \n";
        String test3 = "\n";
        
        HaskellSplitter splitter = new HaskellSplitter(filePath);
        
        assertTrue(!splitter.isEmpty(test1));
        
        assertTrue(splitter.isEmpty(test2));
        
        assertTrue(splitter.isEmpty(test3));
    }
    
    /**
     * Tests the splitter on the whole input Haskell file
     */
    @Test
    public void splitTest1() {
        HaskellSplitter splitter = new HaskellSplitter(filePath);
        List<HaskellBlock> output = splitter.split();
        if (PRINT_RESULTS) {
            for (int i = 0; i < output.size(); i++) {
//                System.out.println(i + "\t" + output.get(i).getBlockText());
                System.out.println(i + "\t" + output.get(i));
            }
        }
        assertEquals(output.size(), 20);
        
        assertEquals(output.get(1).getLineNumber(), 3);
        assertEquals(output.get(15).getLineNumber(), 73);
        assertEquals(output.get(16).getLineNumber(), 77);
        assertEquals(output.get(19).getLineNumber(), 85);
        
        assertTrue(output.get(0).getBlockText().contains("module Sequences"));
        assertTrue(output.get(10).getBlockText().contains("Char -> Char"));
        assertTrue(output.get(19).getBlockText().contains("(n + 1)) / (1 - r)"));
    }

}

@@ -232,23 +232,13 @@
 les/
-sequences_model
+macro
 .hs%22
@@ -1157,495 +1157,10 @@
 (), 
-20);%0A        %0A        assertEquals(output.get(1).getLineNumber(), 3);%0A        assertEquals(output.get(15).getLineNumber(), 73);%0A        assertEquals(output.get(16).getLineNumber(), 77);%0A        assertEquals(output.get(19).getLineNumber(), 85);%0A        %0A        assertTrue(output.get(0).getBlockText().contains(%22module Sequences%22));%0A        assertTrue(output.get(10).getBlockText().contains(%22Char -%3E Char%22));%0A        assertTrue(output.get(19).getBlockText().contains(%22(n + 1)) / (1 - r)%22)
+15
 );%0A 

fix test