contentEquals, contentHashCode, contentToString: Add js implementation and tests
#KT-13582
This commit is contained in:
@@ -165,6 +165,85 @@ fun specialJS(): List<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
templates add f("contentEquals(other: SELF)") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
infix(true)
|
||||
doc {
|
||||
"""
|
||||
Returns `true` if the two specified arrays are *structurally* equal to one another,
|
||||
i.e. contain the same number of the same elements in the same order.
|
||||
"""
|
||||
}
|
||||
annotations("""@library("arrayEquals")""")
|
||||
returns("Boolean")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
templates add f("contentDeepEquals(other: SELF)") {
|
||||
only(ArraysOfObjects)
|
||||
infix(true)
|
||||
doc {
|
||||
"""
|
||||
Returns `true` if the two specified arrays are *deeply* equal to one another,
|
||||
i.e. contain the same number of the same elements in the same order.
|
||||
|
||||
If two corresponding elements are nested arrays, they are also compared deeply.
|
||||
If any of arrays contains itself on any nesting level the behavior is undefined.
|
||||
"""
|
||||
}
|
||||
annotations("""@library("arrayDeepEquals")""")
|
||||
returns("Boolean")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
templates add f("contentToString()") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
doc { "Returns a string representation of the contents of the specified array as if it is [List]." }
|
||||
annotations("""@library("arrayToString")""")
|
||||
returns("String")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
templates add f("contentDeepToString()") {
|
||||
only(ArraysOfObjects)
|
||||
doc {
|
||||
"""
|
||||
Returns a string representation of the contents of this array as if it is [List].
|
||||
|
||||
Nested arrays are treated as lists too.
|
||||
"""
|
||||
}
|
||||
annotations("""@library("arrayToString")""") // arrayToString is already deep
|
||||
returns("String")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
templates add f("contentHashCode()") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
doc {
|
||||
"Returns a hash code based on the contents of this array as if it is [List]."
|
||||
}
|
||||
annotations("""@library("arrayHashCode")""")
|
||||
returns("Int")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
templates add f("contentDeepHashCode()") {
|
||||
only(ArraysOfObjects)
|
||||
doc {
|
||||
"""
|
||||
Returns a hash code based on the contents of this array as if it is [List].
|
||||
|
||||
Nested arrays are treated as lists too.
|
||||
If any of arrays contains itself on any nesting level the behavior is undefined.
|
||||
"""
|
||||
}
|
||||
annotations("""@library("arrayDeepHashCode")""")
|
||||
returns("Int")
|
||||
body { "return noImpl" }
|
||||
}
|
||||
|
||||
|
||||
templates add f("sort(comparison: (T, T) -> Int)") {
|
||||
only(ArraysOfObjects, ArraysOfPrimitives)
|
||||
exclude(PrimitiveType.Boolean)
|
||||
|
||||
Reference in New Issue
Block a user