put several issues in tests (#9352)

* put several issues in tests

* remove wrong test
This commit is contained in:
Miran 2018-10-13 20:17:59 +02:00 • committed by Andreas Rumpf
commit d570dea480

View file

@ -15,6 +15,7 @@ f
5 5
() ()
false false
10
true true
true true
true true
@ -30,7 +31,7 @@ Meow
''' '''
""" """
import macros, typetraits import macros, typetraits, os, posix
block t5983: block t5983:
@ -57,20 +58,20 @@ block t3414:
v.empty is bool v.empty is bool
v.front is T v.front is T
popFront v popFront v
proc find(view: View; target: View.T): View = proc find(view: View; target: View.T): View =
result = view result = view
while not result.empty: while not result.empty:
if view.front == target: if view.front == target:
return return
mixin popFront mixin popFront
popFront result popFront result
proc popFront[T](s: var seq[T]) = discard proc popFront[T](s: var seq[T]) = discard
proc empty[T](s: seq[T]): bool = false proc empty[T](s: seq[T]): bool = false
var s1 = @[1, 2, 3] var s1 = @[1, 2, 3]
let s2 = s1.find(10) let s2 = s1.find(10)
@ -293,13 +294,13 @@ block t3452:
XY = tuple[x, y: int] XY = tuple[x, y: int]
MyGraph = object MyGraph = object
points: seq[XY] points: seq[XY]
static: static:
assert XY is Node assert XY is Node
proc distance( g: MyGraph, a, b: XY): float = proc distance( g: MyGraph, a, b: XY): float =
sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) ) sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) )
static: static:
assert MyGraph is Graph1 assert MyGraph is Graph1
assert MyGraph is Graph2 assert MyGraph is Graph2
@ -313,13 +314,58 @@ block t6691:
ConceptB = concept c ConceptB = concept c
c.myProc(ConceptA) c.myProc(ConceptA)
Obj = object Obj = object
proc myProc(obj: Obj, x: ConceptA) = discard proc myProc(obj: Obj, x: ConceptA) = discard
echo Obj is ConceptB 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: block misc_issues:
# https://github.com/nim-lang/Nim/issues/1147 # https://github.com/nim-lang/Nim/issues/1147
type TTest = object type TTest = object