-
Notifications
You must be signed in to change notification settings - Fork 8
/
package_test.go
81 lines (68 loc) · 2.01 KB
/
package_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2013 The lime Authors.
// Use of this source code is governed by a 2-clause
// BSD-style license that can be found in the LICENSE file.
package sublime
import (
"path/filepath"
"testing"
"github.com/limetext/backend"
"github.com/limetext/backend/packages"
_ "github.com/limetext/commands"
_ "github.com/limetext/sublime/api"
)
var (
pkgPath = filepath.Join("testdata", "package")
pluginPath = filepath.Join("testdata", "package", "plugin.py")
synPath = filepath.Join(pkgPath, "Go.tmLanguage")
csPath = filepath.Join(pkgPath, "Twilight.tmTheme")
)
func TestLoadPlugin(t *testing.T) {
pkg := newPKG(pkgPath).(*pkg)
pkg.loadPlugin(pluginPath)
checkPlugin(pkg, t)
}
func TestLoadPlugins(t *testing.T) {
pkg := newPKG(pkgPath).(*pkg)
pkg.loadPlugins()
checkPlugin(pkg, t)
}
func TestLoadColorScheme(t *testing.T) {
pkg := newPKG(pkgPath).(*pkg)
pkg.loadColorScheme(csPath)
checkColorScheme(pkg, t)
}
func TestLoadSyntax(t *testing.T) {
pkg := newPKG(pkgPath).(*pkg)
pkg.loadSyntax(synPath)
checkSyntax(pkg, t)
}
func checkPlugin(p *pkg, t *testing.T) {
if _, exist := p.plugins[pluginPath]; !exist {
t.Errorf("Expected to %s exist in %s package plugins", pluginPath, p.Name())
}
}
func checkColorScheme(p *pkg, t *testing.T) {
if _, ok := p.colorSchemes[csPath]; !ok {
t.Errorf("Expected %s in %s package color schemes", csPath, p.Name())
}
if cs := backend.GetEditor().GetColorScheme(csPath); cs == nil {
t.Errorf("Expected %s from %s package in editor color schemes", csPath, p.Name())
}
}
func checkSyntax(p *pkg, t *testing.T) {
if _, ok := p.syntaxes[synPath]; !ok {
t.Errorf("Expected %s in %s package syntaxes", synPath, p.Name())
}
if syn := backend.GetEditor().GetSyntax(synPath); syn == nil {
t.Errorf("Expected %s from %s package in editor syntaxes", synPath, p.Name())
}
}
func TestScan(t *testing.T) {
pkg := newPKG(pkgPath).(*pkg)
filepath.Walk(pkg.Path(), pkg.scan)
checkColorScheme(pkg, t)
checkSyntax(pkg, t)
}
func init() {
packages.Unregister(packageRecord)
}