Commit 2845e588 authored by Marcel van Lohuizen's avatar Marcel van Lohuizen

exp/locale/collate: changed default AlternateHandling to non-ignorable, the same

default as ICU.

R=r
CC=golang-dev
https://golang.org/cl/6445080
parent 69183570
...@@ -35,18 +35,18 @@ const ( ...@@ -35,18 +35,18 @@ const (
type AlternateHandling int type AlternateHandling int
const ( const (
// AltShifted sets variables to be ignorable for levels one through three and
// adds a fourth level based on the values of the ignored levels.
AltShifted AlternateHandling = iota
// AltNonIgnorable turns off special handling of variables. // AltNonIgnorable turns off special handling of variables.
AltNonIgnorable AltNonIgnorable AlternateHandling = iota
// AltBlanked sets variables and all subsequent primary ignorables to be // AltBlanked sets variables and all subsequent primary ignorables to be
// ignorable at all levels. This is identical to removing all variables // ignorable at all levels. This is identical to removing all variables
// and subsequent primary ignorables from the input. // and subsequent primary ignorables from the input.
AltBlanked AltBlanked
// AltShifted sets variables to be ignorable for levels one through three and
// adds a fourth level based on the values of the ignored levels.
AltShifted
// AltShiftTrimmed is a slight variant of AltShifted that is used to // AltShiftTrimmed is a slight variant of AltShifted that is used to
// emulate POSIX. // emulate POSIX.
AltShiftTrimmed AltShiftTrimmed
......
...@@ -223,7 +223,7 @@ const sep = 0 // separator byte ...@@ -223,7 +223,7 @@ const sep = 0 // separator byte
var keyFromElemTests = []keyFromElemTest{ var keyFromElemTests = []keyFromElemTest{
{ // simple primary and secondary weights. { // simple primary and secondary weights.
opts{}, opts{alt: collate.AltShifted},
ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)}, ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary
...@@ -232,7 +232,7 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -232,7 +232,7 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // same as first, but with zero element that need to be removed { // same as first, but with zero element that need to be removed
opts{}, opts{alt: collate.AltShifted},
ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)}, ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary
...@@ -241,7 +241,7 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -241,7 +241,7 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // same as first, with large primary values { // same as first, with large primary values
opts{}, opts{alt: collate.AltShifted},
ColElems{w(0x200), w(0x8000), w(0, 0x30), w(0x12345)}, ColElems{w(0x200), w(0x8000), w(0, 0x30), w(0x12345)},
[]byte{0x2, 0, 0x80, 0x80, 0x00, 0x81, 0x23, 0x45, // primary []byte{0x2, 0, 0x80, 0x80, 0x00, 0x81, 0x23, 0x45, // primary
sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary
...@@ -250,7 +250,7 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -250,7 +250,7 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // same as first, but with the secondary level backwards { // same as first, but with the secondary level backwards
opts{backwards: true}, opts{alt: collate.AltShifted, backwards: true},
ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)}, ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, 0, defS, 0, 0x30, 0, defS, 0, defS, // secondary sep, sep, 0, defS, 0, 0x30, 0, defS, 0, defS, // secondary
...@@ -259,7 +259,7 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -259,7 +259,7 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // same as first, ignoring quaternary level { // same as first, ignoring quaternary level
opts{lev: 3}, opts{alt: collate.AltShifted, lev: 3},
ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)}, ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary
...@@ -267,14 +267,14 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -267,14 +267,14 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // same as first, ignoring tertiary level { // same as first, ignoring tertiary level
opts{lev: 2}, opts{alt: collate.AltShifted, lev: 2},
ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)}, ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary sep, sep, 0, defS, 0, defS, 0, 0x30, 0, defS, // secondary
}, },
}, },
{ // same as first, ignoring secondary level { // same as first, ignoring secondary level
opts{lev: 1}, opts{alt: collate.AltShifted, lev: 1},
ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)}, ColElems{w(0x200), zero, w(0x7FFF), w(0, 0x30), zero, w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00}, []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00},
}, },
...@@ -288,7 +288,7 @@ var keyFromElemTests = []keyFromElemTest{ ...@@ -288,7 +288,7 @@ var keyFromElemTests = []keyFromElemTest{
}, },
}, },
{ // as first, primary with case level enabled { // as first, primary with case level enabled
opts{lev: 1, caseLevel: true}, opts{alt: collate.AltShifted, lev: 1, caseLevel: true},
ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)}, ColElems{w(0x200), w(0x7FFF), w(0, 0x30), w(0x100)},
[]byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary []byte{0x2, 0, 0x7F, 0xFF, 0x1, 0x00, // primary
sep, sep, // secondary sep, sep, // secondary
...@@ -378,6 +378,7 @@ var keyTests = []keyTest{ ...@@ -378,6 +378,7 @@ var keyTests = []keyTest{
func TestKey(t *testing.T) { func TestKey(t *testing.T) {
c, _ := makeTable(appendNextTests[4].in) c, _ := makeTable(appendNextTests[4].in)
c.Alternate = collate.AltShifted
buf := collate.Buffer{} buf := collate.Buffer{}
keys1 := [][]byte{} keys1 := [][]byte{}
keys2 := [][]byte{} keys2 := [][]byte{}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment