diff --git a/testament/categories.nim b/testament/categories.nim index 946f99fd6a..c449cf3e04 100644 --- a/testament/categories.nim +++ b/testament/categories.nim @@ -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" diff --git a/testament/testament.nim b/testament/testament.nim index 1ed5ef92a2..5f443ffba0 100644 --- a/testament/testament.nim +++ b/testament/testament.nim @@ -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, diff --git a/tests/misc/tinvalidarrayaccess.nim b/tests/array/tinvalidarrayaccess.nim similarity index 100% rename from tests/misc/tinvalidarrayaccess.nim rename to tests/array/tinvalidarrayaccess.nim diff --git a/tests/misc/tinvalidarrayaccess2.nim b/tests/array/tinvalidarrayaccess2.nim similarity index 100% rename from tests/misc/tinvalidarrayaccess2.nim rename to tests/array/tinvalidarrayaccess2.nim diff --git a/tests/bind/tdatabind.nim b/tests/bind/tdatabind.nim deleted file mode 100644 index f6455749c9..0000000000 --- a/tests/bind/tdatabind.nim +++ /dev/null @@ -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 - diff --git a/tests/compilepragma/test.c b/tests/c/tcompile.c similarity index 100% rename from tests/compilepragma/test.c rename to tests/c/tcompile.c diff --git a/tests/compilepragma/test.nim b/tests/c/tcompile.nim similarity index 83% rename from tests/compilepragma/test.nim rename to tests/c/tcompile.nim index 56087fa577..cf99fd7edb 100644 --- a/tests/compilepragma/test.nim +++ b/tests/c/tcompile.nim @@ -3,7 +3,7 @@ discard """ joinable: "false" """ -{.compile: "test.c".} +{.compile: "tcompile.c".} proc foo(a, b: cint): cint {.importc: "foo", cdecl.} diff --git a/tests/misc/temit.nim b/tests/c/temit.nim similarity index 100% rename from tests/misc/temit.nim rename to tests/c/temit.nim diff --git a/tests/misc/treservedcidentsasfields.nim b/tests/c/treservedcidentsasfields.nim similarity index 96% rename from tests/misc/treservedcidentsasfields.nim rename to tests/c/treservedcidentsasfields.nim index a9a9546517..6cdf9e8552 100644 --- a/tests/misc/treservedcidentsasfields.nim +++ b/tests/c/treservedcidentsasfields.nim @@ -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 diff --git a/tests/actiontable/tactiontable.nim b/tests/collections/tactiontable.nim similarity index 100% rename from tests/actiontable/tactiontable.nim rename to tests/collections/tactiontable.nim diff --git a/tests/config.nims b/tests/config.nims index 3772648e61..842459c3a8 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -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") diff --git a/tests/constr/a.nim b/tests/constructors/a.nim similarity index 100% rename from tests/constr/a.nim rename to tests/constructors/a.nim diff --git a/tests/constr/b.nim b/tests/constructors/b.nim similarity index 100% rename from tests/constr/b.nim rename to tests/constructors/b.nim diff --git a/tests/constr/t18990.nim b/tests/constructors/t18990.nim similarity index 100% rename from tests/constr/t18990.nim rename to tests/constructors/t18990.nim diff --git a/tests/constr/tconstr1.nim b/tests/constructors/tconstr1.nim similarity index 100% rename from tests/constr/tconstr1.nim rename to tests/constructors/tconstr1.nim diff --git a/tests/constr/tconstr2.nim b/tests/constructors/tconstr2.nim similarity index 100% rename from tests/constr/tconstr2.nim rename to tests/constructors/tconstr2.nim diff --git a/tests/deprecated/tannot.nim b/tests/deprecated/tannot.nim deleted file mode 100644 index d14f6cc235..0000000000 --- a/tests/deprecated/tannot.nim +++ /dev/null @@ -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 diff --git a/tests/deprecated/tconst.nim b/tests/deprecated/tconst.nim deleted file mode 100644 index 51eb6cb0ec..0000000000 --- a/tests/deprecated/tconst.nim +++ /dev/null @@ -1,8 +0,0 @@ -discard """ - nimout: ''' -tconst.nim(8, 9) Warning: abcd; foo is deprecated [Deprecated] -''' -""" - -const foo* {.deprecated: "abcd".} = 42 -discard foo diff --git a/tests/deprecated/tmessages.nim b/tests/deprecated/tmessages.nim deleted file mode 100644 index 5884e396d5..0000000000 --- a/tests/deprecated/tmessages.nim +++ /dev/null @@ -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) diff --git a/tests/deprecated/tmodule1.nim b/tests/deprecated/tmodule1.nim deleted file mode 100644 index f26e4ce3fd..0000000000 --- a/tests/deprecated/tmodule1.nim +++ /dev/null @@ -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() diff --git a/tests/borrow/tborrow.nim b/tests/distinct/tborrow.nim similarity index 100% rename from tests/borrow/tborrow.nim rename to tests/distinct/tborrow.nim diff --git a/tests/borrow/tinvalidborrow.nim b/tests/distinct/tinvalidborrow.nim similarity index 100% rename from tests/borrow/tinvalidborrow.nim rename to tests/distinct/tinvalidborrow.nim diff --git a/tests/borrow/typeclassborrow.nim b/tests/distinct/typeclassborrow.nim similarity index 100% rename from tests/borrow/typeclassborrow.nim rename to tests/distinct/typeclassborrow.nim diff --git a/tests/effects/toutparam.nim b/tests/effects/toutparam.nim deleted file mode 100644 index 1126aa77e7..0000000000 --- a/tests/effects/toutparam.nim +++ /dev/null @@ -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() diff --git a/tests/clearmsg/mb.nim b/tests/errmsgs/mb.nim similarity index 100% rename from tests/clearmsg/mb.nim rename to tests/errmsgs/mb.nim diff --git a/tests/clearmsg/mc.nim b/tests/errmsgs/mc.nim similarity index 100% rename from tests/clearmsg/mc.nim rename to tests/errmsgs/mc.nim diff --git a/tests/clearmsg/ta.nim b/tests/errmsgs/ta.nim similarity index 100% rename from tests/clearmsg/ta.nim rename to tests/errmsgs/ta.nim diff --git a/tests/clearmsg/tconsttypemismatch.nim b/tests/errmsgs/tconsttypemismatch.nim similarity index 100% rename from tests/clearmsg/tconsttypemismatch.nim rename to tests/errmsgs/tconsttypemismatch.nim diff --git a/tests/clearmsg/tmacroerrorproc.nim b/tests/errmsgs/tmacroerrorproc.nim similarity index 100% rename from tests/clearmsg/tmacroerrorproc.nim rename to tests/errmsgs/tmacroerrorproc.nim diff --git a/tests/misc/tnoop.nim b/tests/errmsgs/tnoop.nim similarity index 100% rename from tests/misc/tnoop.nim rename to tests/errmsgs/tnoop.nim diff --git a/tests/misc/tsimtych.nim b/tests/errmsgs/tsimpletypecheck.nim similarity index 83% rename from tests/misc/tsimtych.nim rename to tests/errmsgs/tsimpletypecheck.nim index 74a6ad4c07..422437d3a1 100644 --- a/tests/misc/tsimtych.nim +++ b/tests/errmsgs/tsimpletypecheck.nim @@ -1,6 +1,6 @@ discard """ errormsg: "type mismatch: got but expected \'string\'" - file: "tsimtych.nim" + file: "tsimpletypecheck.nim" line: 10 """ # Test 2 diff --git a/tests/friends/mfriends.nim b/tests/generics/mfriends.nim similarity index 100% rename from tests/friends/mfriends.nim rename to tests/generics/mfriends.nim diff --git a/tests/constraints/tconstraints.nim b/tests/generics/tconstraints.nim similarity index 100% rename from tests/constraints/tconstraints.nim rename to tests/generics/tconstraints.nim diff --git a/tests/friends/tfriends.nim b/tests/generics/tfriends.nim similarity index 100% rename from tests/friends/tfriends.nim rename to tests/generics/tfriends.nim diff --git a/tests/generics/toverloading_typedesc.nim b/tests/generics/toverloading_typedesc.nim index 5ab7008281..4d748bfeeb 100644 --- a/tests/generics/toverloading_typedesc.nim +++ b/tests/generics/toverloading_typedesc.nim @@ -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 diff --git a/tests/constr/a_module.nim b/tests/global/a_module.nim similarity index 100% rename from tests/constr/a_module.nim rename to tests/global/a_module.nim diff --git a/tests/constr/tglobal.nim b/tests/global/tglobal2.nim similarity index 100% rename from tests/constr/tglobal.nim rename to tests/global/tglobal2.nim diff --git a/tests/init/tinitchecks_v2.nim b/tests/init/tinitchecks_v2.nim index 4a8cda0288..f7716bcca4 100644 --- a/tests/init/tinitchecks_v2.nim +++ b/tests/init/tinitchecks_v2.nim @@ -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() diff --git a/tests/misc/tproveinit.nim b/tests/init/tproveinit.nim similarity index 100% rename from tests/misc/tproveinit.nim rename to tests/init/tproveinit.nim diff --git a/tests/arithm/t1.nim b/tests/int/t1.nim similarity index 100% rename from tests/arithm/t1.nim rename to tests/int/t1.nim diff --git a/tests/arithm/tarithm.nim b/tests/int/tarithm.nim similarity index 100% rename from tests/arithm/tarithm.nim rename to tests/int/tarithm.nim diff --git a/tests/arithm/tashr.nim b/tests/int/tashr.nim similarity index 100% rename from tests/arithm/tashr.nim rename to tests/int/tashr.nim diff --git a/tests/arithm/tdiv.nim b/tests/int/tdiv.nim similarity index 100% rename from tests/arithm/tdiv.nim rename to tests/int/tdiv.nim diff --git a/tests/misc/tints.nim b/tests/int/tints.nim similarity index 100% rename from tests/misc/tints.nim rename to tests/int/tints.nim diff --git a/tests/misc/tunsigned64mod.nim b/tests/int/tunsigned64mod.nim similarity index 100% rename from tests/misc/tunsigned64mod.nim rename to tests/int/tunsigned64mod.nim diff --git a/tests/misc/tunsignedcmp.nim b/tests/int/tunsignedcmp.nim similarity index 100% rename from tests/misc/tunsignedcmp.nim rename to tests/int/tunsignedcmp.nim diff --git a/tests/misc/tunsignedcomp.nim b/tests/int/tunsignedcomp.nim similarity index 100% rename from tests/misc/tunsignedcomp.nim rename to tests/int/tunsignedcomp.nim diff --git a/tests/misc/tunsignedconv.nim b/tests/int/tunsignedconv.nim similarity index 100% rename from tests/misc/tunsignedconv.nim rename to tests/int/tunsignedconv.nim diff --git a/tests/misc/tunsignedinc.nim b/tests/int/tunsignedinc.nim similarity index 100% rename from tests/misc/tunsignedinc.nim rename to tests/int/tunsignedinc.nim diff --git a/tests/misc/tunsignedmisc.nim b/tests/int/tunsignedmisc.nim similarity index 100% rename from tests/misc/tunsignedmisc.nim rename to tests/int/tunsignedmisc.nim diff --git a/tests/misc/trawstr.nim b/tests/lexer/trawstr.nim similarity index 100% rename from tests/misc/trawstr.nim rename to tests/lexer/trawstr.nim diff --git a/tests/ambsym/mambsym1.nim b/tests/lookups/mambsym1.nim similarity index 100% rename from tests/ambsym/mambsym1.nim rename to tests/lookups/mambsym1.nim diff --git a/tests/ambsym/mambsym2.nim b/tests/lookups/mambsym2.nim similarity index 100% rename from tests/ambsym/mambsym2.nim rename to tests/lookups/mambsym2.nim diff --git a/tests/ambsym/mambsys1.nim b/tests/lookups/mambsys1.nim similarity index 100% rename from tests/ambsym/mambsys1.nim rename to tests/lookups/mambsys1.nim diff --git a/tests/ambsym/mambsys2.nim b/tests/lookups/mambsys2.nim similarity index 100% rename from tests/ambsym/mambsys2.nim rename to tests/lookups/mambsys2.nim diff --git a/tests/bind/mbind3.nim b/tests/lookups/mbind3.nim similarity index 100% rename from tests/bind/mbind3.nim rename to tests/lookups/mbind3.nim diff --git a/tests/ambsym/tambprocvar.nim b/tests/lookups/tambprocvar.nim similarity index 100% rename from tests/ambsym/tambprocvar.nim rename to tests/lookups/tambprocvar.nim diff --git a/tests/ambsym/tambsym.nim b/tests/lookups/tambsym.nim similarity index 100% rename from tests/ambsym/tambsym.nim rename to tests/lookups/tambsym.nim diff --git a/tests/ambsym/tambsym2.nim b/tests/lookups/tambsym2.nim similarity index 100% rename from tests/ambsym/tambsym2.nim rename to tests/lookups/tambsym2.nim diff --git a/tests/ambsym/tambsym3.nim b/tests/lookups/tambsym3.nim similarity index 100% rename from tests/ambsym/tambsym3.nim rename to tests/lookups/tambsym3.nim diff --git a/tests/ambsym/tambsys.nim b/tests/lookups/tambsys.nim similarity index 100% rename from tests/ambsym/tambsys.nim rename to tests/lookups/tambsys.nim diff --git a/tests/bind/tbind.nim b/tests/lookups/tbind.nim similarity index 100% rename from tests/bind/tbind.nim rename to tests/lookups/tbind.nim diff --git a/tests/gensym/tgensym.nim b/tests/lookups/tgensym.nim similarity index 100% rename from tests/gensym/tgensym.nim rename to tests/lookups/tgensym.nim diff --git a/tests/gensym/tgensymgeneric.nim b/tests/lookups/tgensymgeneric.nim similarity index 100% rename from tests/gensym/tgensymgeneric.nim rename to tests/lookups/tgensymgeneric.nim diff --git a/tests/bind/tinvalidbindtypedesc.nim b/tests/lookups/tinvalidbindtypedesc.nim similarity index 100% rename from tests/bind/tinvalidbindtypedesc.nim rename to tests/lookups/tinvalidbindtypedesc.nim diff --git a/tests/bind/tnicerrorforsymchoice.nim b/tests/lookups/tnicerrorforsymchoice.nim similarity index 100% rename from tests/bind/tnicerrorforsymchoice.nim rename to tests/lookups/tnicerrorforsymchoice.nim diff --git a/tests/bind/told_bind_expr.nim b/tests/lookups/told_bind_expr.nim similarity index 100% rename from tests/bind/told_bind_expr.nim rename to tests/lookups/told_bind_expr.nim diff --git a/tests/misc/tgenconstraints.nim b/tests/misc/tgenconstraints.nim deleted file mode 100644 index 829da5173b..0000000000 --- a/tests/misc/tgenconstraints.nim +++ /dev/null @@ -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 diff --git a/tests/misc/trunner.nim b/tests/misc/trunner.nim index 0fc7dcdfd7..626b1a8863 100644 --- a/tests/misc/trunner.nim +++ b/tests/misc/trunner.nim @@ -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] diff --git a/tests/misc/tstrtabs.nim b/tests/misc/tstrtabs.nim deleted file mode 100644 index 2f7eda9f7a..0000000000 --- a/tests/misc/tstrtabs.nim +++ /dev/null @@ -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() diff --git a/tests/deprecated/importme.nim b/tests/msgs/mdeprecated3.nim similarity index 100% rename from tests/deprecated/importme.nim rename to tests/msgs/mdeprecated3.nim diff --git a/tests/misc/mspellsuggest.nim b/tests/msgs/mspellsuggest.nim similarity index 100% rename from tests/misc/mspellsuggest.nim rename to tests/msgs/mspellsuggest.nim diff --git a/tests/pragmas/mused2a.nim b/tests/msgs/mused2a.nim similarity index 100% rename from tests/pragmas/mused2a.nim rename to tests/msgs/mused2a.nim diff --git a/tests/pragmas/mused2b.nim b/tests/msgs/mused2b.nim similarity index 100% rename from tests/pragmas/mused2b.nim rename to tests/msgs/mused2b.nim diff --git a/tests/pragmas/mused2c.nim b/tests/msgs/mused2c.nim similarity index 100% rename from tests/pragmas/mused2c.nim rename to tests/msgs/mused2c.nim diff --git a/tests/pragmas/mused3.nim b/tests/msgs/mused3.nim similarity index 100% rename from tests/pragmas/mused3.nim rename to tests/msgs/mused3.nim diff --git a/tests/pragmas/mused3a.nim b/tests/msgs/mused3a.nim similarity index 100% rename from tests/pragmas/mused3a.nim rename to tests/msgs/mused3a.nim diff --git a/tests/pragmas/mused3b.nim b/tests/msgs/mused3b.nim similarity index 100% rename from tests/pragmas/mused3b.nim rename to tests/msgs/mused3b.nim diff --git a/tests/msgs/tdeprecated1.nim b/tests/msgs/tdeprecated1.nim new file mode 100644 index 0000000000..f4e85da0b0 --- /dev/null +++ b/tests/msgs/tdeprecated1.nim @@ -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]]# diff --git a/tests/deprecated/tdeprecated.nim b/tests/msgs/tdeprecated2.nim similarity index 60% rename from tests/deprecated/tdeprecated.nim rename to tests/msgs/tdeprecated2.nim index 51c0dc14b6..71d20081e5 100644 --- a/tests/deprecated/tdeprecated.nim +++ b/tests/msgs/tdeprecated2.nim @@ -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 ''' """ diff --git a/tests/msgs/tdeprecated3.nim b/tests/msgs/tdeprecated3.nim new file mode 100644 index 0000000000..0c1b7deffe --- /dev/null +++ b/tests/msgs/tdeprecated3.nim @@ -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() diff --git a/tests/deprecated/tequalhook.nim b/tests/msgs/tdeprecatedequalhook.nim similarity index 100% rename from tests/deprecated/tequalhook.nim rename to tests/msgs/tdeprecatedequalhook.nim diff --git a/tests/compilerfeatures/texpandmacro.nim b/tests/msgs/texpandmacro.nim similarity index 100% rename from tests/compilerfeatures/texpandmacro.nim rename to tests/msgs/texpandmacro.nim diff --git a/tests/misc/thints_off.nim b/tests/msgs/thints_off.nim similarity index 100% rename from tests/misc/thints_off.nim rename to tests/msgs/thints_off.nim diff --git a/tests/misc/tspellsuggest.nim b/tests/msgs/tspellsuggest.nim similarity index 100% rename from tests/misc/tspellsuggest.nim rename to tests/msgs/tspellsuggest.nim diff --git a/tests/misc/tspellsuggest2.nim b/tests/msgs/tspellsuggest2.nim similarity index 100% rename from tests/misc/tspellsuggest2.nim rename to tests/msgs/tspellsuggest2.nim diff --git a/tests/misc/tspellsuggest3.nim b/tests/msgs/tspellsuggest3.nim similarity index 100% rename from tests/misc/tspellsuggest3.nim rename to tests/msgs/tspellsuggest3.nim diff --git a/tests/pragmas/tused2.nim b/tests/msgs/tused2.nim similarity index 100% rename from tests/pragmas/tused2.nim rename to tests/msgs/tused2.nim diff --git a/tests/misc/twarningaserror.nim b/tests/msgs/twarningaserror.nim similarity index 100% rename from tests/misc/twarningaserror.nim rename to tests/msgs/twarningaserror.nim diff --git a/tests/newconfig/tfoo.nims b/tests/newconfig/tfoo.nims index 0cb9502271..f22caaacda 100644 --- a/tests/newconfig/tfoo.nims +++ b/tests/newconfig/tfoo.nims @@ -6,7 +6,7 @@ exec "gcc -v" --define:release --forceBuild ---path: "../friends" +--path: "../generics" warning("uninit", off) diff --git a/tests/misc/trangechecks.nim b/tests/overflow/trangechecks.nim similarity index 100% rename from tests/misc/trangechecks.nim rename to tests/overflow/trangechecks.nim diff --git a/tests/misc/trfc_341.nim b/tests/parser/tdotlikeoperators.nim similarity index 93% rename from tests/misc/trfc_341.nim rename to tests/parser/tdotlikeoperators.nim index 37cf675c6d..c2d23bd151 100644 --- a/tests/misc/trfc_341.nim +++ b/tests/parser/tdotlikeoperators.nim @@ -1,3 +1,6 @@ +discard """ + matrix: "-d:nimPreviewDotLikeOps" +""" # test for https://github.com/nim-lang/RFCs/issues/341 import std/json import std/jsonutils diff --git a/tests/defaultprocparam/mdefaultprocparam.nim b/tests/proc/mdefaultprocparam.nim similarity index 100% rename from tests/defaultprocparam/mdefaultprocparam.nim rename to tests/proc/mdefaultprocparam.nim diff --git a/tests/misc/tcolonisproc.nim b/tests/proc/tcolonisproc.nim similarity index 100% rename from tests/misc/tcolonisproc.nim rename to tests/proc/tcolonisproc.nim diff --git a/tests/defaultprocparam/tdefaultprocparam.nim b/tests/proc/tdefaultprocparam.nim similarity index 100% rename from tests/defaultprocparam/tdefaultprocparam.nim rename to tests/proc/tdefaultprocparam.nim diff --git a/tests/misc/tlambdadonotation.nim b/tests/proc/tlambdadonotation.nim similarity index 100% rename from tests/misc/tlambdadonotation.nim rename to tests/proc/tlambdadonotation.nim diff --git a/tests/namedparams/tnamedparams.nim b/tests/proc/tnamedparams.nim similarity index 100% rename from tests/namedparams/tnamedparams.nim rename to tests/proc/tnamedparams.nim diff --git a/tests/namedparams/tnamedparams2.nim b/tests/proc/tnamedparams2.nim similarity index 100% rename from tests/namedparams/tnamedparams2.nim rename to tests/proc/tnamedparams2.nim diff --git a/tests/namedparams/tnamedparams3.nim b/tests/proc/tnamedparams3.nim similarity index 100% rename from tests/namedparams/tnamedparams3.nim rename to tests/proc/tnamedparams3.nim diff --git a/tests/misc/tparamsindefault.nim b/tests/proc/tparamsindefault.nim similarity index 100% rename from tests/misc/tparamsindefault.nim rename to tests/proc/tparamsindefault.nim diff --git a/tests/procvar/tprocvar.nim b/tests/proc/tprocvar.nim similarity index 100% rename from tests/procvar/tprocvar.nim rename to tests/proc/tprocvar.nim diff --git a/tests/procvar/tprocvarmismatch.nim b/tests/proc/tprocvarmismatch.nim similarity index 100% rename from tests/procvar/tprocvarmismatch.nim rename to tests/proc/tprocvarmismatch.nim diff --git a/tests/misc/tnewsets.nim b/tests/sets/tnewsets.nim similarity index 100% rename from tests/misc/tnewsets.nim rename to tests/sets/tnewsets.nim diff --git a/tests/slice/tdistinct.nim b/tests/slice/tdistinct.nim deleted file mode 100644 index d99b529a72..0000000000 --- a/tests/slice/tdistinct.nim +++ /dev/null @@ -1,2 +0,0 @@ -type Foo = distinct uint64 -const slice = 0 ..< 42.Foo diff --git a/tests/distros/tdistros_detect.nim b/tests/stdlib/tdistros_detect.nim similarity index 87% rename from tests/distros/tdistros_detect.nim rename to tests/stdlib/tdistros_detect.nim index 9639cfeb9e..1176c89934 100644 --- a/tests/distros/tdistros_detect.nim +++ b/tests/stdlib/tdistros_detect.nim @@ -1,9 +1,4 @@ -import distros - -discard """ - exitcode: 0 - output: "" -""" +import std/[assertions, distros] when defined(windows): doAssert detectOs(Windows) == true diff --git a/tests/stdlib/tquit.nim b/tests/stdlib/tquit.nim deleted file mode 100644 index 12385e57b0..0000000000 --- a/tests/stdlib/tquit.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ -disabled: true -output: ''' -just exiting... -''' -joinable: false -""" - -# Test `addQuitProc` (now deprecated by `addExitProc`) - -import std/syncio - -proc myExit() {.noconv.} = - write(stdout, "just exiting...\n") - -{.push warning[deprecated]: off.} -addQuitProc(myExit) -{.pop.} diff --git a/tests/rational/trat_float.nim b/tests/stdlib/trat_float.nim similarity index 100% rename from tests/rational/trat_float.nim rename to tests/stdlib/trat_float.nim diff --git a/tests/rational/trat_init.nim b/tests/stdlib/trat_init.nim similarity index 100% rename from tests/rational/trat_init.nim rename to tests/stdlib/trat_init.nim diff --git a/tests/misc/treadln.nim b/tests/stdlib/treadln.nim similarity index 87% rename from tests/misc/treadln.nim rename to tests/stdlib/treadln.nim index b716c47110..4a070e848e 100644 --- a/tests/misc/treadln.nim +++ b/tests/stdlib/treadln.nim @@ -6,6 +6,8 @@ Macintosh, Unix or Windows text format. ''' """ +import std/syncio + # test the improved readline handling that does not care whether its # Macintosh, Unix or Windows text format. @@ -13,7 +15,7 @@ var inp: File line: string -if open(inp, "tests/misc/treadln.nim"): +if open(inp, "tests/stdlib/treadln.nim"): while not endOfFile(inp): line = readLine(inp) if line.len >= 2 and line[0] == '#' and line[1] == ' ': diff --git a/tests/stdlib/tstrtabs2.nim b/tests/stdlib/tstrtabs2.nim index aeef28d655..a4030ec777 100644 --- a/tests/stdlib/tstrtabs2.nim +++ b/tests/stdlib/tstrtabs2.nim @@ -15,3 +15,18 @@ block: doAssert t["name"] == "John" m() + +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() diff --git a/tests/magics/t10307.nim b/tests/system/t10307.nim similarity index 100% rename from tests/magics/t10307.nim rename to tests/system/t10307.nim diff --git a/tests/magics/t20938.nim b/tests/system/t20938.nim similarity index 100% rename from tests/magics/t20938.nim rename to tests/system/t20938.nim diff --git a/tests/concat/tconcat.nim b/tests/system/tconcat.nim similarity index 100% rename from tests/concat/tconcat.nim rename to tests/system/tconcat.nim diff --git a/tests/misc/temptyecho.nim b/tests/system/temptyecho.nim similarity index 100% rename from tests/misc/temptyecho.nim rename to tests/system/temptyecho.nim diff --git a/tests/fields/tfielditerator.nim b/tests/system/tfielditerator.nim similarity index 100% rename from tests/fields/tfielditerator.nim rename to tests/system/tfielditerator.nim diff --git a/tests/fields/tfields.nim b/tests/system/tfields.nim similarity index 100% rename from tests/fields/tfields.nim rename to tests/system/tfields.nim diff --git a/tests/misc/tgcregions.nim b/tests/system/tgcregions.nim similarity index 100% rename from tests/misc/tgcregions.nim rename to tests/system/tgcregions.nim diff --git a/tests/misc/tinc.nim b/tests/system/timmutableinc.nim similarity index 75% rename from tests/misc/tinc.nim rename to tests/system/timmutableinc.nim index 91f6223e23..e857800b3a 100644 --- a/tests/misc/tinc.nim +++ b/tests/system/timmutableinc.nim @@ -1,6 +1,6 @@ discard """ errormsg: "type mismatch: got " - file: "tinc.nim" + file: "timmutableinc.nim" line: 8 """ var x = 0 diff --git a/tests/misc/tnot.nim b/tests/system/tinvalidnot.nim similarity index 92% rename from tests/misc/tnot.nim rename to tests/system/tinvalidnot.nim index a3669705bf..df0291a8ae 100644 --- a/tests/misc/tnot.nim +++ b/tests/system/tinvalidnot.nim @@ -1,6 +1,6 @@ discard """ errormsg: "type mismatch" - file: "tnot.nim" + file: "tinvalidnot.nim" line: 14 """ # BUG: following compiles, but should not: diff --git a/tests/misc/tlocals.nim b/tests/system/tlocals.nim similarity index 100% rename from tests/misc/tlocals.nim rename to tests/system/tlocals.nim diff --git a/tests/misc/tlowhigh.nim b/tests/system/tlowhigh.nim similarity index 100% rename from tests/misc/tlowhigh.nim rename to tests/system/tlowhigh.nim diff --git a/tests/magics/tmagics.nim b/tests/system/tmagics.nim similarity index 100% rename from tests/magics/tmagics.nim rename to tests/system/tmagics.nim diff --git a/tests/stdlib/tmemory.nim b/tests/system/tmemory.nim similarity index 100% rename from tests/stdlib/tmemory.nim rename to tests/system/tmemory.nim diff --git a/tests/misc/tnew.nim b/tests/system/tnew.nim similarity index 87% rename from tests/misc/tnew.nim rename to tests/system/tnew.nim index 41ef3fa195..c28c1187fa 100644 --- a/tests/misc/tnew.nim +++ b/tests/system/tnew.nim @@ -1,5 +1,5 @@ discard """ -matrix: "--mm:refc" +matrix: "--mm:refc; --mm:orc" outputsub: ''' Simple tree node allocation worked! Simple cycle allocation worked! @@ -11,7 +11,6 @@ joinable: false # and the code generation for gc walkers # (and the garbage collector): -## todo fixme it doesn't work for ORC type PNode = ref TNode TNode = object @@ -26,7 +25,10 @@ proc finalizer(n: PNode) = write(stdout, " is now freed\n") proc newNode(data: int, le, ri: PNode): PNode = - new(result, finalizer) + when defined(gcDestructors): # using finalizer breaks the test for orc + new(result) + else: + new(result, finalizer) result.le = le result.ri = ri result.data = data diff --git a/tests/misc/tnewderef.nim b/tests/system/tnewderef.nim similarity index 100% rename from tests/misc/tnewderef.nim rename to tests/system/tnewderef.nim diff --git a/tests/misc/tslices.nim b/tests/system/tslices.nim similarity index 81% rename from tests/misc/tslices.nim rename to tests/system/tslices.nim index 987b50de14..d0c68f8cb7 100644 --- a/tests/misc/tslices.nim +++ b/tests/system/tslices.nim @@ -57,3 +57,9 @@ echo mystr var s = "abcdef" s[1 .. ^2] = "xyz" assert s == "axyzf" + +# issue mentioned in PR #19219 +type Foo = distinct uint64 +# < here calls `pred` which used to cause a codegen error +# `pred` compiles because distinct ordinals are considered ordinal +const slice = 0 ..< 42.Foo diff --git a/tests/misc/tidentconcatenations.nim b/tests/template/tidentconcatenations.nim similarity index 100% rename from tests/misc/tidentconcatenations.nim rename to tests/template/tidentconcatenations.nim diff --git a/tests/template/twrongmapit.nim b/tests/template/twrongmapit.nim index 13f53d1192..2d53d03f5e 100644 --- a/tests/template/twrongmapit.nim +++ b/tests/template/twrongmapit.nim @@ -1,9 +1,6 @@ discard """ - disabled: true - output: "####" + joinable: false """ -# unfortunately our tester doesn't support multiple lines of compiler -# error messages yet... # bug #1562 type Foo* {.pure, final.} = object @@ -30,4 +27,4 @@ import sequtils (var i = @[""];i).applyIt(it) # now works: -echo "##", i[0], "##" +doAssert i[0] == "" diff --git a/tests/types/tisop.nim b/tests/types/tisop.nim deleted file mode 100644 index 5f9cba0d8c..0000000000 --- a/tests/types/tisop.nim +++ /dev/null @@ -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) - diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim index 67f1ce0c1e..64b3d03c00 100644 --- a/tests/types/tisopr.nim +++ b/tests/types/tisopr.nim @@ -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) diff --git a/tests/cnstseq/tcnstseq.nim b/tests/vm/tcnstseq.nim similarity index 100% rename from tests/cnstseq/tcnstseq.nim rename to tests/vm/tcnstseq.nim diff --git a/tests/constr/tconexpr.nim b/tests/vm/tfibconst.nim similarity index 100% rename from tests/constr/tconexpr.nim rename to tests/vm/tfibconst.nim diff --git a/tests/constr/tnocompiletimefunc.nim b/tests/vm/tnocompiletimefunc.nim similarity index 100% rename from tests/constr/tnocompiletimefunc.nim rename to tests/vm/tnocompiletimefunc.nim diff --git a/tests/constr/tnocompiletimefunclambda.nim b/tests/vm/tnocompiletimefunclambda.nim similarity index 100% rename from tests/constr/tnocompiletimefunclambda.nim rename to tests/vm/tnocompiletimefunclambda.nim