-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consider something a builtin when there's no
sourceSpan
(#32)
* Consider something a builtin when there's no sourceSpan * Refactor `extractPackageName` * Use module name to check if a declaration is built-in * Recognize `Prim` module as built-in; add tests * Code style Fix #31 Co-authored-by: Vladimir Kalnitsky <[email protected]>
- Loading branch information
Showing
4 changed files
with
65 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module Test.Declarations where | ||
|
||
import Prelude | ||
|
||
import Data.Maybe (Maybe(..)) | ||
import Docs.Search.Declarations (extractPackageName) | ||
|
||
import Test.Unit (TestSuite, suite, test) | ||
import Test.Unit.Assert as Assert | ||
|
||
tests :: TestSuite | ||
tests = do | ||
suite "Declarations" do | ||
test "extractPackageName" do | ||
Assert.equal "<builtin>" (extractPackageName "Prim" Nothing) | ||
Assert.equal "<builtin>" (extractPackageName "Prim.Foo" Nothing) | ||
Assert.equal "<builtin>" (extractPackageName "Prim.Foo.Bar" Nothing) | ||
Assert.equal "<unknown>" (extractPackageName "Primitive" Nothing) | ||
Assert.equal "foo" | ||
(extractPackageName "Foo" $ | ||
Just { start: [] | ||
, end: [] | ||
, name: ".spago/foo/src/Foo.purs" | ||
} | ||
) | ||
Assert.equal "bar" | ||
(extractPackageName "Bar" $ | ||
Just { start: [] | ||
, end: [] | ||
, name: "/path/to/somewhere/bower_components/bar/src/Bar.purs" | ||
} | ||
) | ||
Assert.equal "<local package>" | ||
(extractPackageName "Bar" $ | ||
Just { start: [] | ||
, end: [] | ||
, name: "/path/to/somewhere/src/Bar.purs" | ||
} | ||
) |