summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/unicode/bidi
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-04-16 05:37:14 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-04-16 08:37:14 -0400
commit6e2cb00008cbf09e556b00f87603797fcaa47e09 (patch)
tree3c0eb55ff4226a3f024aad373140d1fb860a6404 /vendor/golang.org/x/text/unicode/bidi
parentbf24f51c4e1cc6286885460672f7f449e8c6f5ef (diff)
downloadchat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.gz
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.tar.bz2
chat-6e2cb00008cbf09e556b00f87603797fcaa47e09.zip
Depenancy upgrades and movign to dep. (#8630)
Diffstat (limited to 'vendor/golang.org/x/text/unicode/bidi')
-rw-r--r--vendor/golang.org/x/text/unicode/bidi/core_test.go224
-rw-r--r--vendor/golang.org/x/text/unicode/bidi/ranges_test.go53
-rw-r--r--vendor/golang.org/x/text/unicode/bidi/tables_test.go82
3 files changed, 0 insertions, 359 deletions
diff --git a/vendor/golang.org/x/text/unicode/bidi/core_test.go b/vendor/golang.org/x/text/unicode/bidi/core_test.go
deleted file mode 100644
index f28d386c8..000000000
--- a/vendor/golang.org/x/text/unicode/bidi/core_test.go
+++ /dev/null
@@ -1,224 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bidi
-
-import (
- "flag"
- "fmt"
- "log"
- "strconv"
- "strings"
- "testing"
-
- "golang.org/x/text/internal/gen"
- "golang.org/x/text/internal/testtext"
- "golang.org/x/text/internal/ucd"
- "golang.org/x/text/unicode/norm"
-)
-
-var testLevels = flag.Bool("levels", false, "enable testing of levels")
-
-// TestBidiCore performs the tests in BidiTest.txt.
-// See http://www.unicode.org/Public/UCD/latest/ucd/BidiTest.txt.
-func TestBidiCore(t *testing.T) {
- testtext.SkipIfNotLong(t)
-
- r := gen.OpenUCDFile("BidiTest.txt")
- defer r.Close()
-
- var wantLevels, wantOrder []string
- p := ucd.New(r, ucd.Part(func(p *ucd.Parser) {
- s := strings.Split(p.String(0), ":")
- switch s[0] {
- case "Levels":
- wantLevels = strings.Fields(s[1])
- case "Reorder":
- wantOrder = strings.Fields(s[1])
- default:
- log.Fatalf("Unknown part %q.", s[0])
- }
- }))
-
- for p.Next() {
- types := []Class{}
- for _, s := range p.Strings(0) {
- types = append(types, bidiClass[s])
- }
- // We ignore the bracketing part of the algorithm.
- pairTypes := make([]bracketType, len(types))
- pairValues := make([]rune, len(types))
-
- for i := uint(0); i < 3; i++ {
- if p.Uint(1)&(1<<i) == 0 {
- continue
- }
- lev := level(int(i) - 1)
- par := newParagraph(types, pairTypes, pairValues, lev)
-
- if *testLevels {
- levels := par.getLevels([]int{len(types)})
- for i, s := range wantLevels {
- if s == "x" {
- continue
- }
- l, _ := strconv.ParseUint(s, 10, 8)
- if level(l)&1 != levels[i]&1 {
- t.Errorf("%s:%d:levels: got %v; want %v", p.String(0), lev, levels, wantLevels)
- break
- }
- }
- }
-
- order := par.getReordering([]int{len(types)})
- gotOrder := filterOrder(types, order)
- if got, want := fmt.Sprint(gotOrder), fmt.Sprint(wantOrder); got != want {
- t.Errorf("%s:%d:order: got %v; want %v\noriginal %v", p.String(0), lev, got, want, order)
- }
- }
- }
- if err := p.Err(); err != nil {
- log.Fatal(err)
- }
-}
-
-var removeClasses = map[Class]bool{
- LRO: true,
- RLO: true,
- RLE: true,
- LRE: true,
- PDF: true,
- BN: true,
-}
-
-// TestBidiCharacters performs the tests in BidiCharacterTest.txt.
-// See http://www.unicode.org/Public/UCD/latest/ucd/BidiCharacterTest.txt
-func TestBidiCharacters(t *testing.T) {
- testtext.SkipIfNotLong(t)
-
- ucd.Parse(gen.OpenUCDFile("BidiCharacterTest.txt"), func(p *ucd.Parser) {
- var (
- types []Class
- pairTypes []bracketType
- pairValues []rune
- parLevel level
-
- wantLevel = level(p.Int(2))
- wantLevels = p.Strings(3)
- wantVisualOrder = p.Strings(4)
- )
-
- switch l := p.Int(1); l {
- case 0, 1:
- parLevel = level(l)
- case 2:
- parLevel = implicitLevel
- default:
- // Spec says to ignore unknown parts.
- }
-
- runes := p.Runes(0)
-
- for _, r := range runes {
- // Assign the bracket type.
- if d := norm.NFKD.PropertiesString(string(r)).Decomposition(); d != nil {
- r = []rune(string(d))[0]
- }
- p, _ := LookupRune(r)
-
- // Assign the class for this rune.
- types = append(types, p.Class())
-
- switch {
- case !p.IsBracket():
- pairTypes = append(pairTypes, bpNone)
- pairValues = append(pairValues, 0)
- case p.IsOpeningBracket():
- pairTypes = append(pairTypes, bpOpen)
- pairValues = append(pairValues, r)
- default:
- pairTypes = append(pairTypes, bpClose)
- pairValues = append(pairValues, p.reverseBracket(r))
- }
- }
- par := newParagraph(types, pairTypes, pairValues, parLevel)
-
- // Test results:
- if got := par.embeddingLevel; got != wantLevel {
- t.Errorf("%v:level: got %d; want %d", string(runes), got, wantLevel)
- }
-
- if *testLevels {
- gotLevels := getLevelStrings(types, par.getLevels([]int{len(types)}))
- if got, want := fmt.Sprint(gotLevels), fmt.Sprint(wantLevels); got != want {
- t.Errorf("%04X %q:%d: got %v; want %v\nval: %x\npair: %v", runes, string(runes), parLevel, got, want, pairValues, pairTypes)
- }
- }
-
- order := par.getReordering([]int{len(types)})
- order = filterOrder(types, order)
- if got, want := fmt.Sprint(order), fmt.Sprint(wantVisualOrder); got != want {
- t.Errorf("%04X %q:%d: got %v; want %v\ngot order: %s", runes, string(runes), parLevel, got, want, reorder(runes, order))
- }
- })
-}
-
-func getLevelStrings(cl []Class, levels []level) []string {
- var results []string
- for i, l := range levels {
- if !removeClasses[cl[i]] {
- results = append(results, fmt.Sprint(l))
- } else {
- results = append(results, "x")
- }
- }
- return results
-}
-
-func filterOrder(cl []Class, order []int) []int {
- no := []int{}
- for _, o := range order {
- if !removeClasses[cl[o]] {
- no = append(no, o)
- }
- }
- return no
-}
-
-func reorder(r []rune, order []int) string {
- nr := make([]rune, len(order))
- for i, o := range order {
- nr[i] = r[o]
- }
- return string(nr)
-}
-
-// bidiClass names and codes taken from class "bc" in
-// http://www.unicode.org/Public/8.0.0/ucd/PropertyValueAliases.txt
-var bidiClass = map[string]Class{
- "AL": AL, // classArabicLetter,
- "AN": AN, // classArabicNumber,
- "B": B, // classParagraphSeparator,
- "BN": BN, // classBoundaryNeutral,
- "CS": CS, // classCommonSeparator,
- "EN": EN, // classEuropeanNumber,
- "ES": ES, // classEuropeanSeparator,
- "ET": ET, // classEuropeanTerminator,
- "L": L, // classLeftToRight,
- "NSM": NSM, // classNonspacingMark,
- "ON": ON, // classOtherNeutral,
- "R": R, // classRightToLeft,
- "S": S, // classSegmentSeparator,
- "WS": WS, // classWhiteSpace,
-
- "LRO": LRO, // classLeftToRightOverride,
- "RLO": RLO, // classRightToLeftOverride,
- "LRE": LRE, // classLeftToRightEmbedding,
- "RLE": RLE, // classRightToLeftEmbedding,
- "PDF": PDF, // classPopDirectionalFormat,
- "LRI": LRI, // classLeftToRightIsolate,
- "RLI": RLI, // classRightToLeftIsolate,
- "FSI": FSI, // classFirstStrongIsolate,
- "PDI": PDI, // classPopDirectionalIsolate,
-}
diff --git a/vendor/golang.org/x/text/unicode/bidi/ranges_test.go b/vendor/golang.org/x/text/unicode/bidi/ranges_test.go
deleted file mode 100644
index bfaecd502..000000000
--- a/vendor/golang.org/x/text/unicode/bidi/ranges_test.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
-
-package bidi
-
-import (
- "unicode"
-
- "golang.org/x/text/internal/gen"
- "golang.org/x/text/internal/ucd"
- "golang.org/x/text/unicode/rangetable"
-)
-
-// These tables are hand-extracted from:
-// http://www.unicode.org/Public/8.0.0/ucd/extracted/DerivedBidiClass.txt
-func visitDefaults(fn func(r rune, c Class)) {
- // first write default values for ranges listed above.
- visitRunes(fn, AL, []rune{
- 0x0600, 0x07BF, // Arabic
- 0x08A0, 0x08FF, // Arabic Extended-A
- 0xFB50, 0xFDCF, // Arabic Presentation Forms
- 0xFDF0, 0xFDFF,
- 0xFE70, 0xFEFF,
- 0x0001EE00, 0x0001EEFF, // Arabic Mathematical Alpha Symbols
- })
- visitRunes(fn, R, []rune{
- 0x0590, 0x05FF, // Hebrew
- 0x07C0, 0x089F, // Nko et al.
- 0xFB1D, 0xFB4F,
- 0x00010800, 0x00010FFF, // Cypriot Syllabary et. al.
- 0x0001E800, 0x0001EDFF,
- 0x0001EF00, 0x0001EFFF,
- })
- visitRunes(fn, ET, []rune{ // European Terminator
- 0x20A0, 0x20Cf, // Currency symbols
- })
- rangetable.Visit(unicode.Noncharacter_Code_Point, func(r rune) {
- fn(r, BN) // Boundary Neutral
- })
- ucd.Parse(gen.OpenUCDFile("DerivedCoreProperties.txt"), func(p *ucd.Parser) {
- if p.String(1) == "Default_Ignorable_Code_Point" {
- fn(p.Rune(0), BN) // Boundary Neutral
- }
- })
-}
-
-func visitRunes(fn func(r rune, c Class), c Class, runes []rune) {
- for i := 0; i < len(runes); i += 2 {
- lo, hi := runes[i], runes[i+1]
- for j := lo; j <= hi; j++ {
- fn(j, c)
- }
- }
-}
diff --git a/vendor/golang.org/x/text/unicode/bidi/tables_test.go b/vendor/golang.org/x/text/unicode/bidi/tables_test.go
deleted file mode 100644
index 356a4a58d..000000000
--- a/vendor/golang.org/x/text/unicode/bidi/tables_test.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2015 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bidi
-
-import (
- "testing"
-
- "golang.org/x/text/internal/gen"
- "golang.org/x/text/internal/testtext"
- "golang.org/x/text/internal/ucd"
-)
-
-var labels = []string{
- AL: "AL",
- AN: "AN",
- B: "B",
- BN: "BN",
- CS: "CS",
- EN: "EN",
- ES: "ES",
- ET: "ET",
- L: "L",
- NSM: "NSM",
- ON: "ON",
- R: "R",
- S: "S",
- WS: "WS",
-
- LRO: "LRO",
- RLO: "RLO",
- LRE: "LRE",
- RLE: "RLE",
- PDF: "PDF",
- LRI: "LRI",
- RLI: "RLI",
- FSI: "FSI",
- PDI: "PDI",
-}
-
-func TestTables(t *testing.T) {
- testtext.SkipIfNotLong(t)
-
- ucd.Parse(gen.OpenUCDFile("BidiBrackets.txt"), func(p *ucd.Parser) {
- r1 := p.Rune(0)
- want := p.Rune(1)
-
- e, _ := LookupRune(r1)
- if got := e.reverseBracket(r1); got != want {
- t.Errorf("Reverse(%U) = %U; want %U", r1, got, want)
- }
- })
-
- done := map[rune]bool{}
- test := func(name string, r rune, want string) {
- str := string(r)
- e, _ := LookupString(str)
- if got := labels[e.Class()]; got != want {
- t.Errorf("%s:%U: got %s; want %s", name, r, got, want)
- }
- if e2, sz := LookupRune(r); e != e2 || sz != len(str) {
- t.Errorf("LookupRune(%U) = %v, %d; want %v, %d", r, e2, e, sz, len(str))
- }
- if e2, sz := Lookup([]byte(str)); e != e2 || sz != len(str) {
- t.Errorf("Lookup(%U) = %v, %d; want %v, %d", r, e2, e, sz, len(str))
- }
- done[r] = true
- }
-
- // Insert the derived BiDi properties.
- ucd.Parse(gen.OpenUCDFile("extracted/DerivedBidiClass.txt"), func(p *ucd.Parser) {
- r := p.Rune(0)
- test("derived", r, p.String(1))
- })
- visitDefaults(func(r rune, c Class) {
- if !done[r] {
- test("default", r, labels[c])
- }
- })
-
-}