mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
use confusables.SkeletonTweaked to fix the test
This commit is contained in:
parent
f17777995b
commit
6e9a31a574
4
Gopkg.lock
generated
4
Gopkg.lock
generated
@ -62,11 +62,11 @@
|
||||
revision = "9520e82c474b0a04dd04f8a40959027271bab992"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7caf3ea977a13cd8b9a2e1ecef1ccaa8e38f831b4f6ffcb8bd0aa909c48afb3a"
|
||||
digest = "1:940e48aff4b5fe62c3e6fd1245cc35271327a424b7ffbe4febfa83ff8f9c4f53"
|
||||
name = "github.com/oragono/confusables"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d5dd03409482fae2457f0742be22782890f720c2"
|
||||
revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -50,7 +50,7 @@
|
||||
name = "github.com/oragono/go-ident"
|
||||
|
||||
[[constraint]]
|
||||
revision = "d5dd03409482fae2457f0742be22782890f720c2"
|
||||
revision = "e65e89839ad43b68dbea2d3ca62f0f1c594b029a"
|
||||
name = "github.com/oragono/confusables"
|
||||
|
||||
[[constraint]]
|
||||
|
@ -108,26 +108,6 @@ func CasefoldName(name string) (string, error) {
|
||||
return lowered, err
|
||||
}
|
||||
|
||||
// "boring" names are exempt from skeletonization.
|
||||
// this is because confusables.txt considers various pure ASCII alphanumeric
|
||||
// strings confusable: 0 and O, 1 and l, m and rn. IMO this causes more problems
|
||||
// than it solves.
|
||||
func isBoring(name string) bool {
|
||||
for i := 0; i < len(name); i += 1 {
|
||||
chr := name[i]
|
||||
if (chr >= 'a' && chr <= 'z') || (chr >= 'A' && chr <= 'Z') || (chr >= '0' && chr <= '9') {
|
||||
continue // alphanumerics
|
||||
}
|
||||
switch chr {
|
||||
case '$', '%', '^', '&', '(', ')', '{', '}', '[', ']', '<', '>', '=':
|
||||
continue // benign printable ascii characters
|
||||
default:
|
||||
return false // potentially confusable ascii like | ' `, non-ascii
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// returns true if the given name is a valid ident, using a mix of Insp and
|
||||
// Chary's ident restrictions.
|
||||
func isIdent(name string) bool {
|
||||
@ -168,9 +148,7 @@ func Skeleton(name string) (string, error) {
|
||||
// same as PRECIS:
|
||||
name = width.Fold.String(name)
|
||||
|
||||
if !isBoring(name) {
|
||||
name = confusables.Skeleton(name)
|
||||
}
|
||||
name = confusables.SkeletonTweaked(name)
|
||||
|
||||
// internationalized lowercasing for skeletons; this is much more lenient than
|
||||
// Casefold. In particular, skeletons are expected to mix scripts (which may
|
||||
|
@ -128,18 +128,6 @@ func TestCasefoldName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsBoring(t *testing.T) {
|
||||
assertBoring := func(str string, expected bool) {
|
||||
if isBoring(str) != expected {
|
||||
t.Errorf("expected [%s] to have boringness [%t], but got [%t]", str, expected, !expected)
|
||||
}
|
||||
}
|
||||
|
||||
assertBoring("warning", true)
|
||||
assertBoring("phi|ip", false)
|
||||
assertBoring("Νικηφόρος", false)
|
||||
}
|
||||
|
||||
func TestIsIdent(t *testing.T) {
|
||||
assertIdent := func(str string, expected bool) {
|
||||
if isIdent(str) != expected {
|
||||
|
2
vendor
2
vendor
@ -1 +1 @@
|
||||
Subproject commit 8ddbb531841add50f8b7aff8fe00bef311448aaa
|
||||
Subproject commit 42b0d2d5d24a9b0ed4295fa04fd66e7c4ff27fa8
|
Loading…
Reference in New Issue
Block a user