Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1package assert
2
3import (
4 "fmt"
5 "reflect"
6)
7
8// isOrdered checks that collection contains orderable elements.
9func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool {
10 objKind := reflect.TypeOf(object).Kind()
11 if objKind != reflect.Slice && objKind != reflect.Array {
12 return false
13 }
14
15 objValue := reflect.ValueOf(object)
…lines 16–42 unchanged (27 lines)
43
44 return true
45}
46
47// IsIncreasing asserts that the collection is increasing
48//
49// assert.IsIncreasing(t, []int{1, 2, 3})
50// assert.IsIncreasing(t, []float{1, 2})
51// assert.IsIncreasing(t, []string{"a", "b"})
52func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
53 return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
54}
55
56// IsNonIncreasing asserts that the collection is not increasing
57//
58// assert.IsNonIncreasing(t, []int{2, 1, 1})
59// assert.IsNonIncreasing(t, []float{2, 1})
60// assert.IsNonIncreasing(t, []string{"b", "a"})
61func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
62 return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
63}
64
65// IsDecreasing asserts that the collection is decreasing
66//
67// assert.IsDecreasing(t, []int{2, 1, 0})
68// assert.IsDecreasing(t, []float{2, 1})
69// assert.IsDecreasing(t, []string{"b", "a"})
70func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
71 return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
72}
73
74// IsNonDecreasing asserts that the collection is not decreasing
75//
76// assert.IsNonDecreasing(t, []int{1, 1, 2})
77// assert.IsNonDecreasing(t, []float{1, 2})
78// assert.IsNonDecreasing(t, []string{"a", "b"})
79func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
80 return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
81}
82

After

1package assert
2
3import (
4 "fmt"
5 "reflect"
6)
7
8// isOrdered checks that collection contains orderable elements.
9func isOrdered(t TestingT, object interface{}, allowedComparesResults []compareResult, failMessage string, msgAndArgs ...interface{}) bool {
10 objKind := reflect.TypeOf(object).Kind()
11 if objKind != reflect.Slice && objKind != reflect.Array {
12 return false
13 }
14
15 objValue := reflect.ValueOf(object)
…lines 16–42 unchanged (27 lines)
43
44 return true
45}
46
47// IsIncreasing asserts that the collection is increasing
48//
49// assert.IsIncreasing(t, []int{1, 2, 3})
50// assert.IsIncreasing(t, []float{1, 2})
51// assert.IsIncreasing(t, []string{"a", "b"})
52func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
53 return isOrdered(t, object, []compareResult{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...)
54}
55
56// IsNonIncreasing asserts that the collection is not increasing
57//
58// assert.IsNonIncreasing(t, []int{2, 1, 1})
59// assert.IsNonIncreasing(t, []float{2, 1})
60// assert.IsNonIncreasing(t, []string{"b", "a"})
61func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
62 return isOrdered(t, object, []compareResult{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...)
63}
64
65// IsDecreasing asserts that the collection is decreasing
66//
67// assert.IsDecreasing(t, []int{2, 1, 0})
68// assert.IsDecreasing(t, []float{2, 1})
69// assert.IsDecreasing(t, []string{"b", "a"})
70func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
71 return isOrdered(t, object, []compareResult{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...)
72}
73
74// IsNonDecreasing asserts that the collection is not decreasing
75//
76// assert.IsNonDecreasing(t, []int{1, 1, 2})
77// assert.IsNonDecreasing(t, []float{1, 2})
78// assert.IsNonDecreasing(t, []string{"a", "b"})
79func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool {
80 return isOrdered(t, object, []compareResult{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...)
81}
82

Before

source_file
package_clause
package "package"
package_identifier "assert"
import_declaration
import "import"
import_spec_list
( "("
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "fmt"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "reflect"
" "\""
) ")"
comment "// isOrdered checks that collection contains orderable eleme"...
function_declaration
func "func"
identifier "isOrdered"
parameter_list
( "("
parameter_declaration
identifier "t"
type_identifier "TestingT"
, ","
parameter_declaration
identifier "object"
interface_type
interface "interface"
{ "{"
} "}"
, ","
parameter_declaration
identifier "allowedComparesResults"
slice_type
[ "["
] "]"
type_identifier "CompareType"
, ","
parameter_declaration
identifier "failMessage"
type_identifier "string"
, ","
variadic_parameter_declaration
identifier "msgAndArgs"
... "..."
interface_type
interface "interface"
{ "{"
} "}"
) ")"
type_identifier "bool"
block (+319 nodes collapsed)
comment "// IsIncreasing asserts that the collection is increasing"
comment "//"
comment "// assert.IsIncreasing(t, []int{1, 2, 3})"
comment "// assert.IsIncreasing(t, []float{1, 2})"
comment "// assert.IsIncreasing(t, []string{\"a\", \"b\"})"
function_declaration
func "func"
identifier "IsIncreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "CompareType"
literal_value
{ "{"
literal_element
identifier "compareLess"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not less than "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsNonIncreasing asserts that the collection is not increa"...
comment "//"
comment "// assert.IsNonIncreasing(t, []int{2, 1, 1})"
comment "// assert.IsNonIncreasing(t, []float{2, 1})"
comment "// assert.IsNonIncreasing(t, []string{\"b\", \"a\"})"
function_declaration
func "func"
identifier "IsNonIncreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "CompareType"
literal_value
{ "{"
literal_element
identifier "compareEqual"
, ","
literal_element
identifier "compareGreater"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not greater than or equal to "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsDecreasing asserts that the collection is decreasing"
comment "//"
comment "// assert.IsDecreasing(t, []int{2, 1, 0})"
comment "// assert.IsDecreasing(t, []float{2, 1})"
comment "// assert.IsDecreasing(t, []string{\"b\", \"a\"})"
function_declaration
func "func"
identifier "IsDecreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "CompareType"
literal_value
{ "{"
literal_element
identifier "compareGreater"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not greater than "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsNonDecreasing asserts that the collection is not decrea"...
comment "//"
comment "// assert.IsNonDecreasing(t, []int{1, 1, 2})"
comment "// assert.IsNonDecreasing(t, []float{1, 2})"
comment "// assert.IsNonDecreasing(t, []string{\"a\", \"b\"})"
function_declaration
func "func"
identifier "IsNonDecreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "CompareType"
literal_value
{ "{"
literal_element
identifier "compareLess"
, ","
literal_element
identifier "compareEqual"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not less than or equal to "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"

After

source_file
package_clause
package "package"
package_identifier "assert"
import_declaration
import "import"
import_spec_list
( "("
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "fmt"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "reflect"
" "\""
) ")"
comment "// isOrdered checks that collection contains orderable eleme"...
function_declaration
func "func"
identifier "isOrdered"
parameter_list
( "("
parameter_declaration
identifier "t"
type_identifier "TestingT"
, ","
parameter_declaration
identifier "object"
interface_type
interface "interface"
{ "{"
} "}"
, ","
parameter_declaration
identifier "allowedComparesResults"
slice_type
[ "["
] "]"
type_identifier "compareResult"
, ","
parameter_declaration
identifier "failMessage"
type_identifier "string"
, ","
variadic_parameter_declaration
identifier "msgAndArgs"
... "..."
interface_type
interface "interface"
{ "{"
} "}"
) ")"
type_identifier "bool"
block (+319 nodes collapsed)
comment "// IsIncreasing asserts that the collection is increasing"
comment "//"
comment "//\tassert.IsIncreasing(t, []int{1, 2, 3})"
comment "//\tassert.IsIncreasing(t, []float{1, 2})"
comment "//\tassert.IsIncreasing(t, []string{\"a\", \"b\"})"
function_declaration
func "func"
identifier "IsIncreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "compareResult"
literal_value
{ "{"
literal_element
identifier "compareLess"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not less than "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsNonIncreasing asserts that the collection is not increa"...
comment "//"
comment "//\tassert.IsNonIncreasing(t, []int{2, 1, 1})"
comment "//\tassert.IsNonIncreasing(t, []float{2, 1})"
comment "//\tassert.IsNonIncreasing(t, []string{\"b\", \"a\"})"
function_declaration
func "func"
identifier "IsNonIncreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "compareResult"
literal_value
{ "{"
literal_element
identifier "compareEqual"
, ","
literal_element
identifier "compareGreater"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not greater than or equal to "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsDecreasing asserts that the collection is decreasing"
comment "//"
comment "//\tassert.IsDecreasing(t, []int{2, 1, 0})"
comment "//\tassert.IsDecreasing(t, []float{2, 1})"
comment "//\tassert.IsDecreasing(t, []string{\"b\", \"a\"})"
function_declaration
func "func"
identifier "IsDecreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "compareResult"
literal_value
{ "{"
literal_element
identifier "compareGreater"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not greater than "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"
comment "// IsNonDecreasing asserts that the collection is not decrea"...
comment "//"
comment "//\tassert.IsNonDecreasing(t, []int{1, 1, 2})"
comment "//\tassert.IsNonDecreasing(t, []float{1, 2})"
comment "//\tassert.IsNonDecreasing(t, []string{\"a\", \"b\"})"
function_declaration
func "func"
identifier "IsNonDecreasing"
parameter_list (+21 nodes collapsed)
type_identifier "bool"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
call_expression
identifier "isOrdered"
argument_list
( "("
identifier "t"
, ","
identifier "object"
, ","
composite_literal
slice_type
[ "["
] "]"
type_identifier "compareResult"
literal_value
{ "{"
literal_element
identifier "compareLess"
, ","
literal_element
identifier "compareEqual"
} "}"
, ","
interpreted_string_literal
" "\""
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
interpreted_string_literal_content " is not less than or equal to "
escape_sequence "\\\""
interpreted_string_literal_content "%v"
escape_sequence "\\\""
" "\""
, ","
variadic_argument
identifier "msgAndArgs"
... "..."
) ")"
} "}"