Vendor cleanup

Signed-off-by: Madhu Rajanna <mrajanna@redhat.com>
This commit is contained in:
Madhu Rajanna
2019-01-16 18:11:54 +05:30
parent 661818bd79
commit 0f836c62fa
16816 changed files with 20 additions and 4611100 deletions

View File

@ -1,81 +0,0 @@
// Copyright 2014 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 ucd_test
import (
"fmt"
"strings"
"golang.org/x/text/internal/ucd"
)
func Example() {
// Read rune-by-rune from UnicodeData.
var count int
p := ucd.New(strings.NewReader(unicodeData))
for p.Next() {
count++
if lower := p.Runes(ucd.SimpleLowercaseMapping); lower != nil {
fmt.Printf("lower(%U) -> %U\n", p.Rune(0), lower[0])
}
}
if err := p.Err(); err != nil {
fmt.Println(err)
}
fmt.Println("Number of runes visited:", count)
// Read raw ranges from Scripts.
p = ucd.New(strings.NewReader(scripts), ucd.KeepRanges)
for p.Next() {
start, end := p.Range(0)
fmt.Printf("%04X..%04X: %s\n", start, end, p.String(1))
}
if err := p.Err(); err != nil {
fmt.Println(err)
}
// Output:
// lower(U+00C0) -> U+00E0
// lower(U+00C1) -> U+00E1
// lower(U+00C2) -> U+00E2
// lower(U+00C3) -> U+00E3
// lower(U+00C4) -> U+00E4
// Number of runes visited: 6594
// 0000..001F: Common
// 0020..0020: Common
// 0021..0023: Common
// 0024..0024: Common
}
// Excerpt from UnicodeData.txt
const unicodeData = `
00B9;SUPERSCRIPT ONE;No;0;EN;<super> 0031;;1;1;N;SUPERSCRIPT DIGIT ONE;;;;
00BA;MASCULINE ORDINAL INDICATOR;Lo;0;L;<super> 006F;;;;N;;;;;
00BB;RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK;Pf;0;ON;;;;;Y;RIGHT POINTING GUILLEMET;;;;
00BC;VULGAR FRACTION ONE QUARTER;No;0;ON;<fraction> 0031 2044 0034;;;1/4;N;FRACTION ONE QUARTER;;;;
00BD;VULGAR FRACTION ONE HALF;No;0;ON;<fraction> 0031 2044 0032;;;1/2;N;FRACTION ONE HALF;;;;
00BE;VULGAR FRACTION THREE QUARTERS;No;0;ON;<fraction> 0033 2044 0034;;;3/4;N;FRACTION THREE QUARTERS;;;;
00BF;INVERTED QUESTION MARK;Po;0;ON;;;;;N;;;;;
00C0;LATIN CAPITAL LETTER A WITH GRAVE;Lu;0;L;0041 0300;;;;N;LATIN CAPITAL LETTER A GRAVE;;;00E0;
00C1;LATIN CAPITAL LETTER A WITH ACUTE;Lu;0;L;0041 0301;;;;N;LATIN CAPITAL LETTER A ACUTE;;;00E1;
00C2;LATIN CAPITAL LETTER A WITH CIRCUMFLEX;Lu;0;L;0041 0302;;;;N;LATIN CAPITAL LETTER A CIRCUMFLEX;;;00E2;
00C3;LATIN CAPITAL LETTER A WITH TILDE;Lu;0;L;0041 0303;;;;N;LATIN CAPITAL LETTER A TILDE;;;00E3;
00C4;LATIN CAPITAL LETTER A WITH DIAERESIS;Lu;0;L;0041 0308;;;;N;LATIN CAPITAL LETTER A DIAERESIS;;;00E4;
# A legacy rune range.
3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;
4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;
`
// Excerpt from Scripts.txt
const scripts = `
# Property: Script
# ================================================
0000..001F ; Common # Cc [32] <control-0000>..<control-001F>
0020 ; Common # Zs SPACE
0021..0023 ; Common # Po [3] EXCLAMATION MARK..NUMBER SIGN
0024 ; Common # Sc DOLLAR SIGN
`

View File

@ -1,105 +0,0 @@
package ucd
import (
"strings"
"testing"
)
const file = `
# Comments should be skipped
# rune; bool; uint; int; float; runes; # Y
0..0005; Y; 0; 2; -5.25 ; 0 1 2 3 4 5;
6..0007; Yes ; 6; 1; -4.25 ; 0006 0007;
8; T ; 8 ; 0 ;-3.25 ;;# T
9; True ;9 ; -1;-2.25 ; 0009;
# more comments to be ignored
@Part0
A; N; 10 ; -2; -1.25; ;# N
B; No; 11 ; -3; -0.25;
C; False;12; -4; 0.75;
D; ;13;-5;1.75;
@Part1 # Another part.
# We test part comments get removed by not commenting the the next line.
E..10FFFF; F; 14 ; -6; 2.75;
`
var want = []struct {
start, end rune
}{
{0x00, 0x05},
{0x06, 0x07},
{0x08, 0x08},
{0x09, 0x09},
{0x0A, 0x0A},
{0x0B, 0x0B},
{0x0C, 0x0C},
{0x0D, 0x0D},
{0x0E, 0x10FFFF},
}
func TestGetters(t *testing.T) {
parts := [][2]string{
{"Part0", ""},
{"Part1", "Another part."},
}
handler := func(p *Parser) {
if len(parts) == 0 {
t.Error("Part handler invoked too many times.")
return
}
want := parts[0]
parts = parts[1:]
if got0, got1 := p.String(0), p.Comment(); got0 != want[0] || got1 != want[1] {
t.Errorf(`part: got %q, %q; want %q"`, got0, got1, want)
}
}
p := New(strings.NewReader(file), KeepRanges, Part(handler))
for i := 0; p.Next(); i++ {
start, end := p.Range(0)
w := want[i]
if start != w.start || end != w.end {
t.Fatalf("%d:Range(0); got %#x..%#x; want %#x..%#x", i, start, end, w.start, w.end)
}
if w.start == w.end && p.Rune(0) != w.start {
t.Errorf("%d:Range(0).start: got %U; want %U", i, p.Rune(0), w.start)
}
if got, want := p.Bool(1), w.start <= 9; got != want {
t.Errorf("%d:Bool(1): got %v; want %v", i, got, want)
}
if got := p.Rune(4); got != 0 || p.Err() == nil {
t.Errorf("%d:Rune(%q): got no error; want error", i, p.String(1))
}
p.err = nil
if got := p.Uint(2); rune(got) != start {
t.Errorf("%d:Uint(2): got %v; want %v", i, got, start)
}
if got, want := p.Int(3), 2-i; got != want {
t.Errorf("%d:Int(3): got %v; want %v", i, got, want)
}
if got, want := p.Float(4), -5.25+float64(i); got != want {
t.Errorf("%d:Int(3): got %v; want %v", i, got, want)
}
if got := p.Runes(5); got == nil {
if p.String(5) != "" {
t.Errorf("%d:Runes(5): expected non-empty list", i)
}
} else {
if got[0] != start || got[len(got)-1] != end {
t.Errorf("%d:Runes(5): got %#x; want %#x..%#x", i, got, start, end)
}
}
if got := p.Comment(); got != "" && got != p.String(1) {
t.Errorf("%d:Comment(): got %v; want %v", i, got, p.String(1))
}
}
if err := p.Err(); err != nil {
t.Errorf("Parser error: %v", err)
}
if len(parts) != 0 {
t.Errorf("expected %d more invocations of part handler", len(parts))
}
}