This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
forked from alecthomas/chroma
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from wakatime/mason-lexer-text-analysis
Add set text analyser for Mason lexer
- Loading branch information
Showing
4 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package m_test | ||
|
||
import ( | ||
"io/ioutil" | ||
"testing" | ||
|
||
"github.com/alecthomas/assert" | ||
"github.com/alecthomas/chroma" | ||
"github.com/alecthomas/chroma/lexers/m" | ||
) | ||
|
||
func TestMason_AnalyseText(t *testing.T) { | ||
tests := map[string]struct { | ||
Filepath string | ||
Expected float32 | ||
}{ | ||
"unnamed block": { | ||
Filepath: "testdata/mason_unnamed_block.m", | ||
Expected: 1.0, | ||
}, | ||
"calling component": { | ||
Filepath: "testdata/mason_calling_component.m", | ||
Expected: 0.11, | ||
}, | ||
} | ||
|
||
for name, test := range tests { | ||
test := test | ||
t.Run(name, func(t *testing.T) { | ||
data, err := ioutil.ReadFile(test.Filepath) | ||
assert.NoError(t, err) | ||
|
||
analyser, ok := m.Mason.(chroma.Analyser) | ||
assert.True(t, ok) | ||
|
||
assert.Equal(t, test.Expected, analyser.AnalyseText(string(data))) | ||
}) | ||
} | ||
} |
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,4 @@ | ||
<& | ||
/path/to/comp.mi, | ||
name=>value | ||
&> |
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,5 @@ | ||
<%class> | ||
has 'foo'; | ||
has 'bar' => (required => 1); | ||
has 'baz' => (isa => 'Int', default => 17); | ||
</%class> |