mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
some test cleanups & category reorganization (#22010)
* clean up some test categories * mention exact slice issue * magics into system * move trangechecks into overflow * move tmemory to system * try fix CI * try fix CI * final CI fix
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
discard """
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
type
|
||||
TRecord = (tuple) or (object)
|
||||
|
||||
TFoo[T, U] = object
|
||||
x: int
|
||||
|
||||
when T is string:
|
||||
y: float
|
||||
else:
|
||||
y: string
|
||||
|
||||
when U is TRecord:
|
||||
z: float
|
||||
|
||||
E = enum A, B, C
|
||||
|
||||
macro m(t: typedesc): typedesc =
|
||||
if t is enum:
|
||||
result = string
|
||||
else:
|
||||
result = int
|
||||
|
||||
var f: TFoo[int, int]
|
||||
static: doAssert(f.y.type.name == "string")
|
||||
|
||||
when compiles(f.z):
|
||||
{.error: "Foo should not have a `z` field".}
|
||||
|
||||
proc p(a, b: auto) =
|
||||
when a.type is int:
|
||||
static: doAssert false
|
||||
|
||||
var f: TFoo[m(a.type), b.type]
|
||||
static:
|
||||
doAssert f.x.type.name == "int"
|
||||
echo f.y.type.name
|
||||
doAssert f.y.type.name == "float"
|
||||
echo f.z.type.name
|
||||
doAssert f.z.type.name == "float"
|
||||
|
||||
p(A, f)
|
||||
|
||||
@@ -135,3 +135,33 @@ block:
|
||||
let Q = MyObj[P](y: 2)
|
||||
doAssert($Q == "(y: 2)")
|
||||
|
||||
block: # previously tisop.nim
|
||||
type
|
||||
TRecord = (tuple) or (object)
|
||||
TFoo[T, U] = object
|
||||
x: int
|
||||
when T is string:
|
||||
y: float
|
||||
else:
|
||||
y: string
|
||||
when U is TRecord:
|
||||
z: float
|
||||
E = enum A, B, C
|
||||
template m(t: typedesc): typedesc =
|
||||
when t is enum:
|
||||
string
|
||||
else:
|
||||
int
|
||||
var f: TFoo[int, int]
|
||||
static: doAssert(typeof(f.y) is string)
|
||||
when compiles(f.z):
|
||||
{.error: "Foo should not have a `z` field".}
|
||||
proc p(a, b: auto) =
|
||||
when typeof(a) is int:
|
||||
static: doAssert false
|
||||
var f: TFoo[m(a.typeof), b.typeof]
|
||||
static:
|
||||
doAssert f.x.typeof is int
|
||||
doAssert f.y.typeof is float
|
||||
doAssert f.z.typeof is float
|
||||
p(A, f)
|
||||
|
||||
Reference in New Issue
Block a user