package com.redhat.ceylon.compiler;

import java.util.ArrayList;
import java.util.Arrays;

import org.junit.Assert;
import org.junit.Test;

public class TestOptionParser {

    @Test
    public void test1() {
        ArrayList<String> args = new ArrayList<String>(Arrays.asList("-verbose", "-compact", "-module", "f1.ceylon", "f2.ceylon"));
        Options o = Options.parse(args);
        Assert.assertTrue(o.isVerbose());
        Assert.assertFalse(o.isComment());
        Assert.assertFalse(o.isIndent());
        Assert.assertEquals(2, args.size());
        Assert.assertTrue(args.contains("f1.ceylon"));
        Assert.assertTrue(args.contains("f2.ceylon"));
        Assert.assertTrue(o.getRepos().contains("modules"));
        Assert.assertEquals("modules", o.getOutDir());
        Assert.assertEquals("source", o.getSrcDir());
    }

    @Test
    public void test2() {
        ArrayList<String> args = new ArrayList<String>(Arrays.asList("-rep", "r1", "-user", "username", "-pass", "passwd",
                "-rep", "http://r2/", "f3.ceylon", "-src", "/tmp", "-out", "/tmp"));
        Options o = Options.parse(args);
        Assert.assertTrue(o.isComment());
        Assert.assertTrue(o.isIndent());
        Assert.assertFalse(o.isVerbose());
        Assert.assertTrue(o.getRepos().contains("r1"));
        Assert.assertTrue(o.getRepos().contains("http://r2/"));
        Assert.assertFalse(o.getRepos().contains("modules"));
        Assert.assertEquals("username", o.getUser());
        Assert.assertEquals("passwd", o.getPass());
        Assert.assertEquals("/tmp", o.getSrcDir());
        Assert.assertEquals("/tmp", o.getOutDir());
    }

}

@@ -82,16 +82,39 @@
 .Arrays;
+%0Aimport java.util.List;
 %0A%0Aimport
@@ -320,16 +320,18 @@
 act%22, %22-
+no
 module%22,
@@ -721,34 +721,24 @@
 Repos().
-contains(%22modules%22
+isEmpty(
 ));%0A    
@@ -1592,32 +1592,32 @@
 o.getSrcDir());%0A
-
         Assert.a
@@ -1659,10 +1659,528 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testRepos() %7B%0A        ArrayList%3CString%3E args = new ArrayList%3CString%3E(Arrays.asList(%22-rep%22, %22r1%22, %22-rep%22, %22r2%22, %22-rep%22, %22r3%22, %22other%22));%0A        List%3CString%3E repos = Options.findRepos(args, true);%0A        Assert.assertEquals(3, repos.size());%0A        Assert.assertEquals(1, args.size());%0A        Assert.assertTrue(args.contains(%22other%22));%0A        Assert.assertTrue(repos.contains(%22r1%22));%0A        Assert.assertTrue(repos.contains(%22r2%22));%0A        Assert.assertTrue(repos.contains(%22r3%22));%0A    %7D%0A%0A
 %7D%0A

Add more CLI parsing tests