Nim/tests
Ivan Bobev ccd77b42af
Add some enhancements to jsonutils.nim (#15133)
* Add some enhancements to `jsonutils.nim`

* Use `jsonutils.nim` hookable API to add a possibility to deserialize
  JSON arrays directly to `HashSet` and `OrderedSet` types and
  respectively to serialize those types to JSON arrays.

* Also add a possibility to deserialize JSON `null` objects to Nim
  option objects and respectively to serialize Nim option object to JSON
  object if some or to JSON `null` object if none.

* Move serialization/deserialization functionality for `Table` and
  `OrderedTable` types from `jsonutils.nim` to `tables.nim` via the
  hookable API.

* Add object `jsonutils.Joptions` and parameter from its type to
  `jsonutils.fromJson` procedure to control whether to allow
  deserializing JSON objects to Nim objects when the JSON has some
  extra or missing keys.

* Add unit tests for the added functionalities to `tjsonutils.nim`.

* improve fromJsonFields

* Add changelog entry for the jsonutils enhancements

* Add TODO in `jsonutils.nim`

* Added an entry to "Future directions" section in `jsonutils.nim` as
  suggestion for future support of serialization and de-serialization of
  nested variant objects.

* Added currently disabled test case in `tjsonutils.nim` for testing
  serialization and de-serialization of nested variant objects.

* Move JSON hooks to `jsonutils.nim`

Move `fromJsonHook` and `toJsonHook` procedures for different types to
`jsonutils.nim` module to avoid a dependency of collections modules to
the `json.nim` module.

The hooks are removed from the following modules:

  * `tables.nim`

  * `sets.nim`

  * `options.nim`

  * `strtabs.nim`

* Add some tests about `StringTableRef`

Add tests for `StringTableRef`'s `fromJsonHook` and `toJsonHook` to
`tjsonutils.nim`.

* Disable a warning in `jsonutils.nim`

Mark `fun` template in `jsonutils` module with `{.used.}` pragma in
order to disable `[XDeclaredButNotUsed]` hint. The template is actually
used by the `initCaseObject` macro in the same module.

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
2020-09-09 14:18:59 +02:00
..
actiontable Merge tests into a larger file (part 1 of ∞) (#9318) 2018-10-12 17:02:46 +02:00
alias Remove expr/stmt (#5857) 2017-07-25 09:28:23 +02:00
align fixes #13122 (#13126) 2020-01-13 14:11:51 +01:00
ambsym require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
arc fix #15238 (#15262) 2020-09-04 10:26:14 +02:00
arithm fix operators containing percent for VM usage (#13536) 2020-03-11 01:01:25 +01:00
array disallow typedesc in arrays & move existing checks to types.typeAllowedAux (#13261) 2020-05-29 11:48:15 +02:00
assert init checks and 'out' parameters (#14521) 2020-06-23 10:53:57 +02:00
assign fix rtti sizeof for varargs in global scope (#13125) [backport] 2020-01-13 10:17:21 +01:00
astoverload
astspec Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
async fix #15148 (#15149) 2020-08-08 07:24:54 +02:00
bind Add testcases for #11811 and #14315 (#14726) 2020-06-19 14:56:38 +02:00
borrow Add testcase for #14440 (#14771) 2020-06-23 14:17:12 +02:00
casestmt An optimizer for ARC (#14962) 2020-07-15 23:00:06 +02:00
ccgbugs borrow checking (#15282) 2020-09-09 07:32:03 +02:00
ccgbugs2 Remove deprecated stuff from stdlib (#14699) 2020-06-17 15:25:02 +02:00
clearmsg require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
closure Use typeflag instead 2020-08-10 12:57:32 +02:00
cnstseq require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
collections remove a condition that table size must be passed as power of 2 (#14926) 2020-07-08 15:01:47 +02:00
compilepragma fixes #10299 (#11324) 2019-05-25 07:33:33 +02:00
compiler trunner was not actually being tested in non-CTFFI mode; minor testament cleanups (#14377) 2020-05-19 09:41:31 +02:00
compilerapi nimeval errorHook support (#15255) 2020-09-07 20:05:07 +02:00
compilerfeatures new compiler feature: --expandMacro 2019-05-29 20:47:28 +02:00
compiles delete list comprehension (#12392) 2019-11-22 19:57:43 +01:00
concat
concepts fix assignment to converted concept type (#15051) 2020-07-24 21:19:11 +02:00
constr Add testcase for #10465 (#14943) 2020-07-09 01:51:18 +02:00
constraints require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
constructors Turn some of the errors back into warnings 2020-04-01 19:38:44 +02:00
controlflow Make unreachable code a warning instead of an error (#14816) 2020-06-29 08:49:53 +02:00
converter addQuitProc now works with closures, and c, js(node/browser) backend; fix some bugs in testament (#14342) 2020-06-16 11:43:48 +02:00
coroutines Close#5586 (#14682) 2020-06-16 16:24:26 +02:00
cpp fix typos and deprecation warnings for tconvariancerules.nim (#13772) 2020-03-27 08:36:21 +01:00
defaultprocparam Expand hoisted default params in sem (#15270) 2020-09-05 22:01:47 +02:00
deprecated fix #11009 (#14935) 2020-07-09 09:57:35 +02:00
deps Remove deprecated stuff from stdlib (#14699) 2020-06-17 15:25:02 +02:00
destructor disable sink inference, only enable it for the stdlib. Reason: better source code compatibility (#15105) 2020-07-28 19:18:46 +02:00
dir with space fixes #10042 (allow spaces in import) (#10504) 2019-01-31 08:20:00 +01:00
discard improve the 'has to be discarded' error message 2020-05-02 22:31:19 +02:00
distinct fixes #11715 (#11721) 2019-07-13 07:55:56 +02:00
distros fix tdistros test which was failing on Nightlies 2020-04-28 15:59:32 +02:00
dll CI openbsd: 3x batching via NIM_TESTAMENT_BATCH ; overall CI finishes in 21m instead of 34m (#14851) 2020-06-30 14:21:30 +02:00
effects strict funcs: use control flow information for a more precise analysis (#15271) 2020-09-06 22:01:39 +02:00
enum fix enumtostr crash for enum-range (#13035) 2020-01-05 09:18:14 +01:00
errmsgs fix #6608 (#14963) 2020-07-14 09:22:48 +02:00
exception fix #10343 (#14789) 2020-06-24 18:00:35 +02:00
exprs update tests that tested for the 'discard' error messages 2020-05-02 22:31:19 +02:00
fields make tests green again 2019-05-27 21:29:02 +02:00
flags require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
float Error -> Defect for defects (#13908) 2020-04-28 19:56:01 +02:00
fragmentation tests: disable flaky tests for now; closes #9421 2018-10-18 12:12:15 +02:00
friends
gc gc_regions: cleanup & fixes for deallocation (#11920) 2020-08-17 20:20:48 +02:00
generics An optimizer for ARC (#14962) 2020-07-15 23:00:06 +02:00
gensym fixes yet another gensym regression (#12145) 2019-09-06 00:45:00 +02:00
global require errormsg to be specified before file. 2018-12-11 21:23:21 +01:00
ic Incremental compilation (IC): Improvements (#11881) 2019-08-08 08:41:05 +02:00
implicit lots of small changes 2018-12-11 21:23:22 +01:00
import_in_config
init init checks and 'out' parameters (#14521) 2020-06-23 10:53:57 +02:00
isolate 'isolate' builtin; refs https://github.com/nim-lang/RFCs/issues/244 (#15011) 2020-07-20 07:50:19 +02:00
iter Add test-cases for #12576 and #12523 (#15085) 2020-07-27 13:01:50 +02:00
js avoid #8231, bitwise move to mul,div (#15070) 2020-08-25 09:58:32 +02:00
lent closes #14878 2020-07-08 12:22:55 +02:00
let Allow let to not have value when using importc (#14258) 2020-05-12 20:28:18 +02:00
lexer megatest: make it green on Linux 2018-12-11 21:23:25 +01:00
lookups implement the 'bind' statement for generics, it was an oversight that this was never implemented (#14584) 2020-06-07 09:55:56 +02:00
macros "for-loop macros" are no longer an experimental feature (#15288) 2020-09-08 14:25:25 +02:00
magics close #12746; minor cleanup (#14379) 2020-05-17 13:28:18 +02:00
manyloc remove a condition that table size must be passed as power of 2 (#14926) 2020-07-08 15:01:47 +02:00
metatype typetraits.$: $((int, float), int) is now "((int, float), int)" instead of "(tuple of (int, float), int)" (#14812) 2020-07-02 16:19:43 +02:00
method Error -> Defect for defects (#13908) 2020-04-28 19:56:01 +02:00
misc fixes #15210 [backport:1.2] (#15237) 2020-08-31 14:46:23 +02:00
modules Fix #11352 strutil.insertSep() fails on negative numbers (#15087) 2020-07-28 11:47:22 +02:00
namedparams fixes #12196 2019-09-16 12:12:44 +02:00
newconfig deprecate existsDir; use dirExists instead (#14884) 2020-07-03 23:04:23 +02:00
nimble tnimblepathdollarfail.nim -> tests/nimble/tnimblepathdollar_fault to reduce false positives when searching for fail in CI logs (#14450) 2020-05-25 13:54:30 -07:00
nimdoc fix bug in semgnrc: runnableExamples should not semcheck, even with > 1 arg (#14768) 2020-06-23 10:06:36 +02:00
niminaction Remove deprecated stuff from stdlib (#14699) 2020-06-17 15:25:02 +02:00
notnil Add tests for #8481, #6490 and #4061 (#14083) 2020-04-23 19:52:33 +02:00
objects fix #14698 nkRecWhen caused internalAssert in semConstructFields when generic type not mentioned in fields (#14709) 2020-07-27 22:32:21 +02:00
objvariant Better case coverage error message for alias and range enum (#12913) 2019-12-18 10:29:01 +01:00
openarray clean up deprecated stuff and unused imports in tests (#13059) 2020-01-07 09:49:08 +01:00
osproc testament: generic N-fold batching: windows CI 37mn=>16m (#14823) 2020-06-27 16:51:17 +02:00
overflw Error -> Defect for defects (#13908) 2020-04-28 19:56:01 +02:00
overload fix some issues overloading with generics and inheritance (#15211) 2020-08-27 12:56:38 +02:00
package_level_objects new feature: package level objects 2017-10-29 07:54:39 +01:00
parallel #12103 - CI for OpenBSD (#12105) 2020-04-21 15:05:21 +02:00
parser Better semiStmtList parsing (#15123) 2020-09-09 07:36:31 +02:00
pragmas Add test-cases for #12576 and #12523 (#15085) 2020-07-27 13:01:50 +02:00
proc allow typed/untyped in magic procs (#12911) 2019-12-17 11:07:32 +01:00
procvar Merge tests into a larger file (part 5 of ∞) (#9368) 2018-10-16 10:50:10 +02:00
range Error -> Defect for defects (#13908) 2020-04-28 19:56:01 +02:00
rational Error -> Defect for defects (#13908) 2020-04-28 19:56:01 +02:00
realtimeGC WIP, most tests are now skipped 2018-12-11 21:23:18 +01:00
sets tables/sharedtables/intsets/etc: fix #13496, #13504, #13505; add lots of tests (#13498) [backport] 2020-02-26 22:07:09 +01:00
showoff Clean up macros (#14959) 2020-07-14 16:44:56 +02:00
specialops dotops: add a simple object delegation test 2017-12-01 02:05:48 +01:00
statictypes Add testcase for #12571 (#14955) 2020-07-10 17:13:37 +02:00
stdlib Add some enhancements to jsonutils.nim (#15133) 2020-09-09 14:18:59 +02:00
system fix #14912, make --useVersion:1.0 work again (#14945) 2020-07-10 16:44:12 +02:00
template Fix #5691 (#15158) 2020-08-27 15:50:59 +02:00
testament misc testament cleanups (#14764) 2020-06-23 10:53:03 +02:00
testdata
threads faster CIs (#13803) 2020-03-30 13:18:12 +02:00
tools new feature: --staticBoundChecks:on to enforce static array index checking (#10965) 2020-03-18 14:25:10 +01:00
trmacros Reenable a few tests 2020-07-14 19:50:42 +02:00
tuples Fix #14911 (#14922) [backport] 2020-07-07 10:21:18 +02:00
typerel Reenable a few tests 2020-07-14 19:50:42 +02:00
types fix #14007 (#14012) [backport] 2020-04-18 16:15:17 +02:00
untestable Deprecate and/or remove ospaths (#14767) 2020-06-23 10:51:33 +02:00
usingstmt Clean up macros (#14959) 2020-07-14 16:44:56 +02:00
valgrind attempt to add valgrind support to the CIs and testament (#12646) 2019-11-18 09:10:48 +01:00
varres fix #13848: make var result work with nim cpp (#13959) 2020-04-13 14:16:06 +02:00
varstmt Testament: refactoring; makes the test joiner green 2018-12-11 21:23:23 +01:00
vm Remove deprecated stuff from stdlib (#14699) 2020-06-17 15:25:02 +02:00
ast_pattern_matching.nim add tastspec (and ast_pattern_matching) (#10863) 2019-03-19 11:45:29 +01:00
config.nims fix #14320 (tasyncawait.nim is recently very flaky) + avoid hardcoding service ports everywhere + flakyAssert (#14327) 2020-05-13 11:05:47 +02:00
dummy.txt Remove install.txt and readme.txt (#9521) 2018-10-28 13:36:52 +01:00
js.html
js.nim
m14634.nim fix #13166 tioselectors flaky test on freebsd+OSX (#14634) 2020-06-12 21:19:23 -07:00
mmaptest.nim Fix spellings (#12277) [backport] 2019-09-27 07:02:54 +02:00
readme.md Update link to parseSpec proc 2020-06-28 00:13:54 +02:00
rectest.nim
stckovfl.nim
test_nimscript.nims deprecate existsDir; use dirExists instead (#14884) 2020-07-03 23:04:23 +02:00

This directory contains the test cases.

Each test must have a filename of the form: t*.nim

Note: Testament is only aware of tests under a directory (eg tests/foo/) and will ignore top-level tests like tests/tbar.nim.

Specs

Each test can contain a spec in a discard """ ... """ block.

Check out the parseSpec procedure in the specs module for a full and reliable reference

action

Specifies what action this test should take.

Default: run

Options:

  • compile - compiles the module and fails the test if compilations fails.
  • run - compiles and runs the module, fails the test if compilation or execution of test code fails.
  • reject - compiles the module and fails the test if compilation succeeds.

There are certain spec keys that imply run, including output and outputsub.

cmd

Specifies the Nim command to use for compiling the test.

There are a number of variables that are replaced in this spec option:

  • $target - the compilation target, e.g. c.
  • $options - the options for the compiler.
  • $file - the filename of the test.
  • $filedir - the directory of the test file.

Example:

discard """
  cmd: "nim $target --nimblePath:./nimbleDir/simplePkgs $options $file"
"""

Categories

Each folder under this directory represents a test category, which can be tested by running koch tests pcat <category> (or cat to avoid parallel testing, which is slower).

The folder dll contains simple DLL tests.

The folder realtimeGC contains a test for validating that the realtime GC can run properly without linking against the nimrtl.dll/so. It includes a C client and platform specific build files for manual compilation.