Implement the is operator for the new static and typedesc type classes
This also makes the first baby steps towards a sound treatment of higher-order kinds (type type int). Adds test cases showcasing the new features. * Also fixes breakage after the rebase
This commit is contained in:
parent
ab9969ed3b
commit
a49b06a52a
10 changed files with 210 additions and 55 deletions
|
|
@ -1,17 +1,42 @@
|
|||
discard """
|
||||
action: run
|
||||
"""
|
||||
|
||||
type
|
||||
R = ref
|
||||
V = var
|
||||
D = distinct
|
||||
P = ptr
|
||||
T = type
|
||||
S = static
|
||||
OBJ = object
|
||||
TPL = tuple
|
||||
SEQ = seq
|
||||
|
||||
var i: int
|
||||
var x: ref int
|
||||
var y: distinct int
|
||||
var z: ptr int
|
||||
const C = @[1, 2, 3]
|
||||
|
||||
static:
|
||||
assert x is ref
|
||||
assert y is distinct
|
||||
assert z is ptr
|
||||
assert C is static
|
||||
assert C[1] is static[int]
|
||||
assert C[0] is static[SomeInteger]
|
||||
assert C isnot static[string]
|
||||
assert C is SEQ|OBJ
|
||||
assert C isnot OBJ|TPL
|
||||
assert int is int
|
||||
assert int is T
|
||||
assert int is SomeInteger
|
||||
assert seq[int] is type
|
||||
assert seq[int] is type[seq]
|
||||
assert seq[int] isnot type[seq[float]]
|
||||
assert i isnot type[int]
|
||||
assert type(i) is type[int]
|
||||
assert x isnot T
|
||||
assert y isnot S
|
||||
assert z isnot enum
|
||||
assert x isnot object
|
||||
assert y isnot tuple
|
||||
assert z isnot seq
|
||||
|
||||
doAssert x is ref
|
||||
doAssert y is distinct
|
||||
doAssert z is ptr
|
||||
Loading…
Add table
Add a link
Reference in a new issue