diff options
Diffstat (limited to 'vendor/github.com/stretchr/objx/codegen')
5 files changed, 0 insertions, 364 deletions
diff --git a/vendor/github.com/stretchr/objx/codegen/array-access.txt b/vendor/github.com/stretchr/objx/codegen/array-access.txt deleted file mode 100644 index 306023475..000000000 --- a/vendor/github.com/stretchr/objx/codegen/array-access.txt +++ /dev/null @@ -1,14 +0,0 @@ - case []{1}: - a := object.([]{1}) - if isSet { - a[index] = value.({1}) - } else { - if index >= len(a) { - if panics { - panic(fmt.Sprintf("objx: Index %d is out of range because the []{1} only contains %d items.", index, len(a))) - } - return nil - } else { - return a[index] - } - } diff --git a/vendor/github.com/stretchr/objx/codegen/index.html b/vendor/github.com/stretchr/objx/codegen/index.html deleted file mode 100644 index 379ffc3c0..000000000 --- a/vendor/github.com/stretchr/objx/codegen/index.html +++ /dev/null @@ -1,86 +0,0 @@ -<html> - <head> - <title> - Codegen - </title> - <style> - body { - width: 800px; - margin: auto; - } - textarea { - width: 100%; - min-height: 100px; - font-family: Courier; - } - </style> - </head> - <body> - - <h2> - Template - </h2> - <p> - Use <code>{x}</code> as a placeholder for each argument. - </p> - <textarea id="template"></textarea> - - <h2> - Arguments (comma separated) - </h2> - <p> - One block per line - </p> - <textarea id="args"></textarea> - - <h2> - Output - </h2> - <input id="go" type="button" value="Generate code" /> - - <textarea id="output"></textarea> - - <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> - <script> - - $(function(){ - - $("#go").click(function(){ - - var output = "" - var template = $("#template").val() - var args = $("#args").val() - - // collect the args - var argLines = args.split("\n") - for (var line in argLines) { - - var argLine = argLines[line]; - var thisTemp = template - - // get individual args - var args = argLine.split(",") - - for (var argI in args) { - var argText = args[argI]; - var argPlaceholder = "{" + argI + "}"; - - while (thisTemp.indexOf(argPlaceholder) > -1) { - thisTemp = thisTemp.replace(argPlaceholder, argText); - } - - } - - output += thisTemp - - } - - $("#output").val(output); - - }); - - }); - - </script> - </body> -</html> diff --git a/vendor/github.com/stretchr/objx/codegen/template.txt b/vendor/github.com/stretchr/objx/codegen/template.txt deleted file mode 100644 index 047bfc13f..000000000 --- a/vendor/github.com/stretchr/objx/codegen/template.txt +++ /dev/null @@ -1,124 +0,0 @@ -/* - {4} ({1} and []{1}) -*/ - -// {4} gets the value as a {1}, returns the optionalDefault -// value or a system default object if the value is the wrong type. -func (v *Value) {4}(optionalDefault ...{1}) {1} { - if s, ok := v.data.({1}); ok { - return s - } - if len(optionalDefault) == 1 { - return optionalDefault[0] - } - return {3} -} - -// Must{4} gets the value as a {1}. -// -// Panics if the object is not a {1}. -func (v *Value) Must{4}() {1} { - return v.data.({1}) -} - -// {4}Slice gets the value as a []{1}, returns the optionalDefault -// value or nil if the value is not a []{1}. -func (v *Value) {4}Slice(optionalDefault ...[]{1}) []{1} { - if s, ok := v.data.([]{1}); ok { - return s - } - if len(optionalDefault) == 1 { - return optionalDefault[0] - } - return nil -} - -// Must{4}Slice gets the value as a []{1}. -// -// Panics if the object is not a []{1}. -func (v *Value) Must{4}Slice() []{1} { - return v.data.([]{1}) -} - -// Is{4} gets whether the object contained is a {1} or not. -func (v *Value) Is{4}() bool { - _, ok := v.data.({1}) - return ok -} - -// Is{4}Slice gets whether the object contained is a []{1} or not. -func (v *Value) Is{4}Slice() bool { - _, ok := v.data.([]{1}) - return ok -} - -// Each{4} calls the specified callback for each object -// in the []{1}. -// -// Panics if the object is the wrong type. -func (v *Value) Each{4}(callback func(int, {1}) bool) *Value { - for index, val := range v.Must{4}Slice() { - carryon := callback(index, val) - if !carryon { - break - } - } - return v -} - -// Where{4} uses the specified decider function to select items -// from the []{1}. The object contained in the result will contain -// only the selected items. -func (v *Value) Where{4}(decider func(int, {1}) bool) *Value { - var selected []{1} - v.Each{4}(func(index int, val {1}) bool { - shouldSelect := decider(index, val) - if !shouldSelect { - selected = append(selected, val) - } - return true - }) - return &Value{data:selected} -} - -// Group{4} uses the specified grouper function to group the items -// keyed by the return of the grouper. The object contained in the -// result will contain a map[string][]{1}. -func (v *Value) Group{4}(grouper func(int, {1}) string) *Value { - groups := make(map[string][]{1}) - v.Each{4}(func(index int, val {1}) bool { - group := grouper(index, val) - if _, ok := groups[group]; !ok { - groups[group] = make([]{1}, 0) - } - groups[group] = append(groups[group], val) - return true - }) - return &Value{data:groups} -} - -// Replace{4} uses the specified function to replace each {1}s -// by iterating each item. The data in the returned result will be a -// []{1} containing the replaced items. -func (v *Value) Replace{4}(replacer func(int, {1}) {1}) *Value { - arr := v.Must{4}Slice() - replaced := make([]{1}, len(arr)) - v.Each{4}(func(index int, val {1}) bool { - replaced[index] = replacer(index, val) - return true - }) - return &Value{data:replaced} -} - -// Collect{4} uses the specified collector function to collect a value -// for each of the {1}s in the slice. The data returned will be a -// []interface{}. -func (v *Value) Collect{4}(collector func(int, {1}) interface{}) *Value { - arr := v.Must{4}Slice() - collected := make([]interface{}, len(arr)) - v.Each{4}(func(index int, val {1}) bool { - collected[index] = collector(index, val) - return true - }) - return &Value{data:collected} -} diff --git a/vendor/github.com/stretchr/objx/codegen/template_test.txt b/vendor/github.com/stretchr/objx/codegen/template_test.txt deleted file mode 100644 index 6490cb2df..000000000 --- a/vendor/github.com/stretchr/objx/codegen/template_test.txt +++ /dev/null @@ -1,120 +0,0 @@ -/* - Tests for {4} ({1} and []{1}) -*/ -func Test{4}(t *testing.T) { - val := {1}({2}) - m := objx.Map{"value": val, "nothing": nil} - - assert.Equal(t, val, m.Get("value").{4}()) - assert.Equal(t, val, m.Get("value").Must{4}()) - assert.Equal(t, {1}({3}), m.Get("nothing").{4}()) - assert.Equal(t, val, m.Get("nothing").{4}({2})) - assert.Panics(t, func() { - m.Get("age").Must{4}() - }) -} - -func Test{4}Slice(t *testing.T) { - val := {1}({2}) - m := objx.Map{"value": []{1}{ val }, "nothing": nil} - - assert.Equal(t, val, m.Get("value").{4}Slice()[0]) - assert.Equal(t, val, m.Get("value").Must{4}Slice()[0]) - assert.Equal(t, []{1}(nil), m.Get("nothing").{4}Slice()) - assert.Equal(t, val, m.Get("nothing").{4}Slice([]{1}{{1}({2})})[0]) - assert.Panics(t, func() { - m.Get("nothing").Must{4}Slice() - }) -} - -func TestIs{4}(t *testing.T) { - m := objx.Map{"data": {1}({2})} - - assert.True(t, m.Get("data").Is{4}()) -} - -func TestIs{4}Slice(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2})}} - - assert.True(t, m.Get("data").Is{4}Slice()) -} - -func TestEach{4}(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2})}} - count := 0 - replacedVals := make([]{1}, 0) - assert.Equal(t, m.Get("data"), m.Get("data").Each{4}(func(i int, val {1}) bool { - count++ - replacedVals = append(replacedVals, val) - - // abort early - return i != 2 - })) - - assert.Equal(t, count, 3) - assert.Equal(t, replacedVals[0], m.Get("data").Must{4}Slice()[0]) - assert.Equal(t, replacedVals[1], m.Get("data").Must{4}Slice()[1]) - assert.Equal(t, replacedVals[2], m.Get("data").Must{4}Slice()[2]) -} - -func TestWhere{4}(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2})}} - - selected := m.Get("data").Where{4}(func(i int, val {1}) bool { - return i%2 == 0 - }).Must{4}Slice() - - assert.Equal(t, 3, len(selected)) -} - -func TestGroup{4}(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2})}} - - grouped := m.Get("data").Group{4}(func(i int, val {1}) string { - return fmt.Sprintf("%v", i%2==0) - }).Data().(map[string][]{1}) - - assert.Equal(t, 2, len(grouped)) - assert.Equal(t, 3, len(grouped["true"])) - assert.Equal(t, 3, len(grouped["false"])) -} - -func TestReplace{4}(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2})}} - rawArr := m.Get("data").Must{4}Slice() - - replaced := m.Get("data").Replace{4}(func(index int, val {1}) {1} { - if index < len(rawArr)-1 { - return rawArr[index+1] - } - return rawArr[0] - }) - replacedArr := replaced.Must{4}Slice() - - if assert.Equal(t, 6, len(replacedArr)) { - assert.Equal(t, replacedArr[0], rawArr[1]) - assert.Equal(t, replacedArr[1], rawArr[2]) - assert.Equal(t, replacedArr[2], rawArr[3]) - assert.Equal(t, replacedArr[3], rawArr[4]) - assert.Equal(t, replacedArr[4], rawArr[5]) - assert.Equal(t, replacedArr[5], rawArr[0]) - } -} - -func TestCollect{4}(t *testing.T) { - m := objx.Map{"data": []{1}{{1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2}), {1}({2})}} - - collected := m.Get("data").Collect{4}(func(index int, val {1}) interface{} { - return index - }) - collectedArr := collected.MustInterSlice() - - if assert.Equal(t, 6, len(collectedArr)) { - assert.Equal(t, collectedArr[0], 0) - assert.Equal(t, collectedArr[1], 1) - assert.Equal(t, collectedArr[2], 2) - assert.Equal(t, collectedArr[3], 3) - assert.Equal(t, collectedArr[4], 4) - assert.Equal(t, collectedArr[5], 5) - } -} diff --git a/vendor/github.com/stretchr/objx/codegen/types_list.txt b/vendor/github.com/stretchr/objx/codegen/types_list.txt deleted file mode 100644 index 932139d57..000000000 --- a/vendor/github.com/stretchr/objx/codegen/types_list.txt +++ /dev/null @@ -1,20 +0,0 @@ -Interface,interface{},"something",nil,Inter -Map,map[string]interface{},map[string]interface{}{"name":"Tyler"},nil,MSI -ObjxMap,(objx.Map),objx.New(1),objx.New(nil),ObjxMap -Bool,bool,true,false,Bool -String,string,"hello","",Str -Int,int,1,0,Int -Int8,int8,1,0,Int8 -Int16,int16,1,0,Int16 -Int32,int32,1,0,Int32 -Int64,int64,1,0,Int64 -Uint,uint,1,0,Uint -Uint8,uint8,1,0,Uint8 -Uint16,uint16,1,0,Uint16 -Uint32,uint32,1,0,Uint32 -Uint64,uint64,1,0,Uint64 -Uintptr,uintptr,1,0,Uintptr -Float32,float32,1,0,Float32 -Float64,float64,1,0,Float64 -Complex64,complex64,1,0,Complex64 -Complex128,complex128,1,0,Complex128 |