Merge tests into a larger file (part 5 of ∞) (#9368)
* merge magics * merge metatype tests * merge method tests * merge objects tests * change `import future` to `import sugar` Nim in Action tests are left with `import future`, to ensure compatibility. * merge overload tests * merge proc tests * merge procvar tests * merge range tests * merge seq tests * merge sets tests * remove wrong assert from `tsets3` * fix `jsTests` * better fix
This commit is contained in:
parent
f04c93b5dd
commit
749dbce4c6
96 changed files with 1763 additions and 1815 deletions
45
tests/magics/tmagics.nim
Normal file
45
tests/magics/tmagics.nim
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
discard """
|
||||
output: '''
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
true
|
||||
false
|
||||
true
|
||||
'''
|
||||
"""
|
||||
|
||||
block tlowhigh:
|
||||
type myEnum = enum e1, e2, e3, e4, e5
|
||||
var a: array[myEnum, int]
|
||||
|
||||
for i in low(a) .. high(a):
|
||||
a[i] = 0
|
||||
|
||||
proc sum(a: openarray[int]): int =
|
||||
result = 0
|
||||
for i in low(a)..high(a):
|
||||
inc(result, a[i])
|
||||
|
||||
doAssert sum([1, 2, 3, 4]) == 10
|
||||
|
||||
|
||||
block t8693:
|
||||
type Foo = int | float
|
||||
|
||||
proc bar(t1, t2: typedesc): bool =
|
||||
echo (t1 is t2)
|
||||
(t2 is t1)
|
||||
|
||||
proc bar[T](x: T, t2: typedesc): bool =
|
||||
echo (T is t2)
|
||||
(t2 is T)
|
||||
|
||||
doAssert bar(int, Foo) == false
|
||||
doAssert bar(4, Foo) == false
|
||||
doAssert bar(any, int)
|
||||
doAssert bar(int, any) == false
|
||||
doAssert bar(Foo, Foo)
|
||||
doAssert bar(any, Foo)
|
||||
doAssert bar(Foo, any) == false
|
||||
Loading…
Add table
Add a link
Reference in a new issue