Files
Nim/tests
c-blake 7ac1fc81fd Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ? (#10084)
* Resolve things raised in https://github.com/nim-lang/Nim/issues/10081 ?
CDF is a standard ident in all things related to random numbers/sampling,
and full words "cumulativeDistributionFunction" would be silly long, in
this case, IMO.  We use lowercase `cdf` to make it not look like a type,
remove all looping from `sample` letting callers do it.  Besides just
side-stepping any `sampleSize` name choice, callers may want to filter
out samples anyway which this makes slightly simpler.

Also add two variants of `cumsum`, value return and in-place update
distinguished by the var-ness of the first argument.  Add tests for
`int` and `float` for both `cumsum` and the new `sample`.  (The sample
tests exercise the value return mode of `cumsum`.)

Functionality pre-this-PR `sample(a, w)` is now the almost as simple
`for i in 0..<n: sample(a, w.cumsum)`, but this new code factoring is
almost surely better.  The statistical tests pass, as before.

* Address Araq comment in https://github.com/nim-lang/Nim/pull/10084
We can always add in some `var` version later if desired to save
memory, but this change now at least firms up the `sample` interface.

* Rename `cumsum` -> `cumsummed` to honor NEP1 style.  Re-instate `cumsum` as
the in-place transformation.  Test both in `tests/stdlib/tmath.nim` and use
`cumsummed` in the example code for sample since that's a simpler example.

* Fix requests from https://github.com/nim-lang/Nim/pull/10084 :
  example in lib/pure/math.nim and comment whitespace in lib/pure/random.nim
2018-12-31 14:52:51 +01:00
..
2017-07-25 09:28:23 +02:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:25 +01:00
2018-12-11 21:23:21 +01:00
2014-01-13 02:10:03 +01:00
2018-11-23 11:58:29 +01:00
2018-11-23 11:58:32 +01:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:22 +01:00
2018-12-27 22:40:09 +01:00
2018-12-11 21:23:25 +01:00
2018-12-11 21:23:22 +01:00
2018-12-30 02:48:37 +01:00
2018-01-21 03:04:22 +01:00
2018-12-11 21:23:25 +01:00
2018-11-23 11:58:28 +01:00
2018-12-11 21:23:25 +01:00
2018-12-11 21:23:25 +01:00
2018-12-30 02:45:43 +01:00
2018-12-15 14:30:21 +01:00
2018-12-11 21:23:22 +01:00
2018-12-22 18:39:20 +01:00
2018-12-11 21:23:26 +01:00
2018-12-11 21:23:22 +01:00
2018-12-27 22:40:09 +01:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:22 +01:00
2018-12-11 21:23:22 +01:00
2013-03-16 23:53:07 +01:00
2018-10-12 17:27:47 +02:00
2018-11-09 16:36:49 +01:00

This directory contains the test cases.

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

Note: Tests are only compiled by default. In order to get the tester to execute the compiled binary, you need to specify a spec with an action key (see below for details).

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: compile

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 cat <category>.

The folder rodfiles contains special tests that test incremental compilation via symbol files.

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.