* Consolidated types issue tests * Consolidated vm issue tests
This commit is contained in:
parent
1b17c9f693
commit
5ddeead29c
9 changed files with 102 additions and 100 deletions
|
|
@ -1,12 +0,0 @@
|
||||||
discard """
|
|
||||||
output: '''true
|
|
||||||
true
|
|
||||||
true
|
|
||||||
true
|
|
||||||
'''
|
|
||||||
"""
|
|
||||||
|
|
||||||
echo float32 isnot float64
|
|
||||||
echo float32 isnot float
|
|
||||||
echo int32 isnot int64
|
|
||||||
echo int32 isnot int
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
type
|
|
||||||
vecBase[I: static[int]] = distinct array[I, float32]
|
|
||||||
vec2* = vecBase[2]
|
|
||||||
|
|
||||||
var v = vec2([0.0'f32, 0.0'f32])
|
|
||||||
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
discard """
|
|
||||||
output: "ptr Foo"
|
|
||||||
"""
|
|
||||||
|
|
||||||
import typetraits
|
|
||||||
|
|
||||||
type Foo = object
|
|
||||||
bar*: int
|
|
||||||
|
|
||||||
proc main() =
|
|
||||||
var f = create(Foo)
|
|
||||||
f.bar = 3
|
|
||||||
echo f.type.name
|
|
||||||
|
|
||||||
discard realloc(f, 0)
|
|
||||||
|
|
||||||
var g = Foo()
|
|
||||||
g.bar = 3
|
|
||||||
|
|
||||||
main()
|
|
||||||
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
discard int -1
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
discard """
|
|
||||||
output: '''
|
|
||||||
(member: "hello world")
|
|
||||||
(member: 123.456)
|
|
||||||
(member: "hello world", x: ...)
|
|
||||||
(member: 123.456, x: ...)
|
|
||||||
'''
|
|
||||||
"""
|
|
||||||
|
|
||||||
template foobar(arg: typed): untyped =
|
|
||||||
type
|
|
||||||
MyType = object
|
|
||||||
member: type(arg)
|
|
||||||
|
|
||||||
var myVar: MyType
|
|
||||||
myVar.member = arg
|
|
||||||
echo myVar
|
|
||||||
|
|
||||||
foobar("hello world")
|
|
||||||
foobar(123.456'f64)
|
|
||||||
|
|
||||||
template foobarRec(arg: typed): untyped =
|
|
||||||
type
|
|
||||||
MyType = object
|
|
||||||
member: type(arg)
|
|
||||||
x: ref MyType
|
|
||||||
|
|
||||||
var myVar: MyType
|
|
||||||
myVar.member = arg
|
|
||||||
echo myVar
|
|
||||||
|
|
||||||
foobarRec("hello world")
|
|
||||||
foobarRec(123.456'f64)
|
|
||||||
72
tests/types/tissues.nim
Normal file
72
tests/types/tissues.nim
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
discard """
|
||||||
|
output: '''true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
ptr Foo
|
||||||
|
(member: "hello world")
|
||||||
|
(member: 123.456)
|
||||||
|
(member: "hello world", x: ...)
|
||||||
|
(member: 123.456, x: ...)
|
||||||
|
'''
|
||||||
|
"""
|
||||||
|
|
||||||
|
import typetraits
|
||||||
|
|
||||||
|
block t1252:
|
||||||
|
echo float32 isnot float64
|
||||||
|
echo float32 isnot float
|
||||||
|
echo int32 isnot int64
|
||||||
|
echo int32 isnot int
|
||||||
|
|
||||||
|
block t5640:
|
||||||
|
type
|
||||||
|
vecBase[I: static[int]] = distinct array[I, float32]
|
||||||
|
vec2 = vecBase[2]
|
||||||
|
|
||||||
|
var v = vec2([0.0'f32, 0.0'f32])
|
||||||
|
|
||||||
|
block t5648:
|
||||||
|
type Foo = object
|
||||||
|
bar: int
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
var f = create(Foo)
|
||||||
|
f.bar = 3
|
||||||
|
echo f.type.name
|
||||||
|
|
||||||
|
discard realloc(f, 0)
|
||||||
|
|
||||||
|
var g = Foo()
|
||||||
|
g.bar = 3
|
||||||
|
|
||||||
|
main()
|
||||||
|
|
||||||
|
block t7581:
|
||||||
|
discard int -1
|
||||||
|
|
||||||
|
block t7905:
|
||||||
|
template foobar(arg: typed): untyped =
|
||||||
|
type
|
||||||
|
MyType = object
|
||||||
|
member: type(arg)
|
||||||
|
|
||||||
|
var myVar: MyType
|
||||||
|
myVar.member = arg
|
||||||
|
echo myVar
|
||||||
|
|
||||||
|
foobar("hello world")
|
||||||
|
foobar(123.456'f64)
|
||||||
|
|
||||||
|
template foobarRec(arg: typed): untyped =
|
||||||
|
type
|
||||||
|
MyType = object
|
||||||
|
member: type(arg)
|
||||||
|
x: ref MyType
|
||||||
|
|
||||||
|
var myVar: MyType
|
||||||
|
myVar.member = arg
|
||||||
|
echo myVar
|
||||||
|
|
||||||
|
foobarRec("hello world")
|
||||||
|
foobarRec(123.456'f64)
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import macros
|
|
||||||
|
|
||||||
proc doCheck(tree: NimNode) =
|
|
||||||
let res: tuple[n: NimNode] = (n: tree)
|
|
||||||
assert: tree.kind == res.n.kind
|
|
||||||
for sub in tree:
|
|
||||||
doCheck(sub)
|
|
||||||
|
|
||||||
macro id(body: untyped): untyped =
|
|
||||||
doCheck(body)
|
|
||||||
|
|
||||||
id(foo((i: int)))
|
|
||||||
|
|
||||||
static:
|
|
||||||
let tree = newTree(nnkExprColonExpr)
|
|
||||||
let t = (n: tree)
|
|
||||||
assert: t.n.kind == tree.kind
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
discard """
|
|
||||||
nimout: "(Field0: 2, Field1: 2, Field2: 2, Field3: 2)"
|
|
||||||
"""
|
|
||||||
|
|
||||||
proc foo[N: static[int]](dims: array[N, int])=
|
|
||||||
const N1 = N
|
|
||||||
const N2 = dims.len
|
|
||||||
static: echo (N, dims.len, N1, N2)
|
|
||||||
|
|
||||||
foo([1, 2])
|
|
||||||
30
tests/vm/tissues.nim
Normal file
30
tests/vm/tissues.nim
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
discard """
|
||||||
|
nimout: "(Field0: 2, Field1: 2, Field2: 2, Field3: 2)"
|
||||||
|
"""
|
||||||
|
|
||||||
|
import macros
|
||||||
|
|
||||||
|
block t9043:
|
||||||
|
proc foo[N: static[int]](dims: array[N, int])=
|
||||||
|
const N1 = N
|
||||||
|
const N2 = dims.len
|
||||||
|
static: echo (N, dims.len, N1, N2)
|
||||||
|
|
||||||
|
foo([1, 2])
|
||||||
|
|
||||||
|
block t4952:
|
||||||
|
proc doCheck(tree: NimNode) =
|
||||||
|
let res: tuple[n: NimNode] = (n: tree)
|
||||||
|
assert: tree.kind == res.n.kind
|
||||||
|
for sub in tree:
|
||||||
|
doCheck(sub)
|
||||||
|
|
||||||
|
macro id(body: untyped): untyped =
|
||||||
|
doCheck(body)
|
||||||
|
|
||||||
|
id(foo((i: int)))
|
||||||
|
|
||||||
|
static:
|
||||||
|
let tree = newTree(nnkExprColonExpr)
|
||||||
|
let t = (n: tree)
|
||||||
|
assert: t.n.kind == tree.kind
|
||||||
Loading…
Add table
Add a link
Reference in a new issue