type Item {
name: Str
price: Int
}
func total(items: Item[]): Int {
mut sum := 0
for each item in items {
sum = sum + item.price
}
return sum
}
test "an empty cart costs nothing" {
Item[0] empty = []
assert total(empty) == 0
}
test "two items add up" {
assert total([Item("wax", 5), Item("comb", 3)]) == 8
}