Skip to content

Commit

Permalink
add Imba lang
Browse files Browse the repository at this point in the history
  • Loading branch information
hhatto committed May 6, 2023
1 parent a63bc75 commit 4e992cf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,3 +488,43 @@ func TestAnalayzeReader_OnCallbacks(t *testing.T) {
t.Errorf("invalid logic. lines=%v", lines)
}
}

func TestAnalyzeFile4Imba(t *testing.T) {
tmpfile, err := os.CreateTemp("", "test.imba")
if err != nil {
t.Logf("os.CreateTemp() error. err=[%v]", err)
return
}
defer os.Remove(tmpfile.Name())

if _, err := tmpfile.Write([]byte(`###
This color is my favorite
I need several lines to really
emphasize this fact.
###
const color = "blue"
# this is line comment
`),
); err != nil {
t.Fatalf("tmpfile.Write() error. err=[%v]", err)
}

language := NewLanguage("Imba", []string{"#"}, [][]string{{"###", "###"}})
clocOpts := NewClocOptions()
clocFile := AnalyzeFile(tmpfile.Name(), language, clocOpts)
tmpfile.Close()

if clocFile.Blanks != 1 {
t.Errorf("invalid logic. blanks=%v", clocFile.Blanks)
}
if clocFile.Comments != 6 {
t.Errorf("invalid logic. comments=%v", clocFile.Comments)
}
if clocFile.Code != 1 {
t.Errorf("invalid logic. code=%v", clocFile.Code)
}
if clocFile.Lang != "Imba" {
t.Errorf("invalid logic. lang=%v", clocFile.Lang)
}
}
2 changes: 2 additions & 0 deletions language.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ var Exts = map[string]string{
"hx": "Haxe",
"hxx": "C++ Header",
"idr": "Idris",
"imba": "Imba",
"il": "SKILL",
"ino": "Arduino Sketch",
"io": "Io",
Expand Down Expand Up @@ -529,6 +530,7 @@ func NewDefinedLanguages() *DefinedLanguages {
"HLSL": NewLanguage("HLSL", []string{"//"}, [][]string{{"/*", "*/"}}),
"HTML": NewLanguage("HTML", []string{"//", "<!--"}, [][]string{{"<!--", "-->"}}),
"Idris": NewLanguage("Idris", []string{"--"}, [][]string{{"{-", "-}"}}),
"Imba": NewLanguage("Imba", []string{"#"}, [][]string{{"###", "###"}}),
"Io": NewLanguage("Io", []string{"//", "#"}, [][]string{{"/*", "*/"}}),
"SKILL": NewLanguage("SKILL", []string{";"}, [][]string{{"/*", "*/"}}),
"JAI": NewLanguage("JAI", []string{"//"}, [][]string{{"/*", "*/"}}),
Expand Down

0 comments on commit 4e992cf

Please sign in to comment.