diff options
Diffstat (limited to 'tests/bind')
-rw-r--r-- | tests/bind/mbind3.nim | 10 | ||||
-rw-r--r-- | tests/bind/tbind.nim | 78 | ||||
-rw-r--r-- | tests/bind/tdatabind.nim | 95 | ||||
-rw-r--r-- | tests/bind/tinvalidbindtypedesc.nim | 10 | ||||
-rw-r--r-- | tests/bind/tnicerrorforsymchoice.nim | 23 | ||||
-rw-r--r-- | tests/bind/told_bind_expr.nim | 15 |
6 files changed, 0 insertions, 231 deletions
diff --git a/tests/bind/mbind3.nim b/tests/bind/mbind3.nim deleted file mode 100644 index 1a7d3b63b..000000000 --- a/tests/bind/mbind3.nim +++ /dev/null @@ -1,10 +0,0 @@ -# Module A -var - lastId = 0 - -template genId*: int = - bind lastId - inc(lastId) - lastId - - diff --git a/tests/bind/tbind.nim b/tests/bind/tbind.nim deleted file mode 100644 index f3fb952e3..000000000 --- a/tests/bind/tbind.nim +++ /dev/null @@ -1,78 +0,0 @@ -discard """ -output: ''' -3 -1 -1 -1 -5 -''' -""" - - -block tbind: -# Test the new ``bind`` keyword for templates - - proc p1(x: int8, y: int): int = return x + y - - template tempBind(x, y): untyped = - bind p1 - p1(x, y) - - proc p1(x: int, y: int8): int = return x - y - - # This is tricky: the call to ``p1(1'i8, 2'i8)`` should not fail in line 6, - # because it is not ambiguous there. But it is ambiguous after line 8. - - echo tempBind(1'i8, 2'i8) #OUT 3 - - -import mbind3 -echo genId() #OUT 1 - - -import strtabs -block tbinoverload: - template t() = - block: - bind newStringTable - discard {"Content-Type": "text/html"}.newStringTable() - - discard {:}.newStringTable - #discard {"Content-Type": "text/html"}.newStringTable() - t() - - -block tmixin: - type - TFoo1 = object of RootObj - v: int - TFoo2 = object of TFoo1 - v2: int - - proc test(f: TFoo1) = - echo "1" - - proc Foo[T](f: T) = - mixin test - test(f) - - var - a: TFoo1 - b: TFoo2 - - - proc test(f: TFoo2) = - echo "2" - - Foo(a) - Foo(b) - -# issue #11811 -proc p(a : int) = - echo a - -proc printVar*[T:int|float|string](a : T) = - bind p - p(a) - -printVar(5) diff --git a/tests/bind/tdatabind.nim b/tests/bind/tdatabind.nim deleted file mode 100644 index f6455749c..000000000 --- a/tests/bind/tdatabind.nim +++ /dev/null @@ -1,95 +0,0 @@ -discard """ - disabled: true -""" - -import events -type - TProperty*[T] = object of TObject - getProc: proc(property: TProperty[T]): T {.nimcall.} - setProc: proc(property: var TProperty[T], value: T) {.nimcall.} - value: T - ValueChanged*: TEventHandler - Binders: seq[TProperty[T]] - EEmitter: TEventEmitter - # Not a descriptive name but it was that or TPropertyValueChangeEventArgs. - TValueEventArgs[T] = object of TEventArgs - Property*: TProperty[T] - - -proc newProperty*[T](value: T): TProperty[T] = - var prop: TProperty[T] - - prop.EEmitter = initEventEmitter() - prop.Binders = @[] - prop.ValueChanged = initEventHandler("ValueChanged") - prop.value = value - - proc getter(property: TProperty[T]): T = - return property.value - - prop.getProc = getter - - proc setter(property: var TProperty[T], v: T) = - property.value = v - - # fire event here - var args: TValueEventArgs[T] - args.Property = property - property.EEmitter.emit(property.ValueChanged, args) - - prop.setProc = setter - - return prop - -proc `prop`[T] (p: TProperty[T]): T = - # I'm assuming this is trying to get a value from the property. - # i.e. myVar = myProperty - return p.getProc(p) - -proc `~=`[T] (p: var TProperty[T], v: T) = - # Assuming this is setting the value. - p.setProc(p, v) - -proc `$`[T] (p: TProperty[T]): string = - var value = p.getProc(p) - return $value - -proc propertyBind*[T](p1: var TProperty[T], p2: var TProperty[T]) = - p1.Binders.add(p2) - - # make handler -> handler[T] so trigger even more generics bugs ... - proc handler(e: TEventArgs) = - type TEA = TValueEventArgs[T] - var args = TEA(e) - var val = args.Property.getProc(p1) - for i in countup(0, len(e.Property.ValueChanged.Binders) -1): - var binded = e.Property.ValueChanged.Binders[i] - binded.setProc(binded, val) - - echo("Property 1 has changed to " & $val) - - if p1.ValueChanged.containsHandler(handler) == false: - addHandler(p1.ValueChanged, handler) - -proc `->`[T](p1: var TProperty[T], p2: var TProperty[T]) = - propertyBind(p2,p1) - -when true: - # Initial value testing - var myProp = newProperty(5) - - echo(myProp) - - myProp ~= 7 # Temp operator until overloading of '=' is implemented. - echo(myProp) - - # Binding testing - - var prop1 = newProperty(9) - var prop2: TProperty[int] - - prop2 -> prop1 # Binds prop2 to prop1 - - prop1 ~= 7 - echo(prop2) # Output: 7 - diff --git a/tests/bind/tinvalidbindtypedesc.nim b/tests/bind/tinvalidbindtypedesc.nim deleted file mode 100644 index 1c71c8daf..000000000 --- a/tests/bind/tinvalidbindtypedesc.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - errormsg: "type mismatch: got <typedesc[float], string>" - line: 10 -""" - -proc foo(T: typedesc; some: T) = - echo($some) - -foo int, 4 -foo float, "bad" diff --git a/tests/bind/tnicerrorforsymchoice.nim b/tests/bind/tnicerrorforsymchoice.nim deleted file mode 100644 index 6001b6b09..000000000 --- a/tests/bind/tnicerrorforsymchoice.nim +++ /dev/null @@ -1,23 +0,0 @@ -discard """ - errormsg: "type mismatch: got <proc (s: TScgi: ScgiState or AsyncScgiState) | proc (client: AsyncSocket, headers: StringTableRef, input: string){.noSideEffect, gcsafe.}>" - line: 23 -""" - -# Fake ScgiState objects, from now-deprecated scgi module -type - ScgiState* = object of RootObj ## SCGI state object - AsyncScgiState* = object of RootObj ## SCGI state object - -#bug #442 -import asyncnet, strtabs -proc handleSCGIRequest[TScgi: ScgiState | AsyncScgiState](s: TScgi) = - discard -proc handleSCGIRequest(client: AsyncSocket, headers: StringTableRef, - input: string) = - discard - -proc test(handle: proc (client: AsyncSocket, headers: StringTableRef, - input: string), b: int) = - discard - -test(handleSCGIRequest) diff --git a/tests/bind/told_bind_expr.nim b/tests/bind/told_bind_expr.nim deleted file mode 100644 index 56389eaf6..000000000 --- a/tests/bind/told_bind_expr.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ - errormsg: "ambiguous call" - file: "told_bind_expr.nim" - line: 13 -""" - -# Pre-0.9 deprecated bind expression syntax - -proc p1(x: int8, y: int): int = return x + y -proc p1(x: int, y: int8): int = return x - y - -template tempBind(x, y): untyped = - (bind p1(x, y)) #ERROR_MSG ambiguous call - -echo tempBind(1'i8, 2'i8) |