blob: 54d3410c787e197707b154aa28c054c458d8411b [file] [log] [blame]
# generated from the original tests.
# Henceforth it may be nicer to group tests into separate files.
-- in.cue --
import "list"
t1: list.Avg([1, 2, 3, 4])
t2: list.Avg([])
t3: list.Avg("foo")
t4: list.Drop([1, 2, 3, 4], 0)
t5: list.Drop([1, 2, 3, 4], 2)
t6: list.Drop([1, 2, 3, 4], 10)
t7: list.Drop([1, 2, 3, 4], -1)
t8: list.FlattenN([1, [[2, 3], []], [4]], -1)
t9: list.FlattenN([1, [[2, 3], []], [4]], 0)
t10: list.FlattenN([1, [[2, 3], []], [4]], 1)
t11: list.FlattenN([1, [[2, 3], []], [4]], 2)
t12: list.FlattenN([[1, 2] | *[]], -1)
t13: list.FlattenN("foo", 1)
t14: list.FlattenN([], "foo")
t15: list.Max([1, 2, 3, 4])
t16: list.Max([])
t17: list.Max("foo")
t18: list.Min([1, 2, 3, 4])
t19: list.Min([])
t20: list.Min("foo")
t21: list.Product([1, 2, 3, 4])
t22: list.Product([])
t23: list.Product("foo")
t24: list.Range(0, 5, 0)
t25: list.Range(5, 0, 1)
t26: list.Range(0, 5, -1)
t27: list.Range(0, 5, 1)
t28: list.Range(0, 1, 1)
t29: list.Range(0, 5, 2)
t30: list.Range(5, 0, -1)
t31: list.Range(0, 5, 0.5)
t32: list.Slice([1, 2, 3, 4], 1, 3)
t33: list.Slice([1, 2, 3, 4], -1, 3)
t34: list.Slice([1, 2, 3, 4], 3, 1)
t35: list.Slice([1, 2, 3, 4], 5, 5)
t36: list.Slice([1, 2, 3, 4], 1, 5)
t37: list.Sort([], list.Ascending)
t38: list.Sort([2, 3, 1, 4], {x:_, y:_, less: x<y})
t39: list.SortStable([{a:2,v:1}, {a:1,v:2}, {a:1,v:3}], {
x:_,
y:_,
less: (x.a < y.a)
})
t40: list.Sort([{a:1}, {b:2}], list.Ascending)
t41: list.SortStrings(["b", "a"])
t42: list.SortStrings([1, 2])
t43: list.Sum([1, 2, 3, 4])
t44: list.Sum([])
t45: list.Sum("foo")
t46: list.Take([1, 2, 3, 4], 0)
t47: list.Take([1, 2, 3, 4], 2)
t48: list.Take([1, 2, 3, 4], 10)
t49: list.Take([1, 2, 3, 4], -1)
t50: list.MinItems([1, 2, 3, 4], 2)
t51: list.MinItems([1, 2, 3, 4], 5)
t52: list.MaxItems([1, 2, 3, 4], 5)
t53: list.MaxItems([1, 2, 3, 4], 2)
t54: list.Sort([{a:1}, {b:2}], list.Ascending)
-- out/list --
Errors:
error in call to list.Avg: empty list:
./in.cue:4:5
t3: cannot use "foo" (type string) as list in argument 1 to list.Avg:
./in.cue:5:14
error in call to list.Drop: negative index:
./in.cue:9:5
error in call to list.FlattenN: cannot use value "foo" (type string) as list:
./in.cue:15:6
./in.cue:15:20
t14: cannot use "foo" (type string) as int in argument 2 to list.FlattenN:
./in.cue:16:24
error in call to list.Max: empty list:
./in.cue:18:6
t17: cannot use "foo" (type string) as list in argument 1 to list.Max:
./in.cue:19:15
error in call to list.Min: empty list:
./in.cue:21:6
t20: cannot use "foo" (type string) as list in argument 1 to list.Min:
./in.cue:22:15
t23: cannot use "foo" (type string) as list in argument 1 to list.Product:
./in.cue:25:19
error in call to list.Range: step must be non zero:
./in.cue:26:6
error in call to list.Range: end must be greater than start when step is positive:
./in.cue:27:6
error in call to list.Range: end must be less than start when step is negative:
./in.cue:28:6
error in call to list.Slice: negative index:
./in.cue:35:6
error in call to list.Slice: invalid index: 3 > 1:
./in.cue:36:6
error in call to list.Slice: slice bounds out of range:
./in.cue:37:6
error in call to list.Slice: slice bounds out of range:
./in.cue:38:6
Ascending.x: error in call to list.Sort: 2 errors in empty disjunction::
./in.cue:46:6
Ascending.y: error in call to list.Sort: 2 errors in empty disjunction::
./in.cue:46:6
t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string:
./in.cue:48:6
./in.cue:48:24
t45: cannot use "foo" (type string) as list in argument 1 to list.Sum:
./in.cue:51:15
error in call to list.Take: negative index:
./in.cue:55:6
Ascending.x: error in call to list.Sort: 2 errors in empty disjunction::
./in.cue:60:6
Ascending.y: error in call to list.Sort: 2 errors in empty disjunction::
./in.cue:60:6
Result:
t1: 2.5
t2: _|_ // error in call to list.Avg: empty list
t3: _|_ // t3: cannot use "foo" (type string) as list in argument 1 to list.Avg
t4: [1, 2, 3, 4]
t5: [3, 4]
t6: []
t7: _|_ // error in call to list.Drop: negative index
t8: [1, 2, 3, 4]
t9: [1, [[2, 3], []], [4]]
t10: [1, [2, 3], [], 4]
t11: [1, 2, 3, 4]
t12: []
t13: _|_ // error in call to list.FlattenN: cannot use value "foo" (type string) as list
t14: _|_ // t14: cannot use "foo" (type string) as int in argument 2 to list.FlattenN
t15: 4
t16: _|_ // error in call to list.Max: empty list
t17: _|_ // t17: cannot use "foo" (type string) as list in argument 1 to list.Max
t18: 1
t19: _|_ // error in call to list.Min: empty list
t20: _|_ // t20: cannot use "foo" (type string) as list in argument 1 to list.Min
t21: 24
t22: 1
t23: _|_ // t23: cannot use "foo" (type string) as list in argument 1 to list.Product
t24: _|_ // error in call to list.Range: step must be non zero
t25: _|_ // error in call to list.Range: end must be greater than start when step is positive
t26: _|_ // error in call to list.Range: end must be less than start when step is negative
t27: [0, 1, 2, 3, 4]
t28: [0]
t29: [0, 2, 4]
t30: [5, 4, 3, 2, 1]
t31: [0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5]
t32: [2, 3]
t33: _|_ // error in call to list.Slice: negative index
t34: _|_ // error in call to list.Slice: invalid index: 3 > 1
t35: _|_ // error in call to list.Slice: slice bounds out of range
t36: _|_ // error in call to list.Slice: slice bounds out of range
t37: []
t38: [1, 2, 3, 4]
t39: [{
a: 1
v: 2
}, {
a: 1
v: 3
}, {
a: 2
v: 1
}]
t40: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors)
t41: ["a", "b"]
t42: _|_ // t42: invalid list element 0 in argument 0 to call: cannot use value 1 (int) as string
t43: 10
t44: 0
t45: _|_ // t45: cannot use "foo" (type string) as list in argument 1 to list.Sum
t46: []
t47: [1, 2]
t48: [1, 2, 3, 4]
t49: _|_ // error in call to list.Take: negative index
t50: true
t51: false
t52: true
t53: false
t54: _|_ // error in call to list.Sort: Ascending.x: 2 errors in empty disjunction: (and 5 more errors)