erg/tests/should_ok/default_param.er
2024-04-24 15:24:05 +09:00

20 lines
438 B
Python

f x: Int, y: Int := 1, z: Nat := 2 = x + y + z
assert f(1) == 4
assert f(1, 2) == 5
assert f(1, 2, 3) == 6
id_or_int x := 1 = x
i = id_or_int()
s = id_or_int "a"
assert i + 1 + 1 == 3
assert s + "b" == "ab"
_: (Int, y := Int, z := Nat) -> Int = f
_: (Int, y := Int) -> Int = f
_: Int -> Int = f
_: (Int, Int) -> Int = f
_: (Int, Int, Nat) -> Int = f
_: (Int, Int, _: {1}) -> Int = f
_: Int -> Int = id_or_int
_: Str -> Str = id_or_int