diff options
author | Miran <narimiran@users.noreply.github.com> | 2018-10-13 20:17:59 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-10-13 20:17:59 +0200 |
commit | d570dea4807c30ec1463691dc722a9e35e773371 (patch) | |
tree | 4d3db9ecf5188d1a2e5208eccfdeec58e10a447e /tests/concepts/tissues.nim | |
parent | e435dbd35e1bc6ae0ec7c348ae7f66ef7bc2eb88 (diff) | |
download | Nim-d570dea4807c30ec1463691dc722a9e35e773371.tar.gz |
put several issues in tests (#9352)
* put several issues in tests * remove wrong test
Diffstat (limited to 'tests/concepts/tissues.nim')
-rw-r--r-- | tests/concepts/tissues.nim | 68 |
1 files changed, 57 insertions, 11 deletions
diff --git a/tests/concepts/tissues.nim b/tests/concepts/tissues.nim index 080711434..e145b9f37 100644 --- a/tests/concepts/tissues.nim +++ b/tests/concepts/tissues.nim @@ -15,6 +15,7 @@ f 5 () false +10 true true true @@ -30,7 +31,7 @@ Meow ''' """ -import macros, typetraits +import macros, typetraits, os, posix block t5983: @@ -57,20 +58,20 @@ block t3414: v.empty is bool v.front is T popFront v - + proc find(view: View; target: View.T): View = result = view - + while not result.empty: if view.front == target: return - + mixin popFront popFront result - + proc popFront[T](s: var seq[T]) = discard proc empty[T](s: seq[T]): bool = false - + var s1 = @[1, 2, 3] let s2 = s1.find(10) @@ -293,13 +294,13 @@ block t3452: XY = tuple[x, y: int] MyGraph = object points: seq[XY] - + static: assert XY is Node - + proc distance( g: MyGraph, a, b: XY): float = sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) ) - + static: assert MyGraph is Graph1 assert MyGraph is Graph2 @@ -313,13 +314,58 @@ block t6691: ConceptB = concept c c.myProc(ConceptA) Obj = object - + proc myProc(obj: Obj, x: ConceptA) = discard - + echo Obj is ConceptB +block t6782: + type + Reader = concept c + c.read(openarray[byte], int, int) is int + Rdr = concept c + c.rd(openarray[byte], int, int) is int + + type TestFile = object + + proc read(r: TestFile, dest: openarray[byte], offset: int, limit: int): int = + result = 0 + proc rd(r: TestFile, dest: openarray[byte], offset: int, limit: int): int = + result = 0 + + doAssert TestFile is Reader + doAssert TestFile is Rdr + + + +block t7114: + type + MyConcept = concept x + x.close() # error, doesn't work + MyConceptImplementer = object + + proc close(self: MyConceptImplementer) = discard + proc takeConcept(window: MyConcept) = + discard + + takeConcept(MyConceptImplementer()) + + + +block t7510: + type + A[T] = concept a + a.x is T + B[T] = object + x: T + proc getx(v: A): v.T = v.x + var v = B[int32](x: 10) + echo v.getx + + + block misc_issues: # https://github.com/nim-lang/Nim/issues/1147 type TTest = object |