More descriptive names of test files (#9531)
* change generic `tissues` name to more specific * change `tvarious` to more specific names
This commit is contained in:
parent
8d9866a6d4
commit
1b17c9f693
20 changed files with 8 additions and 7 deletions
67
tests/distinct/tdistinct_issues.nim
Normal file
67
tests/distinct/tdistinct_issues.nim
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
discard """
|
||||
output: '''
|
||||
A
|
||||
A
|
||||
25.0
|
||||
210.0
|
||||
apr
|
||||
'''
|
||||
"""
|
||||
|
||||
|
||||
block t4435:
|
||||
type
|
||||
A[T] = distinct T
|
||||
B[T] = distinct T
|
||||
|
||||
proc foo[T](x:A[T]) = echo "A"
|
||||
proc foo[T](x:B[T]) = echo "B"
|
||||
proc bar(x:A) = echo "A"
|
||||
proc bar(x:B) = echo "B"
|
||||
|
||||
var
|
||||
a:A[int]
|
||||
|
||||
foo(a) # fine
|
||||
bar(a) # testdistinct.nim(14, 4) Error: ambiguous call; both testdistinct.bar(x: A) and testdistinct.bar(x: B) match for: (A[system.int])
|
||||
|
||||
|
||||
|
||||
block t7010:
|
||||
type MyInt = distinct int
|
||||
|
||||
proc `+`(x: MyInt, y: MyInt): MyInt {.borrow.}
|
||||
proc `+=`(x: var MyInt, y: MyInt) {.borrow.}
|
||||
proc `=`(x: var MyInt, y: MyInt) {.borrow.}
|
||||
|
||||
var next: MyInt
|
||||
|
||||
proc getNext() : MyInt =
|
||||
result = next
|
||||
next += 1.MyInt
|
||||
next = next + 1.MyInt
|
||||
|
||||
|
||||
|
||||
block t9079:
|
||||
type
|
||||
Dollars = distinct float
|
||||
|
||||
proc `$`(d: Dollars): string {.borrow.}
|
||||
proc `*`(a, b: Dollars): Dollars {.borrow.}
|
||||
proc `+`(a, b: Dollars): Dollars {.borrow.}
|
||||
|
||||
var a = Dollars(20)
|
||||
a = Dollars(25.0)
|
||||
echo a
|
||||
a = 10.Dollars * (20.Dollars + 1.Dollars)
|
||||
echo a
|
||||
|
||||
|
||||
|
||||
block t9322:
|
||||
type Fix = distinct string
|
||||
proc `$`(f: Fix): string {.borrow.}
|
||||
proc mystr(s: string) =
|
||||
echo s
|
||||
mystr($Fix("apr"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue