Files
Nim/tests/borrow/tborrow.nim
Adam Strzelecki e80465dacf tests: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:04:32 +02:00

22 lines
430 B
Nim

discard """
output: "4887 true"
"""
# test the new borrow feature that works with generics:
proc `++`*[T: int | float](a, b: T): T =
result = a + b
type
DI = distinct int
DF = distinct float
DS = distinct string
proc `++`(x, y: DI): DI {.borrow.}
proc `++`(x, y: DF): DF {.borrow.}
proc `$`(x: DI): string {.borrow.}
proc `$`(x: DF): string {.borrow.}
echo 4544.DI ++ 343.DI, " ", (4.5.DF ++ 0.5.DF).float == 5.0