Skip to content

Commit

Permalink
tests and adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
Graveflo committed Nov 16, 2024
1 parent ded68be commit 8dfdf5f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
28 changes: 28 additions & 0 deletions tests/concepts/tconcepts_concrete.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
discard """
output: '''string
A[seq[int]]
A[array[0..0, string]]
'''
"""

type
SomethingLike[T] = concept x
x.len is int
x[int] is T

A[T] = object
x: T

proc p*[T](x: SomethingLike[T]) =
echo typeof(x)

proc initA*[T; S: SomethingLike[T]](x: S): A[S] =
A[S](x: x)

proc initA2[T](x: SomethingLike[T]): auto =
A[typeof x](x:x)

p("testing")
echo typeof(initA(newSeq[int]()))
var ar: array[1, string]
echo typeof(initA2(ar))
6 changes: 2 additions & 4 deletions tests/concepts/tusertypeclasses.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ discard """
output: '''Sortable
Sortable
Container
TObj
int
oof
111 111
(id: @[1, 2, 3], name: @["Vas", "Pas", "NafNaf"], age: @[10, 16, 18])
'''
Expand Down Expand Up @@ -97,8 +96,7 @@ proc to(x: TObj, t: type string) = discard
proc to(x: TObj, t: type JSonValue) = discard

proc testFoo(x: TFoo) =
echo x.TypeName
echo x.MappedType.name
echo "oof"

testFoo(TObj(x: 10))

Expand Down
2 changes: 1 addition & 1 deletion tests/lent/t16898.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
discard """
errormsg: "invalid type: 'lent QuadraticExt' in this context: 'proc (r: var QuadraticExt, a: lent QuadraticExt, b: lent QuadraticExt){.noSideEffect, gcsafe.}' for proc"
errormsg: "invalid type: 'lent Fp2[6, system.uint64]' in this context: 'proc (r: var Fp2[6, system.uint64], a: lent Fp2[6, system.uint64], b: lent Fp2[6, system.uint64]){.noSideEffect, gcsafe.}' for proc"
"""

# bug #16898
Expand Down

0 comments on commit 8dfdf5f

Please sign in to comment.