diff options
author | Arne Döring <arne.doering@gmx.net> | 2018-11-29 16:07:51 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-12-11 21:23:21 +0100 |
commit | 1105d0364401226a2d7d479bd89d77a9da9ed787 (patch) | |
tree | 559160c7497208ca53fb05fc5e97ae03e12e4187 /tests/concepts/tconcepts.nim | |
parent | ca394ebd9514edd6e5f5e5c3d3145aa868744647 (diff) | |
download | Nim-1105d0364401226a2d7d479bd89d77a9da9ed787.tar.gz |
require errormsg to be specified before file.
Diffstat (limited to 'tests/concepts/tconcepts.nim')
-rw-r--r-- | tests/concepts/tconcepts.nim | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/tests/concepts/tconcepts.nim b/tests/concepts/tconcepts.nim index dec1dafe0..d0bc76c20 100644 --- a/tests/concepts/tconcepts.nim +++ b/tests/concepts/tconcepts.nim @@ -1,6 +1,5 @@ discard """ - file: "tconcepts.nim" - output: ''' +output: ''' 10 20 int @@ -378,53 +377,53 @@ block tvectorspace: block tstack: template reject(e) = static: assert(not compiles(e)) - + type ArrayStack = object data: seq[int] - + proc push(s: var ArrayStack, item: int) = s.data.add item - + proc pop(s: var ArrayStack): int = return s.data.pop() - + type Stack[T] = concept var s s.push(T) s.pop() is T - + type ValueType = T const ValueTypeName = T.name.toUpperAscii - + proc genericAlgorithm[T](s: var Stack[T], y: T) = static: echo "INFERRED ", T.name echo "VALUE TYPE ", s.ValueType.name echo "VALUE TYPE NAME ", s.ValueTypeName - + s.push(y) echo s.pop - + proc implicitGeneric(s: var Stack): auto = static: echo "IMPLICIT INFERRED ", s.T.name, " ", Stack.T.name echo "IMPLICIT VALUE TYPE ", s.ValueType.name, " ", Stack.ValueType.name echo "IMPLICIT VALUE TYPE NAME ", s.ValueTypeName, " ", Stack.ValueTypeName - + return s.pop() - + var s = ArrayStack(data: @[]) - + s.push 10 s.genericAlgorithm 20 echo s.implicitGeneric - + reject s.genericAlgorithm "x" reject s.genericAlgorithm 1.0 reject "str".implicitGeneric reject implicitGeneric(10) - + import libs/[trie_database, trie] |