Permalink
Browse files

tests for updated hlint parser

  • Loading branch information...
JPMoresmau committed Aug 24, 2011
1 parent 1c17f82 commit d65f2424d75ecd06a4c81c1e9ebd3157d10d2b95
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/net.sf.eclipsefp.haskell.hlint"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>net.sf.eclipsefp.haskell.hlint.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,12 @@
+#Wed Aug 24 18:49:56 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
@@ -0,0 +1,62 @@
+package net.sf.eclipsefp.haskell.hlint.parser;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import net.sf.eclipsefp.haskell.hlint.CodeModificationText;
+import net.sf.eclipsefp.haskell.hlint.SourceLocation;
+import net.sf.eclipsefp.haskell.hlint.Suggestion;
+
+import org.junit.Test;
+
+/**
+ * Tests the hlint output parser
+ * @author JP Moresmau
+ *
+ */
+public class OutputParserTest {
+
+ @Test
+ public void testWindowsLongPath() throws Exception{
+ //File f=new File("test.txt");
+ OutputParser p=new OutputParser(OutputParserTest.class.getResourceAsStream("testW.txt"));
+ List<Suggestion> sugs=p.suggestions();
+ assertNotNull(sugs);
+ assertEquals(3, sugs.size());
+ Suggestion sug=sugs.get(0);
+ assertEquals("Unused LANGUAGE pragma",sug.getMessage());
+ SourceLocation sl=sug.getLocation();
+ assertNotNull(sl);
+ assertEquals("D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs",sl.getFilename());
+ assertEquals(1,sl.getLine());
+ assertEquals(1,sl.getColumn());
+ assertTrue(sug.getPre() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,\n PatternGuards #-}",((CodeModificationText)sug.getPre()).getText());
+ assertTrue(sug.getPost() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}",((CodeModificationText)sug.getPost()).getText());
+ }
+
+ @Test
+ public void testUnixLongPath() throws Exception{
+ //File f=new File("test.txt");
+ OutputParser p=new OutputParser(OutputParserTest.class.getResourceAsStream("testU.txt"));
+ List<Suggestion> sugs=p.suggestions();
+ assertNotNull(sugs);
+ assertEquals(3, sugs.size());
+ Suggestion sug=sugs.get(0);
+ assertEquals("Unused LANGUAGE pragma",sug.getMessage());
+ SourceLocation sl=sug.getLocation();
+ assertNotNull(sl);
+ assertEquals("/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs",sl.getFilename());
+ assertEquals(1,sl.getLine());
+ assertEquals(1,sl.getColumn());
+ assertTrue(sug.getPre() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,\n PatternGuards #-}",((CodeModificationText)sug.getPre()).getText());
+ assertTrue(sug.getPost() instanceof CodeModificationText);
+ assertEquals("{-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}",((CodeModificationText)sug.getPost()).getText());
+ }
+
+}
@@ -0,0 +1,20 @@
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:1:1: Error: Unused LANGUAGE pragma
+Found:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,
+ PatternGuards #-}
+Why not:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}
+
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:92:14: Error: Redundant do
+Found:
+ do (c :) `fmap` munchmunch (c == '\\')
+Why not:
+ (c :) `fmap` munchmunch (c == '\\')
+
+/dev/haskell/jp-github/runtime-New_configuration/scion/server/Scion/Server/Protocol.hs:96:10: Warning: Use fmap
+Found:
+ munch1 isDigit >>= return . read
+Why not:
+ fmap read (munch1 isDigit)
+
+3 suggestions
@@ -0,0 +1,20 @@
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:1:1: Error: Unused LANGUAGE pragma
+Found:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances,
+ PatternGuards #-}
+Why not:
+ {-# LANGUAGE ExistentialQuantification, TypeSynonymInstances #-}
+
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:92:14: Error: Redundant do
+Found:
+ do (c :) `fmap` munchmunch (c == '\\')
+Why not:
+ (c :) `fmap` munchmunch (c == '\\')
+
+D:\\dev\\haskell\\jp-github\\runtime-New_configuration\\scion\\server\\Scion\\Server\\Protocol.hs:96:10: Warning: Use fmap
+Found:
+ munch1 isDigit >>= return . read
+Why not:
+ fmap read (munch1 isDigit)
+
+3 suggestions
Oops, something went wrong.

0 comments on commit d65f242

Please sign in to comment.