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:
metagn
2023-06-06 07:54:07 +03:00
committed by GitHub
parent 2ab948ce53
commit b97d603cd0
134 changed files with 189 additions and 374 deletions

View File

@@ -215,9 +215,9 @@ proc jsTests(r: var TResults, cat: Category, options: string) =
for testfile in ["exception/texceptions", "exception/texcpt1",
"exception/texcsub", "exception/tfinally",
"exception/tfinally2", "exception/tfinally3",
"actiontable/tactiontable", "method/tmultimjs",
"collections/tactiontable", "method/tmultimjs",
"varres/tvarres0", "varres/tvarres3", "varres/tvarres4",
"varres/tvartup", "misc/tints", "misc/tunsignedinc",
"varres/tvartup", "int/tints", "int/tunsignedinc",
"async/tjsandnativeasync"]:
test "tests/" & testfile & ".nim"

View File

@@ -380,7 +380,7 @@ proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest,
r.addResult(test, target, extraOptions, expected.nimout, given.nimout, reMsgsDiffer)
elif extractFilename(expected.file) != extractFilename(given.file) and
"internal error:" notin expected.msg:
r.addResult(test, target, extraOptions, expected.filename, given.file, reFilesDiffer)
r.addResult(test, target, extraOptions, expected.file, given.file, reFilesDiffer)
elif expected.line != given.line and expected.line != 0 or
expected.column != given.column and expected.column != 0:
r.addResult(test, target, extraOptions, $expected.line & ':' & $expected.column,

View File

@@ -1,95 +0,0 @@
discard """
disabled: true
"""
import events
type
TProperty*[T] = object of TObject
getProc: proc(property: TProperty[T]): T {.nimcall.}
setProc: proc(property: var TProperty[T], value: T) {.nimcall.}
value: T
ValueChanged*: TEventHandler
Binders: seq[TProperty[T]]
EEmitter: TEventEmitter
# Not a descriptive name but it was that or TPropertyValueChangeEventArgs.
TValueEventArgs[T] = object of TEventArgs
Property*: TProperty[T]
proc newProperty*[T](value: T): TProperty[T] =
var prop: TProperty[T]
prop.EEmitter = initEventEmitter()
prop.Binders = @[]
prop.ValueChanged = initEventHandler("ValueChanged")
prop.value = value
proc getter(property: TProperty[T]): T =
return property.value
prop.getProc = getter
proc setter(property: var TProperty[T], v: T) =
property.value = v
# fire event here
var args: TValueEventArgs[T]
args.Property = property
property.EEmitter.emit(property.ValueChanged, args)
prop.setProc = setter
return prop
proc `prop`[T] (p: TProperty[T]): T =
# I'm assuming this is trying to get a value from the property.
# i.e. myVar = myProperty
return p.getProc(p)
proc `~=`[T] (p: var TProperty[T], v: T) =
# Assuming this is setting the value.
p.setProc(p, v)
proc `$`[T] (p: TProperty[T]): string =
var value = p.getProc(p)
return $value
proc propertyBind*[T](p1: var TProperty[T], p2: var TProperty[T]) =
p1.Binders.add(p2)
# make handler -> handler[T] so trigger even more generics bugs ...
proc handler(e: TEventArgs) =
type TEA = TValueEventArgs[T]
var args = TEA(e)
var val = args.Property.getProc(p1)
for i in countup(0, len(e.Property.ValueChanged.Binders) -1):
var binded = e.Property.ValueChanged.Binders[i]
binded.setProc(binded, val)
echo("Property 1 has changed to " & $val)
if p1.ValueChanged.containsHandler(handler) == false:
addHandler(p1.ValueChanged, handler)
proc `->`[T](p1: var TProperty[T], p2: var TProperty[T]) =
propertyBind(p2,p1)
when true:
# Initial value testing
var myProp = newProperty(5)
echo(myProp)
myProp ~= 7 # Temp operator until overloading of '=' is implemented.
echo(myProp)
# Binding testing
var prop1 = newProperty(9)
var prop2: TProperty[int]
prop2 -> prop1 # Binds prop2 to prop1
prop1 ~= 7
echo(prop2) # Output: 7

View File

@@ -3,7 +3,7 @@ discard """
joinable: "false"
"""
{.compile: "test.c".}
{.compile: "tcompile.c".}
proc foo(a, b: cint): cint {.importc: "foo", cdecl.}

View File

@@ -1,39 +1,39 @@
discard """
targets: "c cpp"
"""
import macros
macro make_test_type(idents: varargs[untyped]): untyped =
result = nnkStmtList.newTree()
var ident_defs: seq[NimNode] = @[]
for i in idents:
ident_defs.add newIdentDefs(i, ident("int"))
result.add newTree(nnkTypeSection,
newTree(nnkTypeDef,
ident("TestType"),
newEmptyNode(),
newTree(nnkObjectTy,
newEmptyNode(),
newEmptyNode(),
newTree(nnkRecList,
ident_defs
)
)
)
)
make_test_type(
auto, bool, catch, char, class, compl, const_cast, default, delete, double,
dynamic_cast, explicit, extern, false, float, friend, goto, int, long,
mutable, namespace, new, operator, private, protected, public, register,
reinterpret_cast, restrict, short, signed, sizeof, static_cast, struct, switch,
this, throw, true, typedef, typeid, typeof, typename, union, packed, unsigned,
virtual, void, volatile, wchar_t, alignas, alignof, constexpr, decltype, nullptr,
noexcept, thread_local, static_assert, char16_t, char32_t
)
# Make sure the type makes it to codegen.
var test_instance: TestType
discard """
targets: "c cpp"
"""
import macros
macro make_test_type(idents: varargs[untyped]): untyped =
result = nnkStmtList.newTree()
var ident_defs: seq[NimNode] = @[]
for i in idents:
ident_defs.add newIdentDefs(i, ident("int"))
result.add newTree(nnkTypeSection,
newTree(nnkTypeDef,
ident("TestType"),
newEmptyNode(),
newTree(nnkObjectTy,
newEmptyNode(),
newEmptyNode(),
newTree(nnkRecList,
ident_defs
)
)
)
)
make_test_type(
auto, bool, catch, char, class, compl, const_cast, default, delete, double,
dynamic_cast, explicit, extern, false, float, friend, goto, int, long,
mutable, namespace, new, operator, private, protected, public, register,
reinterpret_cast, restrict, short, signed, sizeof, static_cast, struct, switch,
this, throw, true, typedef, typeid, typeof, typename, union, packed, unsigned,
virtual, void, volatile, wchar_t, alignas, alignof, constexpr, decltype, nullptr,
noexcept, thread_local, static_assert, char16_t, char32_t
)
# Make sure the type makes it to codegen.
var test_instance: TestType

View File

@@ -36,7 +36,7 @@ switch("define", "nimExperimentalLinenoiseExtra")
# preview APIs are expected to be the new default in upcoming versions
switch("define", "nimPreviewFloatRoundtrip")
switch("define", "nimPreviewDotLikeOps")
#switch("define", "nimPreviewDotLikeOps") # deprecated?
switch("define", "nimPreviewJsonutilsHoleyEnum")
switch("define", "nimPreviewHashRef")
switch("define", "nimPreviewRangeDefault")

View File

@@ -1,9 +0,0 @@
discard """
nimout: '''tannot.nim(9, 1) Warning: efgh; foo1 is deprecated [Deprecated]
tannot.nim(9, 8) Warning: abcd; foo is deprecated [Deprecated]
'''
"""
let foo* {.deprecated: "abcd".} = 42
var foo1* {.deprecated: "efgh".} = 42
foo1 = foo

View File

@@ -1,8 +0,0 @@
discard """
nimout: '''
tconst.nim(8, 9) Warning: abcd; foo is deprecated [Deprecated]
'''
"""
const foo* {.deprecated: "abcd".} = 42
discard foo

View File

@@ -1,10 +0,0 @@
discard """
nimout:'''tmessages.nim(10, 1) Warning: Deprecated since v1.2.0, use 'HelloZ'; hello is deprecated [Deprecated]
'''
"""
proc hello[T](a: T) {.deprecated: "Deprecated since v1.2.0, use 'HelloZ'".} =
discard
hello[int](12)

View File

@@ -1,33 +0,0 @@
discard """
matrix: "--hint:all:off"
nimoutFull: true
nimout: '''
tmodule1.nim(21, 8) Warning: goodbye; importme is deprecated [Deprecated]
tmodule1.nim(24, 10) Warning: Ty is deprecated [Deprecated]
tmodule1.nim(27, 10) Warning: hello; Ty1 is deprecated [Deprecated]
tmodule1.nim(30, 8) Warning: aVar is deprecated [Deprecated]
tmodule1.nim(32, 3) Warning: aProc is deprecated [Deprecated]
tmodule1.nim(33, 3) Warning: hello; aProc1 is deprecated [Deprecated]
'''
"""
# line 20
import importme
block:
var z: Ty
z = 0
block:
var z: Ty1
z = 0
block:
echo aVar
block:
aProc()
aProc1()

View File

@@ -1,28 +0,0 @@
discard """
cmd: '''nim c --warningAsError:Uninit:on --skipCfg --skipParentCfg $file'''
errormsg: "use explicit initialization of 'x' for clarity [Uninit]"
line: 24
disabled: "true"
"""
proc gah[T](x: out T) =
x = 3
proc main =
var a: array[2, int]
var x: int
gah(x)
a[0] = 3
a[x] = 3
echo x
main()
proc mainB =
var a: array[2, int]
var x: int
a[0] = 3
a[x] = 3
echo x
mainB()

View File

@@ -1,6 +1,6 @@
discard """
errormsg: "type mismatch: got <bool> but expected \'string\'"
file: "tsimtych.nim"
file: "tsimpletypecheck.nim"
line: 10
"""
# Test 2

View File

@@ -1,7 +1,3 @@
discard """
exitcode: 0
disabled: '''true'''
"""
import moverloading_typedesc
import tables
@@ -9,7 +5,6 @@ type
LFoo = object
LBar = object
when true:
doAssert FBar.new() == 3

View File

@@ -57,3 +57,27 @@ proc currentlyValid(x: out int; y: out string; cond: bool) =
y = "abc" # <-- error: not every path initializes 'y'
currentlyValid gl, gs, false
block: # previously effects/toutparam
proc gah[T](x: out T) =
x = 3
proc arr1 =
var a: array[2, int]
var x: int
gah(x)
a[0] = 3
a[x] = 3
echo x
arr1()
proc arr2 =
var a: array[2, int]
var x: int
a[0] = 3
a[x] = 3 #[tt.Warning
^ use explicit initialization of 'x' for clarity [Uninit] ]#
echo x
arr2()

View File

@@ -1,31 +0,0 @@
discard """
errormsg: "cannot instantiate T2"
file: "tgenconstraints.nim"
line: 25
disabled: true
"""
type
T1[T: int|string] = object
x: T
T2[T: Ordinal] = object
x: T
var x1: T1[int]
var x2: T1[string]
var x3: T2[int]
proc foo[T](x: T): T2[T] {.discardable.} =
var o: T1[T]
foo(10)
# XXX: allow type intersections in situation like this
proc bar(x: int|TNumber): T1[type(x)] {.discardable.} =
when type(x) is TNumber:
var o: T2[type(x)]
bar "test"
bar 100
bar 1.1

View File

@@ -404,7 +404,7 @@ running: v2
block: # UnusedImport
proc fn(opt: string, expected: string) =
let output = runNimCmdChk("pragmas/mused3.nim", fmt"--warning:all:off --warning:UnusedImport --hint:DuplicateModuleImport {opt}")
let output = runNimCmdChk("msgs/mused3.nim", fmt"--warning:all:off --warning:UnusedImport --hint:DuplicateModuleImport {opt}")
doAssert output == expected, opt & "\noutput:\n" & output & "expected:\n" & expected
fn("-d:case1"): """
mused3.nim(13, 8) Warning: imported and not used: 'mused3b' [UnusedImport]

View File

@@ -1,20 +0,0 @@
discard """
targets: "c cpp js"
"""
import std/strtabs
proc fun()=
let ret = newStringTable(modeCaseSensitive)
ret["foo"] = "bar"
doAssert $ret == "{foo: bar}"
let b = ret["foo"]
doAssert b == "bar"
proc main()=
static: fun()
fun()
main()

View File

@@ -0,0 +1,15 @@
let foo* {.deprecated: "abcd".} = 42
var foo1* {.deprecated: "efgh".} = 42
foo1 = foo #[tt.Warning
^ efgh; foo1 is deprecated [Deprecated]; tt.Warning
^ abcd; foo is deprecated [Deprecated]]#
proc hello[T](a: T) {.deprecated: "Deprecated since v1.2.0, use 'HelloZ'".} =
discard
hello[int](12) #[tt.Warning
^ Deprecated since v1.2.0, use 'HelloZ'; hello is deprecated [Deprecated]]#
const foo2* {.deprecated: "abcd".} = 42
discard foo2 #[tt.Warning
^ abcd; foo2 is deprecated [Deprecated]]#

View File

@@ -1,8 +1,8 @@
discard """
nimout: '''
tdeprecated.nim(23, 3) Warning: a is deprecated [Deprecated]
tdeprecated.nim(30, 11) Warning: asdf; enum 'Foo' which contains field 'a' is deprecated [Deprecated]
tdeprecated.nim(40, 16) Warning: use fooX instead; fooA is deprecated [Deprecated]
tdeprecated2.nim(23, 3) Warning: a is deprecated [Deprecated]
tdeprecated2.nim(30, 11) Warning: asdf; enum 'Foo' which contains field 'a' is deprecated [Deprecated]
tdeprecated2.nim(40, 16) Warning: use fooX instead; fooA is deprecated [Deprecated]
end
'''
"""

View File

@@ -0,0 +1,33 @@
discard """
matrix: "--hint:all:off"
nimoutFull: true
nimout: '''
tdeprecated3.nim(21, 8) Warning: goodbye; mdeprecated3 is deprecated [Deprecated]
tdeprecated3.nim(24, 10) Warning: Ty is deprecated [Deprecated]
tdeprecated3.nim(27, 10) Warning: hello; Ty1 is deprecated [Deprecated]
tdeprecated3.nim(30, 8) Warning: aVar is deprecated [Deprecated]
tdeprecated3.nim(32, 3) Warning: aProc is deprecated [Deprecated]
tdeprecated3.nim(33, 3) Warning: hello; aProc1 is deprecated [Deprecated]
'''
"""
# line 20
import mdeprecated3
block:
var z: Ty
z = 0
block:
var z: Ty1
z = 0
block:
echo aVar
block:
aProc()
aProc1()

View File

@@ -6,7 +6,7 @@ exec "gcc -v"
--define:release
--forceBuild
--path: "../friends"
--path: "../generics"
warning("uninit", off)

View File

@@ -1,3 +1,6 @@
discard """
matrix: "-d:nimPreviewDotLikeOps"
"""
# test for https://github.com/nim-lang/RFCs/issues/341
import std/json
import std/jsonutils

Some files were not shown because too many files have changed in this diff Show More